Go Down

Topic: Remote Control Transmitter Trainer Port PPM Signal (Read 1 time) previous topic - next topic

ilovetoflyfpv

Hi Guys

I am wanting to use an Arduino Uno to generate a Pulse Position Modulation (PPM) signal that I can send through the trainer port on my remote control transmitter. I need to generate a 'frame' which consists of a series of pulses (one for each channel) followed by a synchronisation pulse. From what I've read this frame differs depending on the transmitter. I have found the following image for the HK-T6A V2;

http://img401.imageshack.us/img401/8622/pinningvk8.jpg

I have written the following sketch to test the above but it doesn't appear to be working;

Code: [Select]
int startFrame = 0;

void setup(){
  pinMode(13, OUTPUT); 
}

void loop(){
  startFrame = micros();
  for (int x = 0; x < 1; x++){
    digitalWrite(13, LOW);
    delayMicroseconds(400);
    digitalWrite(13, HIGH);
    delayMicroseconds(600);
  }
 
    digitalWrite(13, LOW);
    delayMicroseconds(400);
    digitalWrite(13, HIGH);
    delayMicroseconds(1600);
   
  for (int x = 0; x < 2; x++){
    digitalWrite(13, LOW);
    delayMicroseconds(400);
    digitalWrite(13, HIGH);
    delayMicroseconds(600);
  } 
   
  while (micros() - startFrame < 20000){
    delay(1000);
  }
}


Any suggestions would be greatly appreciated.

Kind Regards

Jason

DuaneB

What do you want to use the PPM Stream for ?

I might have something that will help

Duane B

rcarduino.blogspot.com
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

AWOL

#2
Nov 30, 2012, 02:27 pm Last Edit: Nov 30, 2012, 02:32 pm by AWOL Reason: 1
Quote
while (micros() - startFrame < 20000){
   delay(1000);

"micros" is a time in microseconds, "delay" is a delay in milliseconds.
Waiting a second for a 20 millisecond frame timeout isn't sensible.
"delayMicroseconds" is what you want, I suspect.

Edit: You don't want a delay at all, you just need to idle until your frame time is up.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

ilovetoflyfpv

#3
Dec 01, 2012, 12:19 am Last Edit: Dec 01, 2012, 12:31 am by ilovetoflyfpv Reason: 1
Hi Guys

Thanks for the replies.

@DuaneB: I would like to integrate a joystick with my remote control transmitter using just two channels via the trainer port.

@AWOL: I have made the changes you have suggested (see below). I have also added a synchronisation pulse. Still not working.  :smiley-roll:

Cheers

Jase

Code: [Select]
//PPM Signal Test 1

int startFrame = 0;

void setup(){
 pinMode(13, OUTPUT);  
}

void loop(){
 
 startFrame = micros();
 
 //Channels 1 & 2
 for (int x = 0; x < 1; x++){
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(600);
 }
 
   //Channel 3 (Should run motor at full speed)
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(1600);
   
 //Channels 4, 5 & 6
 for (int x = 0; x < 2; x++){
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(600);
 }

 //Sync pulse
 digitalWrite(13, LOW);
 delayMicroseconds(400);
 digitalWrite(13, HIGH);  
   
 //Wait until frame of 20000 microseconds has passed
 while (micros() - startFrame < 20000){
   delayMicroseconds(1000);
 }
}




AWOL

#4
Dec 01, 2012, 12:28 am Last Edit: Dec 01, 2012, 12:33 am by AWOL Reason: 1
Quote
Still not working.

I wonder what that means.

Code: [Select]
//Channels 1 & 2
  for (int x = 0; x < 1

Comment and code should match.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

DuaneB

Hi,
  If I understand correctly, you want to add an external joystick which will be connected to Arduino, the Arduino will then generate a PPM Stream which will be fed into your existing transmitter ?

  How many channels is the transmitter, it probably expects a full set of channels coming in and will reject any pulse trains that do not include a full set.

  As for generating the PPM, I would use interrupts, the clock signal from this project is very close to a PPM Stream, if I find some time later today I will modify the code slightly to generate a full PPM Signal.

http://rcarduino.blogspot.com/2012/08/arduino-serial-servos.html

Duane B
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

ilovetoflyfpv

Hi AWOL

Thanks for getting back to me so quickly. The sketch I'm using should run the motor at full speed. Unfortunately it doesn't run at all.  :(

I have made the changes to the 'for' loops as suggested (must have been up too late).

Cheers

Jason

Code: [Select]
//PPM Signal Test 1

int startFrame = 0;

void setup(){
 pinMode(13, OUTPUT);  
}

void loop(){
 
 startFrame = micros();
 
 //Channels 1 & 2
 for (int x = 0; x < 2; x++){
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(600);
 }
 
   //Channel 3 (Should run motor at full speed)
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(1600);
   
 //Channels 4, 5 & 6
 for (int x = 0; x < 3; x++){
   digitalWrite(13, LOW);
   delayMicroseconds(400);
   digitalWrite(13, HIGH);
   delayMicroseconds(600);
 }

 //Sync pulse
 digitalWrite(13, LOW);
 delayMicroseconds(400);
 digitalWrite(13, HIGH);  
   
 //Wait until frame of 20000 microseconds has passed
 while (micros() - startFrame < 20000){
 }
}

ilovetoflyfpv

Hi DuaneB

Quote
If I understand correctly, you want to add an external joystick which will be connected to Arduino, the Arduino will then generate a PPM Stream which will be fed into your existing transmitter?


Correct. :)

The sketch I have written 'should' be generating a full six channels (see link below).

http://img401.imageshack.us/img401/8622/pinningvk8.jpg

Am I correct in thinking that on inexpensive remote control transmitters when the master selects slave then all channels are accepted from the slave. In contrast on better remote control transmitters you can elect what channels to accept from the slave?

Cheers

Jase

DuaneB

Hi,
   If you PM Me your email address I will send you a variation of the Serial Servo library which outputs a pure PPM signal -  I don't have anything to test it on at the moment.

Duane B

rcarduino.blogspot.com
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Go Up