In my RC car project, I require that the PWM signal be changed often, but I seem to be having an issue when I try to set PWM pulse waves in quick succession. If, for example, I try to set PWM 8 with
Then, any faster than 50ms later…
…The resulting pulse wave will fluctuate then settle on the new timing. This “flutter” causes my electric speed controller to freak out.
Basically, I need to be able to change the signal faster than 50ms, but it doesn’t look like I can reliably do that with this approach.
Yep, I probably should be using register access to do this. I’ll have to look in the manual.
As for cutting the pulse immediately, that’s exactly what I expected after seeing the scope trace. IMO, I should wait until the last pulse. Cutting a pulse midpoint like that can cause a screwup with whatever you are trying to control. In my case, the ESC will freak out.
We looked at in scope, the signal looks fine and changes correctly,
If you are able to find something or solve it using register access, please let us know.
If I am recalling correctly the update rate for one servo channel is supposed to be about 50ms (or maybe it was 20ms?). This resulted in a fixed number of channels that could be controlled with one transmitter. Could it be that you might be ‘force feeding’ the ESC and causing it to ‘burp’.
I’ll see if I can look up my notes on using hobby servos but it has been several years sense I messed with them. I think the last time I messed around with them I was trying to see if I could control multiple servos with one timer channel on a Cypress PSoC. I had a timer that fired an interrupt like every 0.1ms it would check to see what state the pulse should be in for each servo at that time and update the outputs. It worked very well as I recall and always gave you synchronized movements. That would be a cool experiment to do on a Cobra with PLD.
I looked at the signal under the scope and it looks very strange. Shall I provide you with demo code?
@ Jeff: Duty cycle = 50% = 20ms per PPM frame
@ kurtnelle: Basically, the wave looked like the high time got interrupted. It may have been going from 1.5ms high to 2.0ms high, but the wave might have been something like 900us! I’ll take a video of it or something.
Please set your scope to 10ms/div on a rising repeat trigger, then run the code below. If your scope can, place a ruler at +1.4ms past the trigger. You will be probing digital pin 8.
Nothing will happen for the first few seconds, but when the throttle up command is given, watch as the PWM signal wildly fluctuates. With that code sample, that signal should never go much below 1.4ms, but it does. In fact, it goes as low as 700us!
Yep, I’m still getting the issue even with the simplified code. Watch the scope trace as the signal gets cuts short, then returns to where it should be. http://files.chrisseto.com/wJ2
esc = new PWM((PWM.Pin)FEZ_Pin.PWM.Di8);
Register r = new Register(0xE0018024);
for (double set = 911; set <= 2000; set += 5)
{
// Set the pulse
//esc.SetPulse(20000000, (uint)(set * 1000));
r.Write((uint)(set * 18));
Thread.Sleep(40);
}