A DAQ with 8 Diff/16 Sin. Ended +/- 12V input channels and four +/- 12V output channels using the STM32G4

Similar projects worth following
The DAQ is based around the STM32G4 MCU with integrated USB controller and ADCs and DACs. In complement a AD4254 Amplifier is used for the analog input conditioning. Currently the hardware features and characteristics of the DAQ are the following:

Two Analog Blocks with each:
- 4 Diff. / 8 Sing. ended Inputs with [+/- 12V; +/-16mV] ranges
- 12 bit ADC with up to 62.5 KSPS, shared between channels
- Programmable current source from 100uA to 1.5mA
- 2 Analog Outputs with +/- 12V output range, 12 bit with up to 1 MSPS

Digital IO Block with:
- 16 GPIOs with 5V level shift circuitry (max. 1 MHz)
- SPI, I2C and UART hardware decode interfaces

The firmware and PC software are very early in development. The firmware is in C and uses the STM32 LL library and USB stack. The PC software is in C# and uses WPF and Livechart for the GUI, with a python library planed.


The inspiration for this project came while working at home and only having a multi-meter as test equipment. The first idea was to make a simple low sample rate USB oscilloscope using the integrated analog circuits of the STM32G4, the ADC and the OpAmps with PGA. This then evolved into this DAQ project as the need for many, slower, analog input channels with differential mode became the focus. The idea is to create a DAQ with hardware feature parity with popular USB DAQs from NI, LabJack and others while having a BOM bellow the price of those options. Of course the software compatibility and features will be way more limiting.


The heart of the DAQ is the new STM32G4 MCU which is used for control, USB Interface and for its ADCs and DACs. The board is designed to also use dedicated external ADC and DAC for increased performance but higher cost.

For the analog input signal conditioning the ADA4254 is used in combination with the DG409 Multiplexer, to get the desired number of analog input channels. A trade of between sample rate and circuit complexity was made by splitting the analog input into two identical blocks with each it's own ADC and input signal conditioning. Each of these blocks has 4 differential, 8 single ended, input channels, one programmable current source and two analog outputs, besides 5V and 3.3V outputs. The analog outputs are simply amplified outputs of the MCU DACs, two DACs per block.

The positive and negative voltage rails needed are derived from the USB supply using a combined Boost and Inverter switching converter, the TPS65130, in combination with a combined positive and negative rail LDO, the TPS7A39, for noise reduction.

The DAQ also features a digital interface with 16 channels/pins, each working with 5V signals due to integrated level shift circuitry. All these pins are located on a DB-25 connector.

The figure bellow shows the arrangement of the different circuits and connectors on the PCB.

The pinout of all the connectors is shown in the figure bellow:


The analog input is limited to 62.5 ksps shared between all channels of an analog block. This is manly due to channel switching speed, the ADA4254 has to be reprogrammed after each acquisition to switch gain settings, the external multiplexer (controlled by the ADA4254) and the input mode. Also to note that for the best performance, lowest noise and offset, the sampling frequency has to be a even integer division of 125 kHz because the ADA4254 is a chopping amplifier with a chopping frequency of 125 kHz.

The timing of the analog input can be seen in the figure below, in yellow is the CS line to the ADA4254, in blue is the ADC ISR timing, goes high when an ADC conversion is complete, and in red the output of the ADA4254 when sampling two channels, one at -0.9V and the other at 0.9V.

The analog output is limited to about 250 ksps when using full scale steps,  -12V to 12V. This limitation comes from the low slew rate value, 9 V/us, of the amplifier currently used. To achieve the maximum sample rate of 1 MSPS, limited by the STM32G4 DACs, an amplifier with a slew rate of over 24 V/us is needed.

This amplifier will be exchanged in the future even though this limitation is not very important as to get any other signal besides a square wave more then one sample, multiple steps, are needed which decreases the necessary slew rate. This is shown in the figure bellow where a full scale sine wave is generated using 12 samples/steps @ 1 MSPS without a problem. In yellow is the DAC output and in blue the analog output after the amplifier.

The Digital IO, with the current level shift circuitry, is limited to signals bellow 1 MHz and has an input and output impedance of 1 kOhms. Both of these limitations are due to the level shift circuitry used, a simple single MOSFET level shift circuit, and is mainly dictated by the pull-up resistor value. This can be seen in the figure bellow where a pull-up...

Read more »

Adobe Portable Document Format - 2.15 MB - 08/13/2020 at 15:43


x-zip-compressed - 77.29 kB - 08/13/2020 at 15:43


  • 1 × STM32G473RE Cortex-M4 core with DSP and FPU, 170MHz with 512Kbytes of Flash memory, Math Accelerator, High Analog level integration
  • 2 × ADA4254 Zero Drift, High Voltage, Low Power, Programmable Gain Instrumentation Amplifier
  • 2 × DG409 Switches and Multiplexers / Analog Switches and Multiplexers
  • 1 × TPS65130 Split-Rail Converter with Dual, Positive and Negative Outputs
  • 1 × TPS7A39 dual-channel positive & negative LDO

  • PC Software: Analog Output

    NotBlackMagic09/22/2020 at 21:57 0 comments

    The last week was spent on improving the signal generation functions of the PC Software. All signals are now generated with a variable number of sample points that scales with the signal frequency. A minimum of 20 points is used, at the highest signal frequency of 100 kHz, and this scales up to a maximum of 100 points for signal frequencies of 10 kHz or lower. The figure bellow shows a sine wave with the increased number of points, here 100, as well as a new type of signal that the PC Software can now generate, square waves.

    Besides the improved sine wave generation and the added square wave signals, a ramp signal generation was also added. The ramp center point, highest point, can be configured with the duty cycle parameter. The Figure bellow shows an example of a generated Ramp signal as well as another square wave:

    Both the above images are taken with the DAQ sampling its analog outputs.

    The current PC Software is available on my GitHub page. For more information and more figures visit my website.

  • Analog Input Noise and PC Software

    NotBlackMagic09/16/2020 at 16:18 0 comments

    Analog Input Noise

    During the last few weeks, using the PC Acquisition Software, the analog input noise was analyzed. For now only of the Analog Black A but the values should be the same as the hardware and layouts are the same. To get the baseline noise level one analog input channel is configured in differential mode and its inputs are shorted. The standard deviation of the acquired ADC samples is then calculated, this gives us the input noise in ADC counts. In this test scenario a standard deviation of bellow 2 counts was measured, for all ranges and sample rates.

    To get an idea of cross-channel interference the same test as described above is performed, but this time a full range noise signal is injected into an adjacent channel. The output of this scenario is shown in the figure bellow, showing a screenshot of the PC Acquisition Software Window. The noise/standard deviation is bellow 3 counts on the tested channel, in green. The noise signal is visible in red.

    Overall, in all tested scenarios, ranges and sample rates, the standard deviation was always bellow 4 counts which means that the DAQ has a worst case effective resolution of 10-bits.

    PC Software

    As seen above, the PC Acquisition Software is now functional but with a lot of limitations. It is capable of configuring both the Analog Inputs and Output of the Analog Block A. The Analog Input acquisition window refresh rate is very low, only refreshed every 1s, but the PC DAQ driver receives and saves the samples in real time without problems. The limitation is on the Graph Drawing, which needs to be optimized.

    The Figure bellow shows the PC Software with the Analog Input Menu open. The signal shown is generated by the Analog Output channels 1 and 2 and is acquired by the Analog Input channels 1 and 3, using the settings shown in the figure.

    The Analog Output signal generation can, for now, only generated DC signals and sine waves with 20 sampling points, as can be seen in the figure bellow. Also, at high sample rates, the acquired signal sometimes has the spikes seen in the figure above. It is not clear yet what is the origin of them...

    The PC Software is available on my GitHub page.

    For more information and more in-depth explanations visit the website. I also sometimes publish sneak peaks and pictures of project progress on both Instagram and Twitter.

View all 2 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates