Main Site Documentation

GPIO Usage (Extra PWM channels?)


#1

Greetings.

I am very, very new to this kind of thing. I am in need of controlling 5 servo’s (on different channels). I understand I need to use PWM to control these servos, and you typically do that on a “P” socket I have both a fez hydra & a fez spider. I see the spider has two “P” sockets while the hydra only has one. The P socket pin layout describes it as having 3 pwm channels and 2 GPIO (General purpose input/output)

I would really like to use the hydra for this specific project as it can use as much processing power as it can. Can I re-task the GPIO pins to emulate a PWM channel? or are there any other possibilities to extend my PWM channels?

Thanks for any insight!


#2

Each P socket has 3 PWMs. So, using an Extender module you can use all three separately for each of your Servos. If you need additional you can use OutputCompare() to create a PWM signal from a digital (X or Y socket) pin. Check out OutputCompare in the tutorials. If you really must have all hardware PWM then there are chips that you can add on to provide those. However, that’s probably beyond where you’re at at this point is sounds.

Welcome to the community!


#3

@ BoogieMan

You should be able to generate the necessary PWM signal using OutputCompare. Keep in mind, however, that you’ll be using up CPU resources to do so, which may impact performance:

Here’s some info on the TinyCLR wiki on OutputCompare:

http://wiki.tinyclr.com/index.php?title=Output_Compare
http://wiki.tinyclr.com/index.php?title=PWM_UsingOutputCompare

The tutorial info is not Gadgeteer-specific, but you may be able to gather enough from it to use OC to generate PWM on a non-P socket.

This blog post shows how to do both hardware-based and software-based (using OC) PWM, albeit again for a non-Gadgeteer FEZ board.

Last, but not least, while it doesn’t address directly the particular issue you’re asking about, you may want to keep this handy:

http://www.ghielectronics.com/downloads/Gadgeteer/.NET%20Gadgeteer%20Ultimate%20Guide.pdf

It’s a preview e-book written by Gus that has a lot of good background info on Gadgeteer, and GHI’s offerings, and is a must-read for anyone getting started with .NET Gadgeteer, IMO.

Welcome to the community!