2.4gHz R/C+Auto Rover

Oct 13, 2011

I wanted to control a tracked r wheeled vehicle via remote, while having the option of switching the device over to autonomous mode to maneuver itself around. Either that or send out general macro commands like “go this way” or “Turn here” but have the autonomous stuff kick in to do the detail work, avoiding obstacles. Sort of like electronic training wheels that made an R/C hard to crash into something.  I picked up a Rover 5 platform from Robot Shop for about $50 and added a Pgololu R5 Expansion plate to create a mounting surface with. I traded away the 9v battery pack that came with it, using a 7.4v LiPo rechargeable instead. By running the charging connector out of the platform, it gave me a rechargeable battery and eliminated the need to take the robot apart to change batteries. I used an Arduino Pro (5v 16mHz), an NKC ArduMoto DC motor controller, and a CT6B 2.4gHz radio control receiver. I made a few changes to the motor controller by using pass-thru pins for data access and pressure terminals for motor connections. It looked snazzier.

The assembled controller, motor driver and radio control are shown at left. I used six pin header extension wires that made a very professional connection between the six radio channels and the six Arduino pins. I used analog pins 0 – 6 as digital pins, calling them out as pins 14 – 19. This left the first eight digital pins free for other uses; pins 9 – 13 are used for the motor driver.

I used the dual motor version of the Rover. It comes with two and four motor combinations, and versions of each with wheel encoders pre-installed. I am not using wheel encoding so I have the plain two motor job.

The code to convert the output of the radio control receiver doesn’t seem that difficult. It is accomplished with a pulseIn() read function and then some manipulation of the result to constrain the readings. But it turns out there’s a ghost in the machine, I have yet to make it work right. Here’s the code for the R/C->Arduino I am using.

#define dir_a 13          //digital pin 13 Motor A direction

#define dir_b 12          //digital pin 12 Motor B direction

#define speed_a 10        //digital pin 10 (PWM) Mtr A speed

#define speed_b 9         //digital pin 9 (PWM) Mtr B speed

int RXCH[6];

volatile int RXSG[6];

int RXOK[6];

int PWMSG[6];

 

RXCH[0] = 14;              //Throttle

RXCH[1] = 16;              //turn left/right

RXCH[2] = 15;              //move forward/reverse

RXCH[3] = 19;              //accessory

RXCH[4] = 17;              //accessory

RXCH[5] = 18;              //accessory

 

//The accessory channels may get used to control a gripper or perhaps a dimable headlamp or something. I can figure that out once I can get the control interface to actually work.

 

 

void setup() {

pinMode(speed_a, OUTPUT);

pinMode(speed_b, OUTPUT);

pinMode(dir_a, OUTPUT);

pinMode(dir_b, OUTPUT);

for (int i = 0; i < 6; i++){

pinMode(RXCH[i], INPUT);

}

Serial.begin(9600);

}

 

void loop() {

for (int i = 0; i < 6; i++){   //for each of the 6 channels:

RXSG[i] = pulseIn(RXCH[i], HIGH, 20000);   //read the receiver signal

if (RXSG[i] == 0) {RXSG[i] = RXOK[i];} else {RXOK[i] = RXSG[i];}    //if the signal is good then use it, else use the previous signal

PWMSG[i] = map(RXSG[i], 1000, 2000, 0, 511);//substitute the high values to a value between 0 and 511

constrain (PWMSG[i], 0, 511);

}

 

// code to read variables and translate them into motor responses

// goes here

 

}

I will keep working on it as time allows because I think this would be pretty cool. As a thought, I have an ArduPilot setup that interfaces with R/C to stabilize flight and permit autonomous flight with GPS Nav. Seems a bit pricey for the simple stuff I’m trying to do. Besides, its doing a great job on my EasyStar and I hate to break working projects. :)

 

More on this if I figure something out.

 

by | Categories: Stuff I Wrote | Tagged: , , , , , , , | Comments Off
p5rn7vb