Futaba receiver & remote to control motor..help

Hello,

I am very new in Arduino. I am trying to use the futaba receiver and remote to control speed and direction of a motor. the problem is I have no idea how to do the coding. Also, I do not know what exactly are the characteristics of the PWM signal that i am supposed to be inputing from receiver to arduino. Right now i have a 3 volt signal that changes by 2 milliseconds when i work the joystick control.

Please help.

The radio receiver servo outputs can be more properly called PPM signals (pulse position modulation). The standard pulse range is 1 to 2 millisec high repeated nominally every 20-25 millisec.

One method of utilizing this signal in an Arduino is to wire the signal to a digital input pin (also run a ground wire from the servo output ground pin to the arduino ground pin if the receiver and Arduino are being powered from different power sources) and use the the pulseIn function to measure the pulse duration. You will then have a variable that represents the value for one channel from the radio channel. Wire as many receiver channels to the Arduino that you require.

http://arduino.cc/en/Reference/PulseIn

Lefty

thank you sir. I will try this. How can i use the pulse duration/variable to control direction and speed of a motor? I am sorry...this arduino stuff is really new to me. Your help will be greatly appreciated.

man

I am not a fan of pulsein for RC input. It eats up too much time.

It might be worth using to move on to other areas of your code, but I think that in the long run you will want to use interrupts.

Here is some code that should show what I am talking about. I hacked this out of a sketch I use that morphed into a different direction. So this is old code that might not fit together. I do not have a board with me to try it. Oh, I should also give fair warning that I am not a super-experienced Arduino programmer. I am perfectly willing to accept that I have grave errors in my methodologies. But at least at one point, I did have the inputs from multiple channels from a receiver available to me inside my sketch. (And my hexapod DOES walk!) :slight_smile:

int Chan1Interrupt = 5; // pin 18
int Chan2Interrupt = 4; // pin 19
int Chan3Interrupt = 3; // pin 20
int Chan4Interrupt = 2; // pin 21
int Chan5Interrupt = 1; // pin 3
unsigned long Chan1_startPulse, Chan2_startPulse, Chan3_startPulse, Chan4_startPulse, Chan5_startPulse;
volatile double Chan1_val, Chan2_val, Chan3_val, Chan4_val, Chan5_val;
volatile double Chan1_val_last, Chan2_val_last, Chan3_val_last, Chan4_val_last, Chan5_val_last;

void setup()
{
  attachInterrupt(Chan1Interrupt, Chan1_begin, RISING);
  attachInterrupt(Chan2Interrupt, Chan2_begin, RISING);
  attachInterrupt(Chan3Interrupt, Chan3_begin, RISING);
  attachInterrupt(Chan4Interrupt, Chan4_begin, RISING);
  attachInterrupt(Chan5Interrupt, Chan5_begin, RISING);
}

void loop()
{ 
  
  //Chan1_val has the value for channel 1 from your receiver.
  //same for Chan2_val, Chan3_val, Chan4_val and Chan5_val
  
}

void Chan1_begin()           // enter Chan1_begin when interrupt pin goes HIGH.
        {
          Chan1_startPulse = micros();     // record microseconds() value as Chan1_startPulse
          detachInterrupt(Chan1Interrupt);  // after recording the value, detach the interrupt from Chan1_begin
          attachInterrupt(Chan1Interrupt, Chan1_end, FALLING); // re-attach the interrupt as Chan1_end, so we can record the value when it goes low
        }

void Chan1_end() 
        {
         Chan1_val = micros() - Chan1_startPulse;  // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue. 
         detachInterrupt(Chan1Interrupt);  // detach and get ready to go HIGH again
         attachInterrupt(Chan1Interrupt, Chan1_begin, RISING);
         if (Chan1_val < 1000 || Chan1_val > 2000) { Chan1_val = Chan1_val_last;}
         else {Chan1_val_last = Chan1_val;}
        }

void Chan2_begin()           // enter Chan2_begin when interrupt pin goes HIGH.
        {
          Chan2_startPulse = micros();     // record microseconds() value as Chan2_startPulse
          detachInterrupt(Chan2Interrupt);  // after recording the value, detach the interrupt from Chan2_begin
          attachInterrupt(Chan2Interrupt, Chan2_end, FALLING); // re-attach the interrupt as Chan2_end, so we can record the value when it goes low
        }

void Chan2_end() 
        {
         Chan2_val = micros() - Chan2_startPulse;  // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue. 
         detachInterrupt(Chan2Interrupt);  // detach and get ready to go HIGH again
         attachInterrupt(Chan2Interrupt, Chan2_begin, RISING);
         if (Chan2_val < 1000 || Chan2_val > 2000) { Chan2_val = Chan2_val_last;}
         else {Chan2_val_last = Chan2_val;}
        }
        
void Chan3_begin()           // enter Chan3_begin when interrupt pin goes HIGH.
        {
          Chan3_startPulse = micros();     // record microseconds() value as Chan3_startPulse
          detachInterrupt(Chan3Interrupt);  // after recording the value, detach the interrupt from Chan3_begin
          attachInterrupt(Chan3Interrupt, Chan3_end, FALLING); // re-attach the interrupt as Chan3_end, so we can record the value when it goes low
        }

void Chan3_end() 
        {
         Chan3_val = micros() - Chan3_startPulse;  // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue. 
         detachInterrupt(Chan3Interrupt);  // detach and get ready to go HIGH again
         attachInterrupt(Chan3Interrupt, Chan3_begin, RISING);
         if (Chan3_val < 1000 || Chan3_val > 2000) { Chan3_val = Chan3_val_last;}
         else {Chan3_val_last = Chan3_val;}
       }
        
void Chan4_begin()           // enter Chan4_begin when interrupt pin goes HIGH.
        {
          Chan4_startPulse = micros();     // record microseconds() value as Chan4_startPulse
          detachInterrupt(Chan4Interrupt);  // after recording the value, detach the interrupt from Chan4_begin
          attachInterrupt(Chan4Interrupt, Chan4_end, FALLING); // re-attach the interrupt as Chan4_end, so we can record the value when it goes low
        }

void Chan4_end() 
        {
         Chan4_val = micros() - Chan4_startPulse;  // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue. 
         detachInterrupt(Chan4Interrupt);  // detach and get ready to go HIGH again
         attachInterrupt(Chan4Interrupt, Chan4_begin, RISING);
         if (Chan4_val < 1000 || Chan4_val > 2000) { Chan4_val = Chan4_val_last;}
         else {Chan4_val_last = Chan4_val;}}
        
void Chan5_begin()           // enter Chan5_begin when interrupt pin goes HIGH.
        {
          Chan5_startPulse = micros();     // record microseconds() value as Chan5_startPulse
          detachInterrupt(Chan5Interrupt);  // after recording the value, detach the interrupt from Chan5_begin
          attachInterrupt(Chan5Interrupt, Chan5_end, FALLING); // re-attach the interrupt as Chan5_end, so we can record the value when it goes low
        }

void Chan5_end() 
        {
         Chan5_val = micros() - Chan5_startPulse;  // when interrupt pin goes LOW, record the total pulse length by subtracting previous start value from current micros() vlaue. 
         detachInterrupt(Chan5Interrupt);  // detach and get ready to go HIGH again
         attachInterrupt(Chan5Interrupt, Chan5_begin, RISING);
         if (Chan5_val < 1000 || Chan5_val > 2000) { Chan5_val = Chan5_val_last;}
         else {Chan5_val_last = Chan5_val;} 
        }

How can i use the pulse duration/variable to control direction and speed of a motor?

Well I think that there is no real shorcut, you just have to start learning the fundementals of writing programs (sketches) in the Arduino C/C++ programming language. Learn from the examples avalible in the IDE (like Blink) and read the programming references and learn in small steps.

Trying to jump to a final application goes against the reason the Arduino platform was created, to teach simple programming to new comers.

Lefty