PWMOUT and variables

tim griff

Member
Any thoughts on this on please - I've looked at the datasheets.

I'm driving an analogue meter using PWMOUT. with the help of the forum the meter now works using

pwmout 1,9 ,b0 ( It does not work if the frequency is any higher; and the value for b0 is 0 to 40 giving me a full scale[ 0 volt to 5 volts]

However the meter has 100 divisions and using the above I only get 40 steps ie 2.5 steps per 1 step in b0.

Any thoughts how I can increase the resolution to about 80 ish steps..... thanks
 

bgrabowski

Senior Member
If you filter and buffer the PWM you should be able to use higher frequencies and so get up to 1023 increments of analogue voltage out. I can forward a data sheet if you wish to e-mail me:
bgrabowski[at]talk21.com
 

Jeremy Leach

Senior Member
Let's think about this.
Assuming you've got a 4MHz clock then from the formula in the manual your frequency is 100KHz.

And the duty cycle varies 0 to 40 (0 to 100%) to give a full scale deflection of the needle.

IMHO the frequency is plenty high enough and could actually be dropped massively and still work. If I've got this right (and haven't been following the other threads) you are simply driving a moving coil meter using PWM - so it's the pulse <i>width </i> not frequency that's causing the variation in meter output. Obviously if the frequency is really low then you'll get a wobbling meter needle - but I'd reckon 100Hz would probably work. It's the amount of energy transferred per pulse that varies the needle position - ie the width.

So I'd try dropping your frequency, by increasing the period value. For instance try a value of 19 and a duty range of 0 to 80.

There might be other factors though.


 

BeanieBots

Moderator
I agree fully with Jeremy.
Without doing the sums I'm sure you could find a period value that would give close to a range of 0-100 for the output. Final scaling could be done with a resistor/pot if you want/need to keep the code to 0-100.
What you might find, (I have found this on several meters) is that it is the METER that is not linear by as much as 10%.
This problem could be solved by using a lookup table.

pwmout 1,64 ,b0
can be used for b0=0 to 255 on all the meters I have.

Edited by - beaniebots on 26/07/2006 11:08:41
 

tim griff

Member
Dear all,

Full Marks! I've adjusted the period and I can now use a higher duty cycle, giving me greater resoloution. Thanks again.

PS I adjust for FSD using a pot with the highest duty set
 
Top