[SOLVED] Minor problem emulating RC

Hi,

Looking for insights and advice before my ignorance fries something :-[

I'm building a garden robot that I want to use to do the stuff I'd do anything to avoid - and building a robot to do them is a double win :slight_smile: My initial goals are to use it to spray weedkiller on my drive, to spread grassfeed on my lawn and to powerwash my patio - it's really research into path coverage algos :slight_smile: :slight_smile:

Anyway, while these are autonomous tasks, and I've built a lot of the electronics and software around ROS with a Raspi 3 as the controller and Arduino for sensor/motor control I'd also like to just dump heavy loads (it can carry 300lbs) on top of the robot and use it to carry them, controlling it with an RC transmitter and receiver.

So my problem ... I'm using a Sabertooth 2x60 controller which has dipswitches to configure its operating mode. The two modes I've used are either with an RC receiver for forward/back and left/right or with a microcontroller. This means I would have to have complex switching and flip dipswitches to move between autonomous and controled mode.

I'm thinking to leave it in RC mode, but to have an Arduino read the RC input (if any) on pin 7, and either do its autonomous stuff or flip into controlled mode in which it just replicates any signal it reads onto pin 5. If it fails to read anything on 7 for some defined period it should go back to autonomous mode.

So I wrote some code that reads pin 7 and it finds values from 1034 to 1968 if I have the RC on. It then maps() these to 0-180 and Servo.write()s the result to pin 5. Is this anywhere near sensible ?

My problem is that the value is noisy, even at neutral, or with the transmitter off, pin 7 reads +/- 100 each time, resulting in a map from about 87 to 94 degrees. Testing that with a servo means that at neutral ("rest") the servo jitters a lot.

Sorry for the long post, I'm still thinking it through ...

Cheers,

David

You mention controlling it with an RC transmitter and receiver.

What kind of transmitter and receiver? From the radio control hobby? Do you currently have it reading in the various channels from the receiver? Does the transmitter and receiver have any unused channels?

My RC transmitters have various toggle switches on them that can control functions like gear or flaps. Reading that channel would make it very clear which position the switch is in, and then you can use that to drive your autonomous/RC decision.

How are you reading the inputs from your receiver?

Have you tried averaging several pin 7 readings?

Yes, it's a 3-channel 2.4GHz Radio Control Transmitter and Receiver, a Flysky FS-GT2E for R/C cars.

The thing is that the Sabertooth 2x60 can read two signals, but has about six operating modes. One mode interprets these either as the standard signals that you'd use for throttle/steering or throttle/rudder servos. It also has a separate mode for PWM control:

"Mode 1: Analog Input
Analog input mode takes one or two analog inputs and uses those to set the speed and direction of the motor. The valid input range is 0v to 5v. This makes the Sabertooth easy to control using a potentiometer, the PWM output of a microcontroller (with an RC filter) or an analog circuit.

Mode 2: R/C Input
R/C input mode takes two standard R/C channels and uses those to set the speed and direction of the motor. There is an optional timeout setting. When timeout is enabled, the motor driver will shut down on loss of signal. This is for safety and to prevent the robot from running away should it encounter interference and should be used if a radio is being used to control the driver. If timeout is disabled, the motor driver will continue to drive at the commanded speed until another
command is given."

To read the input from the R/C receiver on pin 7 I just use

int insig = pulseIn (7, HIGH);

Averaging sounds like a good idea, I'll give it a shot, see how fast I need to sample to get stable readings without losing responsiveness - thanks !

Found the answer to my question here RCArduino: How To Read Multiple RC Channels in case anyone has the same need in future :slight_smile: