You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
STM32 currently produces an "analog output voltage" by controlling the duty cycle of a PWM peripheral. However, stm32 has DAC peripherals. We should use these instead.
EDIT: We should have two AnalogOutput implementations in mcal/stm32 - one for AnalogOutputDAC and AnalogOutputPWM, the latter is the one we already use. Both should be subclasses of the shared::periph::AnalogOutput. Then, each project has the choice of using PWM or DAC to simulate an analog signal, but the public interface is the same.
Rename the existing stm32 AnalogOutput class (and file) to AnalogOutputPWM. Apply this to all projects where it's used. You can ignore the debug/ projects
Create a new file & class AnalogOutputDAC. Follow the structure of the other peripherals.
Implement the SetVoltage() function using DAC instead of PWM.
Testing
Create a project Demo/AnalogDAC.
In main(), use a DAC to create an interesting signal (ex sine / sawtooth wave) which shows you can control the voltage.
Between each voltage level, add a couple milliseconds of delay. See DelayMS() in the Demo/Blink project
Create an stm32 platform. Look at other projects for the structure.
Open the STM32CubeMX program and start a new project for your board. Save the project as AnalogDAC/platforms/stm32/cubemx/board_config.ioc
Set up a DAC pin.
In the "Project Manager" tab of CubeMX, choose these settings
Project Structure: Basic
Toolchain: CMake
Check "Do not generate main()`
Code Generation Tab:
Select "Generate separate .c and .h files"
Build the project from racecar/firmware/ with
make PROJECT=Demo/AnalogDAC PLATFORM=stm32
Verify the signal on an oscilloscope
The text was updated successfully, but these errors were encountered:
STM32 currently produces an "analog output voltage" by controlling the duty cycle of a PWM peripheral. However, stm32 has DAC peripherals. We should use these instead.
EDIT: We should have two
AnalogOutput
implementations inmcal/stm32
- one forAnalogOutputDAC
andAnalogOutputPWM
, the latter is the one we already use. Both should be subclasses of theshared::periph::AnalogOutput
. Then, each project has the choice of using PWM or DAC to simulate an analog signal, but the public interface is the same.See the datasheet section 16
Task
stm32
AnalogOutput class (and file) toAnalogOutputPWM
. Apply this to all projects where it's used. You can ignore the debug/ projectsAnalogOutputDAC
. Follow the structure of the other peripherals.SetVoltage()
function using DAC instead of PWM.Testing
Demo/AnalogDAC
.main()
, use a DAC to create an interesting signal (ex sine / sawtooth wave) which shows you can control the voltage.stm32
platform. Look at other projects for the structure.AnalogDAC/platforms/stm32/cubemx/board_config.ioc
Build the project from
racecar/firmware/
withVerify the signal on an oscilloscope
The text was updated successfully, but these errors were encountered: