PWM below 4Khz

Staffscrocs

New Member
I have been reading old posts from ANJ and Hippy about altering a TRMS prescale register to get lower PWN frequencies.
I have got together a working set up for controlling a power feed on a workshop item using info from several contibutors to this forum and this lower frequency thing would just about make it perfect.
Could someone please tell me what the address/name of the register that I need to poke to get a lower frequency of PWM?
I understand that I would need to set a PWMOUT then poke the register to get the result and that I would need to poke again after any new PWM command later in the program to maintain the low register.
Thanks in advance.
Staffchina
 

xstamp

Senior Member
I would also like to know how to generate lower PWM output rates. The plan is to link the PWM output back to a picaxe input to use as a free-running ADC scan clock. That way I could have selectable scan rates that do not depend upon potentially variable software loops.

 

hippy

Ex-Staff (retired)
I don't recall any particular discussion on this, but I did find this previous post ...

http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=2955

Often the easiest thing to do in such circumstances is to try it and see. The PICmicro datasheets show diagrams of the PWM controller and give an explanation on how it works. Then it's a question of working out which registers need to be poked to achieve what's needed, looking up the address of where those registers are, use POKE to set the required values and keep your fingers crossed it doesn't interfere with other PICAXE operations, hoping that the PICAXE formware doesn't update the registers itself and undo what you are trying to achieve.
 

hippy

Ex-Staff (retired)
Noting that the intended use is; "controlling a power feed on a workshop item", you need to consider what the situation is should any PWM setting get altered by the PICAXE Firmware, because there's no guarantee it won't, even if it looks like it doesn't, and likewise if any glitch causes the PICAXE to misbehave. The usual Safety Critical issues apply.
 

Staffscrocs

New Member
Thanks Hippy,
I had not found that post. I have tried Mr Anderson's code and it does work. However it does seem a little fragile and can alter itself back again without warning. No big safety issues but I would prefer reliable, everyday type working! I shall keep playing but may well use a logic pulse divider on the output and move everything on the pic to a higher frequency that it likes.
Regards,
Les
 

andrewpro

New Member
A divider would pretty much negate the PWM aspect of the PWM. You would only get pulses on the other side the same period of the PWM, both on and off.

--Andy P
 
Top