ppm (sum) in to servo output, possible timer issue

Hi,

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);
  }

Duane B

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.

Duane

I notice you have

#define MINIMUM_FRAME_SPACE 16000

It should be

#define MINIMUM_FRAME_SPACE 16000

LOL, I must be blind, I don't see the difference?

Lefty

Ok ppm input is looking good now, servo output still very jerky. getting there though

Ok, for the servos are you using the test sketch in its original form or have you made any changes to the sketch of library so far ?

We will need to make some changes for the number of servos, but if possible lets start with the original

Duane

Just the updated sketch from your website and unmodified library files except the RC_CHANNEL_IN_COUNT

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 ?

If so, how are you powering the servo ?

Duane B

that was my bad, I had changed #define RC_CHANNEL_OUT_COUNT and hadn't set it back to 4.
It is working now. Last thing, add more servo outputs..

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.

Duane B

rcarduino.blogspot.com

I know that felling and thankyou for your help.
I'll keep on playing around with the code and keep an eye out for your updated sample code.

It might not be the most useful FAQ just yet, but its a start

Let me know if it helps or which bits could be clearer

Duane B

FAQ looks good, thankyou.
I am just in the middle of adding my servos and should be testing oit soon.

You mentioned ppm out as well. That could be very useful for one project I have in mind, mainly to reduce wire clutter.

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.

Duane B

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.

Thankyou for sharing your code to BTW

Hi,
With 10 servos you don't need a framespace, try it again without setting a framespace and I wil update the FAQ with this later today.

To try it, set RC_CHANNEL_OUT_COUNT to 10

Attach your servos from 0 to 9

Dont use setFramespace

Then just work away on your 10 servos.

You could actually drive 20 servos, the library is able to drive a second bank of upto ten if you define MORE_SERVOS_PLEASE

Thats probably something else that should go in the FAQ.

Duane.

Will do, I had fame space set to 0 but will remove it completely and try again

Did what you suggested and it is all working great now. What to use all the spare servos channels for now :stuck_out_tongue:

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.

1590 throttle 1498 alerion 1528 rudder 1558 elevator 1247 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1562 elevator 1246 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1563 elevator 1247 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1591 throttle 1498 alerion 1524 rudder 1562 elevator 1247 flight mode 991 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
382 throttle 1386 alerion 1499 rudder 1525 elevator 1562 flight mode 1247 flaps 990 failsafe 1503 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1562 elevator 1247 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1564 elevator 1246 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1563 elevator 1247 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare
1590 throttle 1498 alerion 1524 rudder 1563 elevator 1246 flight mode 990 flaps 1503 failsafe 1502 pan 1000 buzzer 1000 spare

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.

Code is available here if you need to look at it.
https://dl.dropbox.com/u/11371953/DIY_RTH_10.rar

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.