2025-01-20 12:12 PM
Hi,
I've successfully generated a sine wave using stm32 DAC. The current generated sine wave has the following properties; where min amplitude is 0 to max amplitude 4096 and the zero crossing is at 2048. I'd like to shift the output sine wave amplitude to where min amplitude -2048 to max amplitude 2048 and zero crossing is at 0. Are there any registers or methods i can use to achieve this task?
Best Regards,
Vu
2025-01-20 01:39 PM
There are ways to get a zero-balanced output voltage - but not with an MCU that only has a positive supply voltage.
Let's think about this: your DAC output ranges from 0...4095 (not 4096, because zero also is one step), which corresponds to a full voltage swing, e.g. 0...3.3V. In order to shift the range by 2048 in the negative direction, you would have to be able to output a negative voltage - but where would this come from?
For this reason, there are electronic circuits such as a level shifter with an opamp that can achieve your goal using a simple differential amplifier, which can be found, for example, in the Wikipedia article on the topic opamp applications.
Hope that helps?
Regards
/Peter