Whenever a channel reads as not 0 it has a valid value -
uint16_t unThrottleIn = CRCArduinoPPMChannels::getChannel(SERVO_THROTTLE);
// Test if its something other than zero, if so its valid and we can use it
if(unThrottleIn)
{
CRCArduinoFastServos::writeMicroseconds(SERVO_THROTTLE,unThrottleIn);
// Add a serial print here
Serial.println(unThrottleIn);
}
As for the other defines, leave them as they are -
// two ticks per us, 3000 us * 2 ticks = 6000 minimum frame space #define MINIMUM_FRAME_SPACE 6000 #define MAXIMUM_PULSE_SPACE 5000
I notice you have
#define MINIMUM_FRAME_SPACE 16000
It should be
#define MINIMUM_FRAME_SPACE 16000
As per the original code.
The background is Timer1 is running at 2 ticks per microsecond, with 8 channels you have
8*2,000us = 16,000us
16,000 us in timer ticks = 32,000
Then we have a total frame size of 1/50 = 20,000 us or 40,000 ticks
40,000 ticks - 32,000 signal space = 8,000 frame space
so for 8 channels we expect around 8,000 ticks of frame space, the default setting is 6,000 so we are good for 8 channels or less with the default setting.
Hi,
I can't see any software reason for jerky servos, can you confirm that the servo is attached to the same pin that you are printing the channel input for ? and that the channel input is steady ?
I have to turn in for the evening now, tomorrow I will add additional comments to the example code to show how and where to add additional servos. Its been good to work through it with someone, it really does need better documentation which I will put together over the weekend.
Hi,
I have a variation of the Serial Servos code in the link below which outputs PPM
The clock signal that gets sent to the 4017 counter is very similar to PPM so it was a trivial conversion to output PPM instead - I should consolidate the code into a single library with the option of PPM out or serial output to a counter but thats a job for another day.
I have not tested the PPM output modification in anger, but have sent it to a few people that have asked for it.
People always come back if something has a problem, on the basis that no one has got back I have to assume that it works perfectly.
I will send you the library, at some point in the next day or two.
Got it all working now. I had 10 servo outputs but they all seemed like they had steps when you slowly swept across the full throw of the Tx stick. I went down to 9 and it is far smoother now.
I finally managed to replicate my bug and record it as well.
I can make the following occur by using any channel.
If left at neutral there is no twitching, slight jitter but that can be put down to other causes.
Note the single line of epic fail.
I was inputting a small amount of throttle then everything violently twitched.
I tried commenting out all of my code until all I was left with was the ppmin and servo out so I assed something up along the way.
When I did the testing the other day I was using 2 9g servos, in the test bed used here is 1 full sized sevro and an esc.
I'm going to double check my .h file settings and will post back if I discover anything I missed.
Update: nothing in the h files looks out of the wrong.
And if left along long enough it does twitch equally as violently as when controls are being inputted, abet not as frequently.
The one hint I can see is that with the printout I post above the last 2 channel have no glitching, those to channels are hard coded to put out 1000 were as the rest are read from ppm. So I suspect it is somewhere in the ppm in that things are going astray.
I shall now take the absoltue minimum code needed to move servos and see if that works in this platform.
Update 2: Pulled a new set of .cpp .h and the demo sketch from your website, the only change I made was channel input number to 8 as that is what my setup is spiting out.
Exact same result, if I wiggle the steering quickly the throttle bounces all over the place.
Any idea as to what it could be? (to be honest it is probably me doing something wrong)
I have been over on the multiwii forums and one of the guys has made a ppm in servo out lump of code from multiwii. As a test of the hardware I'll set that up and see of the results are the same. I am hopping to use your code though as it is far more flexible and easier to work with.