RC Tank Conversion

The idea with this project was the conversion of a static Tamiya Pz. III model to a motorized, remote-control tank. The project started my freshman year of college, and was not until the summer going into my senior year that I finished it. I greatly overestimated my own abilities, and since it was a side project, it was pushed off.

The real goal with this project is to eventually create an all-on-one programmable, miniature board for converting static models to dynamic ones. Through the work completed on the Pz. III, I was able to determine a few constraints:

  1. Must have at least 4 pwm outputs
  2. Must have at least 2 digital outputs
  3. Must have SPI capability
  4. Must have enough H-bridges to support 4+ motors
  5. Must be able to be reprogrammed

With these ideas, moving forward, I believe that I should be able to develop a solution to the aforementioned problem.

Work completed:

In the picture below one can see the basic form of how the tank moves. There are two axles, each going out of the hull and connected to their respective sprockets, which in turn mesh with the tracks.

DSC_0215
One side’s motors installed

From there, two vex motor controllers were used (they were on hand) to convert the PWM signal from an Arduino Nano to analog voltages. Connected to the Arduino was a 433Mhz receiver.

Besides that, the tank is actually completed.

DSC_0189

The code was rather simple as well, but for the life of me I could not understand the servo2 library. So, it took a while to actually implement it. Below can be seen the working code.

//Receiver

#include <ServoTimer2.h>
#include <VirtualWire.h>

ServoTimer2 R;
ServoTimer2 L;

int pos;

int rSpeed = 1500;
int lSpeed = 1500;

void setup()
{
 R.attach(5);
 L.attach(6);
 //Serial.begin(9600); // Configure the serial connection
 vw_set_ptt_inverted(true); // Required by the RF module
 vw_setup(2000); // bps connection speed
 vw_set_rx_pin(3); // Arduino pin to connect the receiver data pin
 vw_rx_start(); // Start the receiver
}

void loop()
{

uint8_t buf[2];
 uint8_t buflen = 2;
 if (vw_get_message(buf, &buflen)) //check if we have received data
 {
 byte L = (byte)buf[0];
 lSpeed = map(L, 0, 255, 1000, 2000);
 byte R = (byte)buf[1];
 rSpeed = map(R, 0, 255, 1000, 2000);

unsigned int L_R = L;
 L_R <<= 8;
 L_R += R;
 //Serial.println(L_R, HEX); pi 
 }

R.write(rSpeed);
 L.write(lSpeed);

}

 

#include <VirtualWire.h>
#include <Math.h>

#define leftPin A4
#define rightPin A6

byte mode = 0x00;
int sensorValueR;
int sensorValueL;

byte cSpeedL, cSpeedR, gear,revStart;

void setup()
{

vw_set_ptt_inverted(true); // Required by the RF module
 vw_setup(2000); // bps connection speed
 vw_set_tx_pin(3); // Arduino pin to connect the receiver data pin
 pinMode(rightPin, INPUT);
 pinMode(leftPin, INPUT);
 gear = 0;
 cSpeedL = 128;
 cSpeedR = 128;
 revStart = 25;
}
 
void loop()
{
 sensorValueR = analogRead(rightPin);
 // delay(2);
 sensorValueR = analogRead(rightPin);
 sensorValueR = map(sensorValueR, 0, 1023, 255, 0);
 if(sensorValueR < 131 & sensorValueR > 125){
 sensorValueR = 128;}
 
 sensorValueL = analogRead(leftPin);
// delay(2);
 sensorValueL = analogRead(leftPin); 
 sensorValueL = map(sensorValueL, 0, 1023, 255, 0);
 if(sensorValueL < 131 & sensorValueL > 125){
 sensorValueL = 128;}
 
 byte L = (byte)sensorValueL;
 byte R = (byte)sensorValueR;

unsigned int L_R = L;
 L_R <<= 8;
 L_R += R;

uint8_t LR[2] = {L,R};
 
 //Message to send:
 vw_send((uint8_t *)LR, 2); //message is array of bytes to send
 // second argument takes number of bytes
 vw_wait_tx(); // We wait to finish sending the message
 delay(25); // We wait to send the message again

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s