Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Richard

Member Since 04 Oct 2010
Offline Last Active Jul 13 2014 06:43 AM
-----

Topics I've Started

Driving more RC servos than you have PWM outputs

12 October 2010 - 11:57 AM

Hi all, I am new to the Netduino way but a very experienced programmer at all levels. While I originally bought the device for remote sensing, I find myself doing what everyone seems to do at some point, playing with robotics :-) Anyway, I am looking for ways to drive at many servos as I have GPIO ports. As far as I can tell, we are limited to only 4 ports that support PWM on the standard board. It occurs to me, however, that I may be able to get around this by creating a 100kHz timer interrupt (to get 10uS resolution) and a lookup table to brute force the signal generation. As far as I can see, this will not be possible in C# since the interrupt servicing in the CLR is too slow and timer resolution is far too poor. I am thinking the only approach will be some sort of C/ASM driver with a few friendly C# classes for servo control. Is this overkill? Assuming that I can come up with an efficient way of modulating the GPIOs in my interrupt handler, do you think that the CPU will have enough grunt left over for control loops and other work? As far as I can tell, all I have to do is keep a an array of desired pulse widths (between 125 and 175 for a 10uS clock). At the beginning of every 25ms cycle (assuming 400Hz update) a counter is zeroed and all GPIOs are sent high. Each interrupt, the counter is incremented and compared with each of the individual pulse widths. When the counter exceeds the pulse width for a given servo, the GPIO is driven low. When all ports are low, the interrupt could be disabled for 2.5ms (to reduce CPU load) before starting the cycle again. So, am I on the right track or is there a better way to do this? Am I fooling myself that the Netduino can handle this as well as doing real work in the foreground? Would I be better off firing up the old AVR development board and knocking up a dedicated AVR chip that takes the traditional 3 byte commands across SPI and is otherwise dedicated to the control loop? Thanks in advance people, I look forward to comments and/or critisisms :-) Richard.

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.