PWM analogue output

Kiwi Bruv

Member
I want to produce an analogue output from a picaxe to replace the signal from a pot which is an input to a comparator (or controls an astable 555)

Does the frequency matter and how do I decide the values of the Cap and Res?

Can someone give me a starter to begin experimenting.
 

BeanieBots

Moderator
The RC values depends on a lot of things but here are the basics to get you started.
Frequency is important, you want an RC of about 10 times your base PWM period.
(depends on how much ripple you can tollerate and how much delay in response you can cope with)
If we assume a PWM frquency of 3kHz, then the period is about 0.0003S
An RC of 1uF and 30k would be about right.
But that assumes no load on the RC.
If you load it, then the R is effectively decreased.
One way to avoid that is to buffer it with an op-amp or similar. Another way, is to decrease R (so that the effect is smaller) and increase C to keep RC the same.
I don't know what loading your 555 circuit would present so try it and see.
If you get a lot of ripple then try 1uF and 3k.
The values are not critical but it is a balancing act between response and ripple.
 

kranenborg

Senior Member
Hi,

The following link might well answer all your questions; it has detailed info about calculating the component values to be used, loading effect etc.:

http://www.zilog.com/docs/z8/appnotes/1channel_dac.pdf

Note that the theory applies to any microcontroller ...

Regards,

Jurjen Kranenborg
http://www.kranenborg.org/ee/picaxe
 

BeanieBots

Moderator
Nice link kranenborg, thanks.
Also gives equation for two stage filter which is a better way of removing ripple without decreasing response time.
 

Kiwi Bruv

Member
Thankyou. I am going to use an op amp to buffer the cap because I also need voltage amplification. Can I supply the op amp with the voltage range I need to get the output swing I need ie 0 to 5V pwm gets converted to 0 to 5V dc by the RC which then gets converted to 1 to 11 V by the op amp.
 

premelec

Senior Member
For what it's worth after trying a number of pwm schemes and integrators I'm using Digital to Analog Convertors - The DAC holds the output you set with a serial string instruction. see www.ti.com for data sheets on TLV5628 [8 out 2 ref] TLC5620 [4 out 4 ref].

The DACs are basically controlled digital potentioneters in this case with the ref voltage at the high side of the pot.

I found the updating with PWM was giving too much ripple in my case. The single channel of PWMOUT on the other hand worked ok on the 08M as it runs continuously in the background.
 

BeanieBots

Moderator
You should supply the op-amp with a volt or so more than you need it to put out. That applies to both ends of the range. ie if you needed -10v to +10v then supply the op-amp with around +/- 12v.
As suggested by premelec, PWM can be a chore because it must be refreshed, but this is less of a burden when buffered with an op-amp. PWMout is MUCH better because it is continuous. Infact, whenever I refer to PWM I tend to assume the PWMout command and forget that on a PICAXE "PWM" referes to the non continuous command.
 
Top