First PWM experience

Hi, everyone!This is my first time i am going to use a PWM to control a servo. I wanted to start from my Fez Raptot, but i don’t have a power module yet to power up the board, so i decided to try it on FEZ Cerbuino bee.
Help me to clarify the following questions please:

  1. which socket should i use on cerbuino bee?
  2. i am going to use a breakout tb10 module. Wich pin of the module should i use for connection with a servo signal wire?
  3. i am using a net gadgeteer project. Can you show me a code sample how to control a servo in my scenario (cerbuino bee->socket number->tb10 module->pin number-> gadgeteer project code sample)?

Thank you very much!

Grr, my reply was eaten by the gremlins !

Anyway, you can only use P sockets for PWM, which means on your device socket 1 or 3. https://www.ghielectronics.com/docs/305/gadgeteer-sockets-quick-reference has the definition of all the sockets, and from this you can see pins 7, 8, and 9 on a P socket are PWM capable.

You can use the individual pins in a socket in one of two ways - quick and dirty, or “like a tiger” I mean “like a driver”. If you do it like a driver does, you basically create a constructor that then allocates the pins you need within the Gadgeteer framework - if you find a driver that uses PWMOutputFactory class you’ll find an example how to do it “correctly”. I personally can’t think of a module using the P socket, can anyone? Anyway, you could use one of those to look at specifics how to implement that if you so choose, but I’ll show you the quick and dirty, grab a pin and go, way.

From the developers guide, note the PWM information https://www.ghielectronics.com/docs/46/fez-cerb-family-developers-guide .
Ordinarily the “finding IOs” would be a good reference https://www.ghielectronics.com/docs/6/locating-ios but that only deals with Cpu.Pin, not Cpu.PWMChannel.
Head over to https://www.ghielectronics.com/docs/144/plain-netmf-on-gadgeteer to be able to grab a code snippet that corresponds to the pin you chose. The below uses socket 1 pin 7; you could use socket 1 or 3, pins 7-9.



And you're done !

@ Brett -
Oo heaps of valuable links and information!!! Thank you for your time! I will learn it all and i am ready for a pwm fighting

@ Brett -
I won this fighting, thank you for the information you provided! It really helped me to achive the result. You was right about the Cpu.PWMChannel it didn’t work for me at all, instead i used a Cpu.Pin directly and i am done. :clap:

1 Like