I've gotten a rudimentary version of my frequency sweep program working, I just have a question about the language. Specifically, why do I need to specify a duty cycle each time I change the frequency? Here's the code that works:
public static void Main() { PWM FreqOut = new PWM(PWMChannels.PWM_PIN_D10, 1000, .5, false); int[] Frequencies = new int[10] { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; while (true) { for (int i = 0; i < 10; i++) { FreqOut.Stop(); FreqOut.Frequency = Frequencies[i]; FreqOut.DutyCycle = 0.5; FreqOut.Start(); Debug.Print(Frequencies[i].ToString()); Thread.Sleep(4000); } } }
But if I comment out line 25, then it gives me a flat signal until the frequency switches to 1000Hz, then pumps out the square wave as expected.