Skip to the content
4 layers36 × 60 mmSignal generator, the printed circuit board in 3D

Signal Generator with an STM32

Size
36 × 60 mm
Copper layers
4
Thickness
1.6 mm
Parts
70
Nets
89
Pads
290
Tracks, vias
315, 57
Pours
8
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
25 Oct 2022
Updated
27 Nov 2024

Overview

Signal generator is an open-source printed circuit board by NidasioAlberto, from the NidasioAlberto/signal-generator repository on GitHub. It is a 4-layer board of 36 × 60 mm with 70 parts on 89 nets, routed with 315 tracks and 57 vias.

It is built around the FT230XQ-R, TLV61048DBV and MEM2080-00-128-00-A, with the LD39050PU33R and LDK320AM120R among its other parts. Its parts include 30 capacitors, 20 resistors, 7 ICs, 6 connectors and 4 diodes. It belongs with the STM32 boards of this library.

Main components

5

README

readme.md

Signal Generator with an STM32

Introduction

The main idea of this project is to develop a waveform generator instrument using an STM32 microcontroller and its built-in DAC. The project has 2 parts:

  • Software: The application needs to showcase the STM32 capability to output waveforms at sample rates of 100kHz or greater. The software has to include a peripheral driver to access the built in DAC using DMA.
  • Hardware: The device has to to implement a waveform generator output stage circuitry that allows to extend the capabilities of the built in DAC.

To achieve this goals a custom board was designed and software drivers were developed for the DAC and DMA. The final product also includes a text interface where the user can setup an arbitrary waveform and the device parses the user input using Flex and Bison.

Console Example PCB Render

Analog Front End

The stm32 incorporates a Digital-to-Analog Converter (DAC) with an integrated output buffer. When enabled, the buffer allows the DAC to drive external loads directly. However, this comes at the cost of limited driving capability, especially when interfacing with capacitive loads. Disabling the buffer offers a pure analog output, but necessitates an external buffer or amplifier to drive any meaningful external load. The inherent impedance of the DAC's output pin can also cause distortions and constrain the signal's frequency, particularly when dealing with capacitive loads.

Integrating an external operational amplifier (op-amp) into the analog front-end offers multiple advantages:

  • Buffering DAC Output: The op-amp serves as a buffer, isolating the DAC from the actual load. This setup minimizes the effects of the DAC output pin's impedance, enabling the DAC to operate in a near-ideal environment.
  • Voltage Scaling: Configured in a non-inverting amplifier mode, the op-amp provides adjustable gain, facilitating flexible signal amplitude adjustments.

Given that the board is powered via USB, which typically provides 5V, there's a need to step up this voltage to achieve the 12V requirement for the analog front end:

  • Boost Converter: The TLV61048 boost converter is employed to step up the USB's 5V to 13.12V.
  • Linear Voltage Regulator: Following the boost converter, an LDO is used to convert the 13.12V from the boost converter to a stable 12V output. This stable 12V supply is crucial to ensure that the analog front-end, especially the operational amplifier, operates with consistency.

The opamp circuit also features a voltage divider to feedback the output signal to the STM32's ADC. This could allow the microcontroller to perform automatic calibration of the opamp gains. Here's the provided LaTeX content converted into markdown:

Microcontroller and digital domain

The STM32F205 is a low-end microcontroller with a 120MHz clock speed, 128KB of RAM, and the required peripherals needed by the project (DAC, DMA, and timers). It was used mainly because it was already stocked in the lab.

The board also features:

  • An external 25MHz crystal oscillator to drive the microcontroller.
  • A USB to UART bridge to allow the user to interact with the device via a serial terminal.
  • An RGBW addressable led used for status indication.
  • A header connector that exposes the SWD programming interface.
  • Two buttons: one for reset and one for the BOOT0 pin.
  • A microSD card slot to store files.

Software architecture

The software powering the signal generator board is built upon the Miosix operating system and features 2 main components:

  • Drivers for the DAC and DMA peripherals.
  • A parser built using Flex and Bison that allows interpreting the user input into arbitrary math functions used to generate the output waveform.

Peripherals drivers

The STM32F205 microcontroller is equipped with a versatile Digital-to-Analog Converter (DAC) peripheral that offers 12-bit resolution and two separate channels, effectively incorporating two DACs. This dual-channel architecture permits simultaneous generation of two distinct analog outputs, allowing our custom board to feature two independent output channels.

The DAC's conversion process can be initiated through multiple methods. It can be triggered manually via software, which provides direct control over the conversion timing. Alternatively, for applications requiring precise and periodic analog outputs, external triggers can be employed. A common external trigger source is a timer, which can initiate DAC conversions at predetermined intervals, ensuring consistent waveform generation.

The STM32's DAC is also designed with the capability to generate DMA requests. Once the DAC is ready for new data, it can signal the DMA peripheral to fetch the next data sample. The DMA (Direct Memory Access) controller is a powerful tool designed to handle data transfers independently of the CPU's operation. This peripheral is characterized by sixteen independent streams, each of which can be paired with different peripherals, granting a wide range of configuration possibilities. By leveraging the DMA's rapid data transfer capabilities, the DAC can be persistently supplied with data while leaving the CPU time to generate new data samples or perform other tasks.

One of its standout features is the double buffering mode. This mode uses two memory pointers: while one buffer is actively engaged by the DMA stream, the other can be prepared by the CPU, ensuring uninterrupted data flow.

In the context of the signal generator project, the DMA plays a crucial role. Each DAC is set up to utilize an external trigger originating from a timer. With every trigger event, the DAC issues a DMA request for a new data sample. The DMA has been configured in double buffer mode. Alternatively, a single buffer mode combined with the half-transfer interrupt could have been adopted to achieve a similar result. This integration of the DAC with the DMA and a timer is what ultimately powers the project's ability to generate high-frequency waveforms even with a low-end microcontroller such as the STM32F205.

The developed drivers are C++ classes that abstract the peripherals and allow the programmer to easily configure and use them. In particular, the DMA driver is divided into two classes and one struct:

  • DMADriver: A singleton that manages all DMA streams. When a piece of code needs a stream, it can request it to the DMADriver. If the stream is already in use, the DMADriver will pause the thread until the stream is available, otherwise, it will acquire the stream and return it to the caller.
  • DMATransaction: A struct that holds all configuration parameters for a specific transfer. This includes source and destination addresses, data size, double buffer, interrupts, and so on.
  • DMAStream: This class allows configuring the stream for a specific transaction, start and stop it, and easily handle interrupts. In particular, interrupts can be waited for with or without a timeout (thanks to the Miosix's timed wait feature) or registering a callback function that will be called when the interrupt occurs.

Project outcomes

Concrete outcomes

The project achieved two concrete outcomes:

  • Electronic board: The board was designed and assembled successfully. It includes an analog front end that extends the capabilities of the STM32's built-in DAC and also includes features, such as the ADC feedback and micro SD, that allows further experimentation.
  • Software drivers: Two software drivers were developed, one for the DAC and one for the DMA. These allow the use of the peripherals in a simple and efficient way.

Signal Generator board hooked up to an oscilloscope

Learning outcomes

Developing both the hardware and the software allowed me not only to learn about the STM32 microcontroller and its peripherals but also to learn about the whole process of designing and assembling a PCB.

Particular effort went into the design of the board itself, selecting and sourcing the components, and manually assembling the board. It was a challenge because, being my first time creating a complex PCB with a microcontroller, I was not well prepared. I had to learn about the different types of components, which were required for my design, and which not. Some special takeaways were the importance of reading carefully the components datasheet, finding application notes to understand similar projects, and learning how to design and order a PCB (with KiCad and JLCPCB).

The assembly of the board was the most exciting part because I got to see my design come to life. I procured the necessary soldering equipment (solder paste, a hot plate, a hot air gun, and a microscope) and I soldered the board first by distributing the solder paste with a stencil and then by heating the board with the hot plate for the top layer, and with the hot air gun for the bottom layer. I had to learn how to use the equipment and how to solder the different components.

The software side was instead more akin to my previous experiences. I had already worked with microcontrollers and already used the Miosix operating system. However, I had never worked with the DMA peripheral. The most challenging aspects were understanding how the peripherals work by reading the reference manual and also finding examples online which are hard to come by.

Existing knowledge

The most useful knowledge that helped me in this project came from 3 sources:

  • Advanced Operating System: In particular, the parts on concurrency, thread programming, and analysis of the features in the Miosix operating system.
  • Embedded Systems: The course gave me a good understanding of the development process of a microcontroller-based system, both for the design aspects and for the production processes involved.
  • Skyward Experimental Rocketry: Most of the experience I had prior to this academic year was my involvement in the Skyward Experimental Rocketry team. Previously I was involved in the design and development of the software for the rocket. This year I also had the responsibility of managing the production of the avionic system as a whole, including the electronic part. This gave me a good opportunity to work on another project and the luck of knowing lots of talented teammates.

Problems encountered

The worst setback I faced was the board redesign. In the first version, I used an STM32F103 which is a cheaper microcontroller that has no built-in DAC! I realized this only after I had assembled the board and tried to use it. I had to adjust the schematic and the PCB in order to use the STM32F205 instead and reorder the board.

Once the board was ready I faced other problems during the development of the drivers but I managed to solve them without major issues. In this process, the debugger was particularly useful to understand what was going on.

Parts

70
QtyValueFootprintReferences
12100nCapacitor_SMD:C_0603_1608MetricC3, C6, C7, C8, C12, C16, C17, C18, C19, C20, C21, C23
61uCapacitor_SMD:C_0603_1608MetricC22, C25, C26, C27, C29, C30
20.5pCapacitor_SMD:C_0603_1608MetricC9, C10
21.33kResistor_SMD:R_0603_1608MetricR8, R10
210uCapacitor_SMD:C_0603_1608MetricC1, C28
22.2uCapacitor_SMD:C_0603_1608MetricC14, C15
2240kResistor_SMD:R_0603_1608MetricR13, R15
227Resistor_SMD:R_0603_1608MetricR1, R2
24.75kResistor_SMD:R_0603_1608MetricR7, R9
246.4kResistor_SMD:R_0603_1608MetricR11, R12
247pCapacitor_SMD:C_0603_1608MetricC4, C5
25.1kResistor_SMD:R_0603_1608MetricR3, R4
291kResistor_SMD:R_0603_1608MetricR14, R16
11.54MCapacitor_SMD:C_0603_1608MetricR19
1100kCapacitor_SMD:C_0603_1608MetricR20
1100pCapacitor_SMD:C_0603_1608MetricC11
110kResistor_SMD:R_0603_1608MetricR18
11kResistor_SMD:R_0603_1608MetricR17
13.32Resistor_SMD:R_0603_1608MetricR5
1330uSignal Generator Components:WCAP-PSHPC2
14.7uSignal Generator Components:XAL4030L1
14.7uCapacitor_SMD:C_0603_1608MetricC24
143.2Resistor_SMD:R_0603_1608MetricR6
16.8uCapacitor_SMD:C_0603_1608MetricC13
1AudioJack3Signal Generator Components:SJ-3523-SMT-TRJ1
1Conn_01x04Connector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ6
1Conn_02x02_Odd_EvenConnector_PinHeader_2.54mm:PinHeader_2x02_P2.54mm_HorizontalJ2
1D_ZenerSignal Generator Components:BZT52C10-TPD4
1FT230XQPackage_DFN_QFN:QFN-16-1EP_4x4mm_P0.65mm_EP2.1x2.1mmU1
1FT5HNOscillator:Oscillator_SMD_Fox_FT5H_5.0x3.2mmU4
1IN-PI55QASignal Generator Components:IN-PI55QAD3
1LD39050PU33RSignal Generator Components:LD39050PU33RU5
1LDK320AM120RSignal Generator Components:LDK320AM120RU7
1LED BlueLED_SMD:LED_0603_1608MetricD1
1LED OrangeLED_SMD:LED_0603_1608MetricD2
1MEM2080-00-128-00-ASignal Generator Components:MEM2080-00-128-00-AJ4
1Opamp_DualPackage_SO:SOIC-8_3.9x4.9mm_P1.27mmU2
1STM32F205RCTxPackage_QFP:LQFP-64_10x10mm_P0.5mmU3
1SW_PushButton_Switch_THT:SW_PUSH_6mm_H5mmSW1
1SW_SPDTSignal Generator Components:Push Button Switch 7x7mmSW2
1Screw_Terminal_01x04TerminalBlock_Phoenix:TerminalBlock_Phoenix_MPT-0,5-4-2.54_1x04_P2.54mm_HorizontalJ3
1TLV61048Signal Generator Components:TLV61048U6
1USB_C_Receptacle_USB2.0Signal Generator Components:USB4105-GF-AJ5

Similar boards

  • 4 layers52.7 × 60.9 mmCartGen4, the printed circuit board in 3D

    CartGen4

    elialm/ecgc-hardware

    Hardware documentation of the ECGC cartridge

    86 parts2CERN-OHL-P-2.0
  • 2 layers200 × 200 mmFULL BOARD, the printed circuit board in 3D

    FULL BOARD

    AndyPpohl/PCB-Conundrum-Crack

    128 parts1
  • 4 layers70 × 110 mmNixon phone, the printed circuit board in 3D

    Nixon phone

    rrruark/nixon_phone

    Analog Telephone Adapter Audio Player

    117 partsMIT
  • 2 layers52.8 × 55 mmILDAWaveX16, the printed circuit board in 3D

    ILDAWaveX16

    stanleyondrus/ILDAWaveX16

    ILDAWaveX16 is an open-source, high-resolution, wireless laser DAC with SD-card playback, network control, and ILDA output.

    95 parts42
  • 4 layers64 × 77 mmOBSPro, the printed circuit board in 3D

    OBSPro

    FabianSchwartau/OBSPro

    Version of the OpenBikeSensor hardware optimized for PCBA

    131 parts3LGPL-2.1
  • 4 layers45 × 53 mmOpenTRV ESP, the printed circuit board in 3D

    OpenTRV ESP

    mpiraux/OpenTRV-ESP

    An open-source and open-hardware thermostatic radiator valve based on the ESP32C6 and the 28BYJ-48 stepper motor.

    64 parts2CERN-OHL-P-2.0
  • 2 layers32 × 46 mmGeneral purpose step up, the printed circuit board in 3D

    General purpose step up

    marcusmueller/12V_step_up

    General purpose Step-Up converter

    26 partsCERN-OHL-S-2.0
  • 4 layers59.3 × 37.5 mmModule, the printed circuit board in 3D

    Module

    Pollex/MFM-Module-RS485

    A MultiFlexMeter (MFM) sensor module. The hardware is a generic carrier: RS-485 + 1-Wire, with a software-selectable sensor supply rail (3.6 V / 5 V / 12 V).

    56 parts

Questions

How big is the Signal generator PCB?

It measures 36 × 60 mm and has 4 copper layers, 1.6 mm thick.

What parts does the Signal generator use?

70 parts, built around the FT230XQ-R, TLV61048DBV, MEM2080-00-128-00-A and LD39050PU33R. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Signal generator KiCad files?

From the NidasioAlberto/signal-generator repository on GitHub, at the commit this page was made from: the board is pcb/Signal Generator.kicad_pcb and its schematic pcb/MCU.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Signal generator design in my own project?

Its repository states no licence, so its author keeps all rights: ask NidasioAlberto before reusing the design.