logoalt Hacker News

imglorptoday at 3:21 PM3 repliesview on HN

Today I learned you can use generic GPIO PWM to fake an analog voltage.

https://ww1.microchip.com/downloads/en/Appnotes/90003250A.pd...


Replies

throwaway219450today at 3:36 PM

This is also how Arduino emulates analog output, since most micros don’t have a hardware DAC

https://docs.arduino.cc/language-reference/en/functions/anal...

show 1 reply
inigyoutoday at 4:41 PM

Congrats, you're one of today's lucky 10000! It's extremely common actually. I don't know if they're still doing it but Raspberry Pi 1,2,3 had only PWM audio output, not true analog.

A PWM output followed by an adequate filter can be considered a cheap, low quality type of DAC. You never get the quality as good as you want but you get it good enough.

technothrashertoday at 4:26 PM

Working in process control, this is an everyday thing for me. But I prefer to use pulse frequency modulation, which is what a lot of dedicated DACs use.