8000 GitHub - frolovilya/stm32-signal-generator: STM32F4 analog audio-level signal generator with precise UART control
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

frolovilya/stm32-signal-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stm32-signal-generator

Turns your STM32F4 development board into an analog audio-level signal generator with precise UART control. Uses built-in 12-bit DAC and 192kHz sampling rate to produce waves of various form, frequency and level generated by Welle library.

Build

Install Welle library header.

Install STM32CubeCLT command tools package with arm-none-eabi-gcc, STM32_Programmer_CLI and ST-LINK_gdbserver tools included.

Build the project using CMake:

mkdir build; cd build

# Using USART2 by default if -DUSE_USART3=1 flag isn't provided
cmake ../ -DPROGRAMMER_CLI=/opt/ST/STM32CubeCLT_1.18.0/STM32CubeProgrammer/bin/STM32_Programmer_CLI \
    -DUSE_USART3=0

make

# Upload to the device
make flash

Connectivity

DAC output pin is PA4.

Using USART2 by default: TX PA2, RX PA3. Note that on Nucleo boards USART2 is routed to ST-Link USB, so that you can send UART commands directly by plugging-in the board via USB.

Using USART3 when built with -DUSE_USART3=1: TX PC10, RX PC11. Use this feature when external UART control is required.

Signal Level

Built-in DAC produces signals with max voltage = Vdda, so for 3.3V supply it outputs signals with a peak-to-peak level 3.3V and DC offset 1.65V. Connect a capacitor to the DAC output pin to remove the DC offset and generate signals oscillating around 0V with a peak output of 1dBV.

Typical levels:

  • Line: -10dBV
  • Pro line: 4dBu
  • Phono: -45dBV

Below is the conversion table of the supported level units:

Unit Conversion from mV peak
mV_RMS mV / sqrt(2)
dBV 20 * log(mV_RMS)
dBu 20 * log(mV_RMS / 0.775)

Usage

Command Syntax

# WaveForm Frequency(Hz) Level(mV)
{sine|square|saw|triangle} frequency{[Hz]|kHz} level{[mV]|mVRMS|dBV|dBu}LF

Note that LF(\n) at the end is required.

Supported frequency is in the range from 20Hz to 20000Hz.

Sending Commands via Serial Port

When using Nucleo board or any UART to USB adapter it's possible to send commands via a serial port.

# Install picocom serial port terminal
brew install picocom

# Find your connected device
ls /dev/tty.*

# Start session (press Ctrl+a Ctrl+x to exit)
picocom --echo --omap crlf --imap lfcrlf,bsdel -b 115200 /dev/tty.usbmodem14203

Examples

sine 440Hz -10dBV
# Generating sine, 440Hz, 316mV RMS (-10dBV) signal

sine_440hz_-10dbv

square 100Hz 200mVRMS
# Generating square, 100Hz, 200mV RMS (-6dBV) signal

square_100hz_200mvrms

saw 1kHz 100mV
# Generating saw, 1000Hz, 71mV RMS (-23dBV) signal

saw_1khz_100mv

triangle 10kHz -3dbU
# Generating triangle, 10000Hz, 548mV RMS (-5dBV) signal

triangle_10khz_-3dbu

About

STM32F4 analog audio-level signal generator with precise UART control

Topics

Resources

License

Stars

Watchers

Forks

0