One thing i have always wanted to do (before arduino even existed) was get an RC tank! i always wanted to build one but didnt have the money to buy new hardware. If only there was a way you could have used a 2 axis controler (forward, backward, left, right) on a skid steer vehicle?!
Now as an adult i could afford the new hardware and the tank but dont have the inclination.
With a little help from rcarduino.blogspot.co.uk i have wired up my Old RC car reciever to the arduino on my "home made generic 2wd platform"
The reciever can tolerate between 3.8v and 9.6 i believe, (the car runs is on 7.2v, the plane runs it on 6v) so i wired it up the battery input to the onboard 5v supply. I figured i didnt need the "power" line outs on the servo, so just took the individual signal lead and put one on each interupt pin (2 and 3) (i now know what an interupt is and how to use is!)
I had to move my motor lead from M2 to M1 as M2 is controlled by pin 3. Remind me if i ever go back to my other 2wd projects!
I also added a "free hand" switch that drops into the 5v, gnd, and "a pin within range of the 5v and gnd headers"
The bot currently starts up, and by waggling the sticks to their extremes, i map the millisecond pulses as values, -10 to 10.
the pressing the button moves the program on to the movement section.
I can currently spin on the spot if the throttle is central and move backwards and forwards, both with a resolution of 10 in each direction (variable speeds)
i want to work out how to steer while moving next. I need to take the throttle values, and then add speed to the outside wheel, and subtract speed from the inside wheel, while maintaing forward motion on both. i guess.
but that is a job for tommorow
Tommorow:
So i built a few rules to determine how to make this thing move. I have mapped the sticks each to +10 - 10 to work with. I have then actually mapped them back up to bigger value to represent motor speed. doing it this convoluted way let me change the degree to which each stick had effect depending on the movement.
Having made a whole stack of rules, i actually found that i only needed a couple. Spin left, spin right, forward and backward. I included in the forward and backward the ability to slow one wheel.
I also applied a bit of a dead zone in the neutral position so that fluctuations in the transmitted signal didnt try and move the motors SUPER slowly (which makes them make horrible loaded noises)
if (throttle > -2 && throttle <2 && steer >-2 && steer <2) { // Stop
motorL.run(RELEASE);
motorR.run(RELEASE);
}
if (throttle >= -2 && throttle <= 2 && steer < -2) { // Spin Left
steer = map(steer, 1, 10, 50, 250);
motorL.setSpeed(steer*-1);
motorR.setSpeed(steer*-1);
motorL.run(BACKWARD);
motorR.run(FORWARD);
}
if (throttle >= -2 && throttle <= 2 && steer > 2) { // Spin right
steer = map(steer, 1, 10, 50, 250);
motorL.setSpeed(steer);
motorR.setSpeed(steer);
motorL.run(FORWARD);
motorR.run(BACKWARD);
}
if (throttle > 2 ) { // FORWARD
throttle = map(throttle, 0, 10, 50, 250);
steer = map(steer, -10, 10, -50, 50);
motorL.setSpeed(throttle - steer);
motorR.setSpeed(throttle + steer);
motorL.run(FORWARD);
motorR.run(FORWARD);
}
if (throttle < -2 ) { // BACKWARD
throttle = map(throttle, 0, -10, 50, 250);
steer = map(steer, -10, 10, -50, 50);
motorL.setSpeed(throttle + steer);
motorR.setSpeed(throttle - steer);
motorL.run(BACKWARD);
motorR.run(BACKWARD);
}
This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/rc-signals