Go Down

Topic: CPPM Library for Arduino (Read 394 times) previous topic - next topic

I have written a library for Arduino to interface the CPPM signal of a RC receiver. With it, I can control a small motorized engine with a RC transmitter.

My engine is driven by 2 small dc wheels/motors. Left and right wheels/motors are controlled by PWM pin 5 and 6. The ELEV stick controls the speed and sens of deplacement. The RUDD stick controls the left and right turn and rotation.

The library is documented and explained here: CPPM Library for Arduino



I Try your code, and it's dosen't work!!!!

Code: [Select]
#include "CPPM.h"

// your code...

void setup(void)

void loop(void)
  if (CPPM.synchronized())
    int throttle = CPPM.read(CPPM.THRO);
    digitalWrite(11, !digitalRead(11));    //LED

I see nothing in monitoring

Code: [Select]
#include "CPPM.h"
I do this because i put .cpp and .h in the same directory

I change in .h the pin interrupt like this because i use an AtMega32u4: INT0 is on pin 5
Code: [Select]
#define CPPM_ICP1 5

I use an Teensy v2:
My board : https://www.pjrc.com/store/teensy.html
Doc : http://www.atmel.com/images/doc7766.pdf

And my RC is : FRSKY D4RII (It's working on my Naze32 ! )

Thx for help ;)

Hi Jimbow,

I've watched the specifications of the receiver FRSKY D4RII.
It differs from Orange R615X in 2 points:

1/ The synchronization is based on falling edge.
2/ The frame rate is 18ms. So the max number of servos is restricted to 1st 6 of 8 channels (as explained in last red note of manual).

It's why my CPPM library can't synchronize with FRSKY at moment.
I must write some modifications to my library.

At moment, I doesn't own a FrSky equipment, only Orange receivers and Spektrum transmitters.
If somebody based in Switerland can lend me a FrSky D4RII and a transmitter, I could update my library.

You can also try another library, for example: https://github.com/claymation/CPPM



I've read your code ^^ and now it 's working!

In first i have do a mistake, interrupt pin (AtMega32u4) for timer 1 is not in pin 5 but in pin 22 ^^

In Seconde, i see in your code :
Line 99
Code: [Select]
if (CPPM.sync3 < (610 - 16) || CPPM.sync3 > (643 + 16))

I think it's with pulse for a Spektrum (300us) but for FRSKY D4RII it's 400us !

I modified a little your code and i have add in CPPM.h:

Code: [Select]
#ifndef FRSKY_D4RII
#define WITH_SYNC_PULSE 800 //400us for 0.5us tick timer (16MHz/2)
#define MAX_GAP_PULSE 5088 // 2544 us 
#define WITH_SYNC_PULSE 300 //300us
#define MAX_GAP_PULSE 5088 // 2544us for 0.5us tick timer (16MHz/2)

I have modified the line 99:
Code: [Select]
if (CPPM.sync3 < WITH_SYNC_PULSE - 30 || CPPM.sync3 > WITH_SYNC_PULSE + 30)

And the line 113:
Code: [Select]
if(CPPM.sync2 > MAX_GAP_PULSE) // gap pulse ?

I live in france in Haute Savoie not far from Annemasse, i think you are from geneva ^^

Thank you Jimbow for your help.
I will study the AtMega32u4 that I don't know currently.
And integrate your corrections.
And the write() function to generate a CPPM Stream (Arduino pin 9).
I have also written a ATtiny85 CPPM decoder for 4 servos.

note: I live in Neuch√Ętel. Annecy is not so far.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131