Very cool!
I don't want to hijack this thread, but it brings up a quick thought. We're looking to add some additional functionality in the next version of the PWM classes. On the table are a few ideas: assignment of the PWM channels to one of two clocks; setting individual clock frequencies; possible interrupt-based sine and triangle wave functions; possible software PWM on hardware pins. Would any of those be useful in your projects?
BTW, just curious: what was the difference you noted between our PWM implementation and the GHI one?
Chris
Chris,
It looks like the difference is that the FEZ PWM.SetPulse method uses nanoseconds as seen in the below code... or its 100% possible I am using the Netduino Setpulse method incorrectly as I am very new to microcontroller's. The Netduino is my first board. I really need to get my "Google" degree in a lot of this stuff. On that note, and after "Googleing" the changes you have on the table to the PWM classes, I think all those additions would be very useful.
using System; using System.Threading; using Microsoft.SPOT; using GHIElectronics.NETMF.Hardware; using GHIElectronics.NETMF.FEZ; class Program { public static void Main() { PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5); while (true) { // 0 degrees. 20ms period and 1.25ms high pulse servo.SetPulse(20 * 1000 * 1000, 1250 * 1000); Thread.Sleep(1000);//wait for a second // 90 degrees. 20ms period and 1.50ms high pulse servo.SetPulse(20 * 1000 * 1000, 1500 * 1000); Thread.Sleep(1000);//wait for a second // 180 degrees. 20ms period and 1.75ms high pulse servo.SetPulse(20 * 1000 * 1000, 1750 * 1000); Thread.Sleep(1000);//wait for a second } Thread.Sleep(-1); } }
Jason