Hardware PWM for servos, motors, and LEDs


30 posts   Page 2 of 2   1, 2
by ScienceTeacher » Fri Jan 25, 2013 9:14 pm
One problem could be the difference of base frequency used by servos. Some cheap servos use a frequency around 3-500 Hz, and some (Futaba/Robbe) uses (accepts) a frequency between 30 and 60 Hz, and a pulse width between 920-2120 uS.
Another problem could be the mode selected. It should be the mode that sends a high that is kept high for the wanted duration, opposed to the mode that tries to equally spread short, alternating highs and lows in a pattern that reflects the wanted duty cycle.
Posts: 2
Joined: Tue Apr 17, 2012 3:07 pm
by sarfata » Fri Feb 08, 2013 7:32 pm
Hi,

I have looked at Richard Hirst code and also wanted to use it for arbitrary PWM. I have just published the results on github under the GPL (like Richard's original code).

The code is here:
https://github.com/sarfata/pi-blaster

And you can use it (for example) to drive high power led:
http://www.tbideas.com/blog/2013/02/con ... pberry-pi/

Hope this helps!

cheers,
thomas
Posts: 4
Joined: Thu Feb 07, 2013 6:10 pm
by dx21 » Tue Mar 26, 2013 6:14 pm
Hello Joan, I'm back.

I've just tested your V2 code in my project, an it"s working flawlessly :)
I don't know exactly why it's working, and why the V1 won't, but thank you for your work! It's just awesome :)
Posts: 9
Joined: Sun Nov 18, 2012 9:17 pm
by joan » Tue Mar 26, 2013 9:28 pm
dx21 wrote:Hello Joan, I'm back.

I've just tested your V2 code in my project, an it"s working flawlessly :)
I don't know exactly why it's working, and why the V1 won't, but thank you for your work! It's just awesome :)

The Arm cache.

The software writes a value to "memory". The CPU reads the value and stores it in its cache. It doesn't need to be written to physical memory until something reads that value. It doesn't know that the DMA hardware is reading the memory location so doesn't update physical memory until the cache is needed to store other memory locations.

Any userland (or kernel) program which uses DMA will have the same problem. I introduced a special cache "flushing" algorithm.
User avatar
Posts: 6579
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK
by peepo » Thu Aug 08, 2013 9:38 am
Joan,

great video, what servos & pan/tilt mechanism did you use?
User avatar
Posts: 268
Joined: Sun Oct 21, 2012 9:36 am