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

I was really keen to try it out so quickly copied all the files from your blog and chucked them in the appropriate locations. The example code complies fine but when I copy the ppm input demo code from your blog I get the following error "multiple definition of `__vector_1'". I saw there are some comments on the blog that pertain to a similar error but didn't really have a resolved answer.
How do you increase the number of ouput serovs as well??
Sorry I may bombard you with a torrent of questions as I figure this out.
Hadley

Hi,

change this in the cpp file

void CRCArduinoPPMChannels::begin()
{
 m_sOutOfSynchErrorCounter = 0;
 attachInterrupt(0,CRCArduinoPPMChannels::INT0ISR,RISING);
}

to this

void CRCArduinoPPMChannels::begin()
{
 m_sOutOfSynchErrorCounter = 0;
 /* We dont need this if using the sample sketch
 attachInterrupt(0,CRCArduinoPPMChannels::INT0ISR,RISING);
 */
}

That should do it.

I will dig out the PPM Output for you as well, probably tomorrow, remind me if I don't

Duane B

Sorry, needs another line to enable interrupts, will advise in a few minutes.

Duane B

Add this to the setup function in the main sketch, I will update the original link with these two changes -

// enable the external interrupt
EIMSK = 1;  //1 - enable external interrupt 1
EICRA = 3; //3 - enable interrupt on rising edge only

Any problems let me know

Duane B

Ok have done the above mods and I still run into the vector 1 error.
Just to make sure - I am talking about using the sketch found at the bottom of this page

In work at the moment, so can't help but try this -

Use the original cpp and h files without modification, but remove this from the test sketch -

ISR(INT0_vect) {
 CRCArduinoPPMChannels::INT0ISR();
}

Hi,

Your not the only person to have had trouble combining the code from the two posts on this basis I will remove the code from both posts and reference them both to a new post, it will make it easier for everyone and easier for me to manage.

Duane

Hi,

Your not the only person to have had trouble combining the code from the two posts on this basis I will remove the code from both posts and reference them both to a new post, it will make it easier for everyone and easier for me to manage.

Duane

Got it kind of working but the servo output was very jerky.
I'll wait until you've made up a new post and try again

Hi,

How many channels are you reading and how many are you outputting ?

Did you change these defines to match ?

#define RC_CHANNEL_OUT_COUNT 4

#define RC_CHANNEL_IN_COUNT 3

3 and 4 are correct for my test setup, you most likely have a different number of channels coming in and will need to update the 3 to whatever it is that you have - leave the 4 for now we will come back to it.

Duane B

rcarduino.blogspot.com

Reading 8 channels outputting at least 8 as well.

Will update that and get back to you with results.

Edit: 1 bit of clarification. I have changed that lump of code to this

#define RC_CHANNEL_IN_COUNT 8
// two ticks per us, 3000 us * 2 ticks = 6000 minimum frame space
#define MINIMUM_FRAME_SPACE 16000
#define MAXIMUM_PULSE_SPACE 5000

Does MAXIMUM_PULSE_SPACE need to be changed as well?
I'm going to guess ether 1500 or 1066?? if it does need changed.

I need to create a FAQ or something similar for using the library, the interface is not the nicest - I did consider auto detection of the number of channels, its easily done but slows the ISR down slightly if the number of channels is not set at compile time.

Anyway just set the number of input channels to 8 for now, and once thats working nicely we will adjust the output channels.

Duane B.

Seeing as your online now I'll grab my arduino and see if I cant get it sorted

And a FAQ would be great help. This is the only code I've come across to deal with both ppm in and servo out and would be a benefit to many people I imagine

Internally its nice code, it just has a bit of an awkward interface to get started. Let me know how you get on

Duane.

Also where in the code can I chuck a set of serial.prints so I can confirm the inputs are correct, its very much hot and miss with just a servo plugged in atm? In uS would be good.

I also edited a post on the previous page, I think you may have missed it.

"Edit: 1 bit of clarification. I have changed that lump of code to this

#define RC_CHANNEL_IN_COUNT 8
// two ticks per us, 3000 us * 2 ticks = 6000 minimum frame space
#define MINIMUM_FRAME_SPACE 16000
#define MAXIMUM_PULSE_SPACE 5000

Does MAXIMUM_PULSE_SPACE need to be changed as well?
"

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