Go Down

Topic: Decoding Radio Control signal pulses (Read 71407 times) previous topic - next topic

jds

It is correct that the Vex transmitter has 6 channels, but I read (after doing a Google search for this transmitter) that you can connect an extra transmitter and have 12 channels.

I don't know the details, but those that are interested can look it up.

mem

#31
Mar 24, 2009, 04:30 pm Last Edit: Mar 24, 2009, 04:31 pm by mem Reason: 1
Most transmitters start a channel on the rising edge, but You can easily change it by making a small mod to the library.

in ServoDecode.cpp, change:  
[font=Courier New]
 volatile byte pulseEnd = PULSE_START_ON_RISING_EDGE ; // default value[/font]
to[font=Courier New]
 volatile byte pulseEnd = PULSE_START_ON_FALLING_EDGE; // inverted pulses[/font]

ubuntucat

#32
Mar 24, 2009, 05:45 pm Last Edit: Mar 24, 2009, 05:49 pm by ubuntucat Reason: 1
I was thinking that  pulseEnd changed what defined the end of the pulse (when it stops counting).  I want it to start counting on the falling edge and stop counting at the leading edge.

When I try your suggestion mem it never synchs..  keeps repeating "the decoder is NOT_SYNCHED" Cx0= 0  and all the rest are 0

I'm assuming this is because the synch pulse is low and it is only reading the 0.5ms high pulses that never change.

Is there a way to make it start on a falling edge instead of rising edge?  This would also explain why my measurements seemed to be 0.5ms too long

mem

what values did you use for MIN_IN_PULSE_WIDTH and MAX_IN_PULSE_WIDTH

ubuntucat



gmv

Hi all, i´ve been out for a few days but last night i got the chance to connect the PWM data stream of my radio to the pin8 of my board, with Arduino monitor i could see the data on the screen but the "fail safe" message was always there, i even tested with my scope just to confirm and nothing at the outputs, i must check the values(TTL), i guess it may need to be rised a little bit,.....any ideias ?

p.s - i got the data stream from the radio output plug (after the TX module been removed) .

 thanks

mem

ubuntucat, sorry for the delayed reply, I have been busy and did not see your post.

I have no experience with the vex and it's difficult to help without having the actual hardware on the bench. Did you try and contact jamiechan?

mem

gmv, what transmitter are you using? Can you post a snippet of the data you get on the Arduino monitor? The voltage level of the pulses need more than 2.5 volts when high, ideally between 3 and 5 volts, what do you see on your scope?

jds

does it matter if his radio is in pcm or ppm mode?

mem

Yes, it must be in PPM mode for this library to decode the signal

gmv

Hi mem, i´ve changed my transmitter and now i got a good signal from the trainer port to pin8, now i can see the changes each time i move the channel switchs or the joysticks, but how can i drive the servos ?.....wich outputs should i use, ...the PWM ones i supose,....., could you please edit and post here the full sketch file in order for me to compare with mine ? ::)

thanks again and sorry to take your time

ubuntucat

Well I've got it working....  When I ran the example sketch for servoDecode it would frequently go into fail safe.  When I run my own sketch everything seems to be working fine.  It's being used to run 4 motor controllers and 3 servos using a servo controller.  Thanks for the help mem, and everyone else.

On a side note, which PWM pins will no longer work when using ServoDecode?

mem

ubuntucat, good to hear you have it working.

ServoDecode uses timer1, therefore analogWrite on pins 9 and 10 are not available.

I am surprised to hear that changing a sketch would make any difference to fail safe. I would want to modify the example if it could prevent anyone in future from having a similar problem, please tell me more about what you needed to change.

mem

#44
Mar 29, 2009, 06:08 pm Last Edit: Mar 29, 2009, 06:11 pm by mem Reason: 1
Quote
On a side note, which PWM pins will no longer work when using ServoDecode?

Servos don't operate with the pwm output from analogWrite, but you can use the ServoTimer2 library. This was developed specifically for use with ServoDecode.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230479947/0

Here is a simple test sketch:
Code: [Select]

// ServoDecodeTest
#include <ServoTimer2.h>
#include <ServoDecode.h>

// define the servo pins
#define servoApin  2   // the pin the servo is attached to/
ServoTimer2 servoA;    // declare variables for the servos

char * stateStrings[] = {
 "NOT_SYNCHED", "ACQUIRING", "READY", "in Failsafe"};


void setup()                    // run once, when the sketch starts
{
 Serial.begin(38400);  
 servoA.attach(servoApin);
 ServoDecode.begin();
 ServoDecode.setFailsafe(3,1234); // set channel 3 failsafe pulse  width
}


void loop()                     // run over and over again
{
 int count=0;
 int pulsewidth;

 // print the decoder state
 if( ServoDecode.getState()!= READY_state) {
   Serial.print("The decoder is ");
   Serial.println(stateStrings[ServoDecode.getState()]);
   for ( int i =0; i <=MAX_CHANNELS; i++ ){ // print the status of the first four channels
     Serial.print("Cx");
     Serial.print(i);
     Serial.print("= ");
     pulsewidth = ServoDecode.GetChannelPulseWidth(i);
     Serial.print(pulsewidth);
     Serial.print("  ");
   }
   Serial.println("");
 }
 else {  
   if( count % 20 == 0){   // decoder is ready, print the channel pulse widths every second
     for ( int i =1; i <=MAX_CHANNELS; i++ ){ // print the status of the first four channels
       Serial.print("Ch");
       Serial.print(i);
       Serial.print("= ");
       pulsewidth = ServoDecode.GetChannelPulseWidth(i);
       Serial.print(pulsewidth);
       Serial.print("  ");
     }
     Serial.println("");
   }
   count++;
 }
 servoA.write(ServoDecode.GetChannelPulseWidth(3));
 delay(20); // update 50 times a second        

}

Go Up