Compare commits

...

7 Commits
v0.1 ... master

1
.gitattributes vendored

@ -0,0 +1 @@
ChibiOS_20.3.2/** linguist-vendored

@ -1,25 +1,26 @@
# stmdsp
The `stmdsp` project enables certain STM32 development boards to be used as a digital signal processing (DSP) education tool.
The *stmdsp* project enables certain [NUCLEO development boards](https://www.st.com/en/evaluation-tools/stm32-nucleo-boards.html) to be used as an educational tool for digital signal processing (DSP). The solution is portable, and can be used without any external tools or lab equipment.
The project consists of two parts: the firmware, which allows users to upload custom DSP algorithms to process signals in real-time; and the GUI currently named [stmdspgui](https://code.bitgloo.com/clyne/stmdspgui), which facilitates algorithm design, upload, and execution, while also providing numerous analysis features.
The firmware for the device is written in C++, building on top of the [ChibiOS](https://www.chibios.org/dokuwiki/doku.php) real-time operating system.
The project consists of three parts:
1. Firmware that allows users to upload custom DSP algorithms to process signals in real-time.
2. A [custom add-on board](https://code.bitgloo.com/clyne/stmdsp/wiki/DSP-add-on-board) which provides the necessary circuitry for interfacing with signals and the host computer.
3. [Computer software](https://code.bitgloo.com/clyne/stmdspgui) that facilitates algorithm design and execution while also providing numerous analysis features.
## Features
* Real-time signal processing: the input channel is read from the ADC, and the processed output is sent out over the DAC.
* Signal sampling rates from 8kS/s up to 96kS/s.
* Custom algorithms, uploaded over USB at run-time, can be applied to the input signal.
* The second DAC channel can act as a signal generator, should no other input be available.
* Analysis features, including measuring algorithm execution time and logging input and output samples.
## Supported development boards
* Real-time signal processing: signal readings from the ADC are streamed through the loaded algorithm binary and out the DAC.
* Custom algorithms are uploaded to the hardware at run-time, enabling a fast design and test process.
* Supports signal sampling rates from 8kS/s up to 96kS/s, with buffer size of up to 4,096 samples.
* Supports signals between -3.3V and +3.3V, with adequate protection for the development board.
* Two parameter knobs allow for algorithm adjustments while the algorithm is running.
* An on-board signal generator eliminates the need for inputs from external hardware.
* Numerous analysis features, including signal visualization and algorithm execution time measurement, eliminate the need of other equipment such as oscilloscopes.
This project is aided by a custom add-on board, which is designed to stack on top of STMicroelectronic's NUCLEO line of dev boards.
## Learn more
At the moment, only the NUCLEO-L476RG board is fully supported.
See the [project's wiki](https://code.bitgloo.com/clyne/stmdsp/wiki/Home) for more details. The `doc` folder also contains add-on board schematics and a work-in-progress PDF guide (which may later be abandoned in favor of the wiki).
## Programming instructions and more information
### Licensing
See the `doc` folder for further project documentation, including a PDF guide.
The *stmdsp*, *stmdspgui*, and ChibiOS projects are all licensed under version three of the GNU General Public License.

Binary file not shown.
1 Designator Quantity Manufacturer Part Manufacturer
2 AUDIO1,AUDIO2,AUDIO3 3 PJ-313D HRO
3 C1 1 0603X105K100NT Guangdong Fenghua Advanced Tech
4 C2,C3 2 0603B225K100NT FH
5 C4,C5,C6 3 CL10B104KB8WPNC Samsung Electro-Mechanics
6 H1,H2,H3 3 2171-210SG0CUNT3 Wcon
7 H4 1 1-87215-2 TE Connectivity
8 LED4 1 19-237/R6GHBHC-M07/2T Everlight Elec
9 P1,P2,P3,P4 4
10 R1,R2 2 3386P-1-103 Chengdu Guosheng Tech
11 R3 1 ARG05BTC1002 Viking Tech
12 R4 1 RN732ATTD3002B25 KOA Speer Elec
13 R6 1 RC0603FR-07511RL YAGEO
14 R7,R8 2 RC0603JR-07240RL YAGEO
15 R10,R17,R22 3 AC0805FR-0720KL YAGEO
16 R11,R12,R13,R14,R15,R16,R19,R20,R21 9 ERJ3GEYJ103V PANASONIC
17 R18,R23 2 ARG02FTC0330 Viking Tech
18 U1 1 LM2776DBVR TI
19 U2,U3,U4 3 LM833DR2G ON
20 U6 1 REF3333AIDBZR TI
21 USB1 1 U-F-M5SS-W-1 HRO

@ -32,7 +32,7 @@ static void setBufferSize(unsigned char *);
static void updateGenerator(unsigned char *);
static void loadAlgorithm(unsigned char *);
static void readStatus(unsigned char *);
static void startConversionMeasure(unsigned char *);
static void measureConversion(unsigned char *);
static void startConversion(unsigned char *);
static void stopConversion(unsigned char *);
static void startGenerator(unsigned char *);
@ -53,7 +53,7 @@ static const std::array<std::pair<char, void (*)(unsigned char *)>, 19> commandT
{'D', updateGenerator},
{'E', loadAlgorithm},
{'I', readStatus},
{'M', startConversionMeasure},
{'M', measureConversion},
{'R', startConversion},
{'S', stopConversion},
{'W', startGenerator},
@ -159,12 +159,10 @@ void readStatus(unsigned char *)
USBSerial::write(buf, sizeof(buf));
}
void startConversionMeasure(unsigned char *)
void measureConversion(unsigned char *)
{
if (EM.assert(run_status == RunStatus::Idle, Error::NotIdle)) {
run_status = RunStatus::Running;
ConversionManager::startMeasured();
}
if (EM.assert(run_status == RunStatus::Running, Error::NotRunning))
ConversionManager::startMeasurement();
}
void startConversion(unsigned char *)
@ -177,7 +175,7 @@ void startConversion(unsigned char *)
void stopConversion(unsigned char *)
{
if (run_status == RunStatus::Running) {
if (EM.assert(run_status == RunStatus::Running, Error::NotRunning)) {
ConversionManager::stop();
run_status = RunStatus::Idle;
}

@ -65,11 +65,9 @@ void ConversionManager::start()
DAC::start(0, Samples::Out.data(), Samples::Out.size());
}
void ConversionManager::startMeasured()
void ConversionManager::startMeasurement()
{
Samples::Out.clear();
ADC::start(Samples::In.data(), Samples::In.size(), adcReadHandlerMeasure);
DAC::start(0, Samples::Out.data(), Samples::Out.size());
ADC::setOperation(adcReadHandlerMeasure);
}
void ConversionManager::stop()
@ -157,12 +155,14 @@ void ConversionManager::threadRunner(void *)
asm("mov %0, sp" : "=r" (sp));
samples = entry(samples, size);
asm("mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples;
} else {
// Start execution timer:
asm("mov %0, sp; eor r0, r0; svc 2" : "=r" (sp));
samples = entry(samples, size);
// Stop execution timer:
asm("mov r0, #1; svc 2; mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples;
}
}

@ -31,8 +31,8 @@ public:
// Begins sample conversion.
static void start();
// Begins conversion with execution time measured.
static void startMeasured();
// Prepare to measure execution time of next conversion.
static void startMeasurement();
// Stops conversion.
static void stop();

@ -22,7 +22,8 @@ enum class Error : char
BadUserCodeLoad,
BadUserCodeSize,
NotIdle,
ConversionAborted
ConversionAborted,
NotRunning
};
class ErrorManager

Loading…
Cancel
Save