Reading data from RC Receiver trouble with noise

Hi,
It might be that when your RC is off, your inputs are floating - quick and simple hardware solution, try adding pull down resistors on the inputs.

A software variation on what others have suggested is to pick one of the channels (throttle is a good one) and take a time stamp every time you receive a valid signal on this channel, if the difference between the time stamp and current time is greater than 60ms set the throttle to neutral. In my experience it is better to allow a signal through if its available than it is to enter a failsafe mode - i.e. car is out of range, enters neutral, you start walking towards the car, SUV comes around the corner, your back in range and drive your car away from the SUV - if you entered failsafe, you will need a new RC Car at this point.

In air applications something else might be perferable, but generally if a valid signal is available, try to use it.

Code not tested - I am in Cairo this week.

void loop()
{
  // create local variables to hold a local copies of the channel inputs
  // these are declared static so that thier values will be retained
  // between calls to loop.
  static uint16_t unThrottleIn;
  static uint16_t unSteeringIn;
  static uint16_t unAuxIn;
  // local copy of update flags
  static uint8_t bUpdateFlags;

  static unsigned long ulLastThrottleTime;

  // check shared update flags to see if any channels have a new signal
  if(bUpdateFlagsShared)
  {
    noInterrupts(); // turn interrupts off quickly while we take local copies of the shared variables

    // take a local copy of which channels were updated in case we need to use this in the rest of loop
    bUpdateFlags = bUpdateFlagsShared;
   
    // in the current code, the shared values are always populated
    // so we could copy them without testing the flags
    // however in the future this could change, so lets
    // only copy when the flags tell us we can.
   
    if(bUpdateFlags & THROTTLE_FLAG)
    {
      unThrottleIn = unThrottleInShared;
    }
   
    if(bUpdateFlags & STEERING_FLAG)
    {
      unSteeringIn = unSteeringInShared;
    }
   
    if(bUpdateFlags & AUX_FLAG)
    {
      unAuxIn = unAuxInShared;
    }
    
    // clear shared copy of updated flags as we have already taken the updates
    // we still have a local copy if we need to use it in bUpdateFlags
    bUpdateFlagsShared = 0;
   
    interrupts(); // we have local copies of the inputs, so now we can turn interrupts back on
    // as soon as interrupts are back on, we can no longer use the shared copies, the interrupt
    // service routines own these and could update them at any time. During the update, the
    // shared copies may contain junk. Luckily we have our local copies to work with :-)
  }
 
  // do any processing from here onwards
  // only use the local values unAuxIn, unThrottleIn and unSteeringIn, the shared
  // variables unAuxInShared, unThrottleInShared, unSteeringInShared are always owned by
  // the interrupt routines and should not be used in loop
 
  // the following code provides simple pass through
  // this is a good initial test, the Arduino will pass through
  // receiver input as if the Arduino is not there.
  // This should be used to confirm the circuit and power
  // before attempting any custom processing in a project.
 
  // we are checking to see if the channel value has changed, this is indicated 
  // by the flags. For the simple pass through we don't really need this check,
  // but for a more complex project where a new signal requires significant processing
  // this allows us to only calculate new values when we have new inputs, rather than
  // on every cycle.
  if(bUpdateFlags & THROTTLE_FLAG)
  {
    // DB 19/11/2012 added range test and timestamp if valid  - ulLastThrottleTime
    if(unThrottleIn > 1000 && unThrottleIn < 2000)
    {
      if(servoThrottle.readMicroseconds() != unThrottleIn)
      {
        servoThrottle.writeMicroseconds(unThrottleIn);
      }
      ulLastThrottleTime = millis();
    }
  }
 
  bUpdateFlags = 0;

  // if we didnt get a signal for 3 times the expected interval, enter neutral
  // this condition self clears if a signal is available
  if((millis() - ulLastThrottleTime) > 60)
  {
    // set a warning LED or BUZZER so we know whats happening
    // for you to do

    // set throttle to neutral
    servoThrottle.writeMicroseconds(1500);    
  }
}

Duane B

rcarduino.blogspot.com