Hey guys,
writing c code for pwm controlling 4 servo's and as far as I can tell, the dirty method seems infinitely easier than using the proper pwm method (which I have yet to get my head around).
What is the point in using pwm mode rather than simply doing the work in code?
Hardware PWM lets the processor spend it's time doing other things. Software PWM eats up processor power and is more sensitive to the processor load since it is a time dependent task running alongside other tasks. If the PWM hardware module allows you to have time pulses long enough for operation with RC servos then it is best to do that.
There's the rub, most microcrontrollers don't run the PWM slow enough for effective servo control. Also most have only one or two actual PWM controllers.
It's easy enough in software, using interrupts is the way to go.
The usual refresh rate for model servos is 50Hz. Analog servos will operate OK to about 100 to 120 Hz, which gets you to the lower limit of PIC hardware PWM, but the resolution might not be what you need. I had read somewhere that digital servos can go even higher. I can'f find that source, but if you search on "digital servo refresh rate" you will find lots of comments that they will tolerate 300Hz. Here is one thread: http://www.multiwii.com/forum/viewtopic.php?f=8&t=1644
Of course, one can also find out how to make cars run on water on the Internet too. So, I can't vouch for the reliability of that number. It should be easy enough to test with a digital servo. They are quite cheap now, and the ones with 8 µS deadband (standard) should be more than adequate for that purpose.
John
Edit: I forgot to say that I agree with Bill about using software. The above was written from the standpoint of someone who wanted to use hardware or in a situation, such as a latch, where hardware might be simpler.
Thanks for your reply's. My initial though was also that hardware pwm didn't seem very practical as it would require constant changing of multiple registers and calculations. I think i'll go ahead with the software approach as I've already got some experience with this anyway.
It's called "bit banging" implying that you bang the bit either 0 or 1 and that does all the work.
But with software PWM then the software is loaded down unless of course you're not doing anything else anyway.
One of the moon missions almost didnt make it back because of software overloading...not enough time to perform all the required tasks. If you have the time however then there's no problem. So it's really a matter of if you have the time in clock cycles or not. If you really didnt have the time you'd before forced to use the on board hardware.
I hope this isn't a hyjack, although it may be, does any one know of a radio control type PWM chip for decoding the 1 - 2ms pulse? other than the NJM2611 by JRC,(analog) or the Renesas M64611FP (digital) which Renesas says is not available any more. I'd like to find a source for digital decoder if possible.
Thanks
Kinarfi