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?
- posted
13 years ago
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?
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
If you need to control many output pins, e.g. for a LED matrix, "Bit Angle Modulation" may be a good technique.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.