Hi, i want use a digital pin as analog output voltage: is it possible linear decrease voltage (maybe with a proper 1-0 combination) as output without PWM?
Digital pin used as analog pin
Oct 12, 2009
3 Replies
You could do PWM in software using a timer interrupt.
Depending on how precise you want the output and rate you want the output to change there are at least two alternative ways you could do this. Both of these ways require a low pass filter connected to the digital pin (as does PWM's)
1) Compute a sigma delta stream and send that to the digital pin. 2) An interesting way to avoid the timing constraints of PWM is to compare the desired output value with a random number and set the pin to a 1 every time the desired value is less than the random number. Do this as often as possible in the application code.Regards,
Walter..
-- Walter Banks Byte Craft Limited
formatting link
If you need to control many output pins, e.g. for a LED matrix, "Bit Angle Modulation" may be a good technique.
formatting link
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required