~
Overview of the prototype.
Behavior Description
The device acts as a function generator with the user being able change settings for the device via a numerical keypad. The keypad allows for three different properties of the waveform being generated to be modified in real-time. The three properties are: frequency, waveform type, and duty cycle (for square waves). Pressing number buttons 1 - 5 on the keypad, selects the frequency starting at 100 Hz and going up to 500 Hz. Pressing ‘6’ causes the waveform to change to sine, ‘7’ to triangle, ‘8’ to sawtooth, and ‘9’ to a square wave. When the current waveform is a square wave, pressing the ‘*’ key reduces the duty cycle by 10%, which cannot go lower than 10%. Pressing ‘0’ resets the duty cycle to 50%, and ‘#’ increases the duty cycle by 10%, with a maximum of 90%.
Physical Overview
This project was built around a STM32 Nucleo64-L476RG development board. The user-interface is a old school 12 button telephone keypad. The waveform generation is handled by a external MCP4921 12-bit DAC with a SPI interface. There are also four LED’s which output what button was last pressed represeteed in binary.
BOM:
Item | Designator | Description | Price |
---|---|---|---|
NUCLEO-L476RG | U1 | 12-Bit DAC with SPI Interface, 8-Pin PDIP, Extended Temperature | 14.90 |
MCP4921 | U2 | 12-Bit Single Output DAC with SPI | 2.81 |
Keypad | K1 | 12 Button Keypad | 4.95 |
LED | D1, D2, D3, D4 | Light-Emitting Diode | 1.12 |
Resistor | R1, R2, R3, R4 | Resistor | 0.40 |
Software Overview
This project was created using register based configuration for the STM32. Choosing to not utilize STM’s HAL (hardware abstraction layer) provided for a more in depth learning experience which required extensive research into the STM technical manuals for proper perhipherial configuration and setup via the registers. To precisely control the timing of output waves, the output values for the DAC were set at controlled intervals using a interupt timer. The values for waveforms were generated using a script and stored in a look up table to save on computational overhead. The ARR timing value was calcualated based on the size of the LUT, the minimun frequency needed (100 Hz in this case) and the system clock, using this formula ARR = F_SYSCLK / (n_lookup * F_min).