Proof of Concept: RoboTank
Mission Statement
Create a wireless remote-controlled vehicle, with speed control, capable of moving in forward and reverse as well as steering left and right using the PIC18F4520 microcontroller.
Concepts
The basis of any robotic vehicle is the chassis. We examined a few chassis to work with including pre-built radio controlled toy cars. All had distinct advantages and disadvantages, but one fit our bill perfectly. The Tamiya treaded chassis appeared easy to use and most importantly was very cheap.
For motor control we went with the LMD18200 h-bridge. As far as h-bridges go, this is the Cadillac. The LMD18200 has one-pin direction control, one-pin brake control current-sense output and a single PWM input that is utilized for both forward and reverse. All diode protection is built in eliminating the need for extra hardware as needed by most other h-bridges. It has a 3A current carrying capacity which is plenty for the twin gearbox of the Tamiya chassis.
Wireless module selection was easy. One of our group members has used the XBee modules on some of his previous projects with great results. The XBee Pro 900 MHz series of modules offer ease of use and great range. Operation for RS-232 applications is transparent, simply set the baud rate desired and transmit away. The XBee’s also off a 450’ indoor range and a 6 mile LOS range outdoors. We tested the range going as far as having one module in the lab and the other walked out to the pump-jack between Rex St and Madison Hall with no communication problems.
Of course, all the on-board brainwork of the vehicle will be handled by the PIC18F4520 microcontroller. It has much more capability than is needed for this project but it is the microcontroller we are studying.
Control of the vehicle and data display is handled by a laptop computer and Xbox 360 controller. A custom program written in C# displays battery voltage and current draw of each motor. The XBox 360 controller was chosen due to prior experience with it. It is the perfect control vehicle due to its ease of use. Ninety-five percent of the kids and young adults today are capable of picking up an Xbox controller and knowing exactly how to use it. One of todays most popular video games is Halo. In the game, the player can climb into a futuristic tank and use it to destroy enemies. Most people have played this game and have indeed driven that tank. For this reason, we modeled the control of our tracked vehicle after the control of the tank in Halo. In a real-world environment, such as defense projects, a short training program is often as important as low project cost. Give the user something they have been unintentionally ‘training’ on before and and the official training program can be shortened.
Materials
· Microchip PIC18F4520 Microcontroller
· (2)National Semiconductor LMD 18200 3A 55V H-Bridge
· (2)XBee Pro 900 MHz wireless module
· Tamiya Tracked Vehicle Chassis Kit
· Tamiya Twin Motor Gearbox
· LM317 Adjustable Voltage Regulator
· Various capacitors and resistors
· (14)AA Batteries and holders
Communication
The first order of business was to get serial communications working. Reading through the datasheet gave us a good idea of what needed to be done to implement serial communication with the PIC. After some trial and error we were able to get communicating with the laptop. That’s when we discovered the next problem.
With wireless communication, there is no doubt that some data will be dropped now and again. With our process of just transmitting bytes, this could cause us to ‘lose track’ of which byte is which. After some discussion with Zahir, we came to a conclusion. We would use the first two bits of each byte to implant an address for identification. This only allowed us four addresses, but that was plenty for this project. It also brought the resolution down to 64 bit which was also acceptable for this project.
Implementing the protocol was not difficult. We took the byte and its value, rotated it to the right twice turning our 8 bit number into a 6 bit number and opening up the first two bits for addressing. We then set the first two bits according to what they represented.
|
00 |
Left Motor Current Value |
|
01 |
Right Motor Current Value |
|
10 |
Battery Voltage |
|
11 |
Spare |
When the bytes were received at the laptop, the first two bits were checked to determine what value the byte represented. Then, the byte was shifted left 2 bits and assigned to its designated variable.
After implementing the protocol, all was well. We had good
solid communication between the PIC and the laptop. Here is the final code:


Control
The control side of the project proved to be somewhat challenging but quite ‘doable’. The analog value is read from the joysticks of the controller into the laptop and converted from a 16-bit number to an 8-bit number. We then implemented a ‘mixing’ technique to enable us to drive forward and reverse in both directions with just one stick. This would leave the other stick available to control a turret or pan/tilt camera in the future just as it is in the video game. Once we have two motor commands, the laptop transmits, through the XBee, the bytes to the PIC. Based on the motor values, the PIC decides what action to take. There are four possibilities, LFwd, LRev, RFwd and RRev. Each action will drive the vehicle in its respective direction while using the motor values to determine the speed at which it does so.
The process is simple, they tricky part was getting the right combinations of direction and value. Here is the final drive code:



Telemetry
Data telemetry on this project originally consisted of receiving left and right motor currents and battery voltage back to the laptop to be displayed. We were able to get battery voltage back but were unsuccessful in getting the motor currents.
Battery voltage is displayed on the laptop screen by way of voltage divider. The battery pack for the drive portion of the vehicle consists of ten AA batteries connected in series to produce +15VDC. By using a 10k resistor for R1 and a 2.7k resistor for R2, we were able to bring the max voltage on the PIC input down to 3.18VDC. This allows us to measure the battery voltage with the PIC, send a byte back to the laptop and then display it at the full 15V scale on the screen.
![]()
The motor currents proved to be a little more tricky. The current sense output on the LMD18200 sends out 377uA for each ampere being drawn by the motor. With the motors being used only drawing about 100mA nominally, the current sense output of the LMD18200 put out a very low voltage (about100mV). This characteristic, coupled with the 64 bit resolution due the addressing, proved very problematic. The readings were simply too low to get any valid data. This could have been overcome with the use of an operational amplifier but the time allotted for this project prohibits the implementation of op-amps.
The Control Station
The control station consists of a laptop running custom software to send and receive data, an Xbox360 controller and an XBee wireless module.

The software is used to receive control input, mix it for and send to the vehicle and receive vehicle data back for display. It is written in C# and uses CSTSoft meters for data display. It provides data to the operator consisting of stick movement, battery voltage and communication status. As described earlier, it was originally meant to also display motor currents but gremlins prohibited this operation.
Here is the code:




The UpdateController() function is continuously called from a while loop in the program class.
Power
Due to the noise and lack of time to engineer a filter, we had to use two separate power systems onboard the vehicle. One system is used to power the PIC and XBee radio while the other powers the motors and LMD18200.
The PIC and XBee are powered by four(4) AA batteries, connected serially, feeding a LM316 Voltage Regulator. This converts the +6VDC to +3.3VDC to power the XBee and PIC.
The LMD18200 and motors are powered by ten(10) AA batteries connected serially to produce +15VDC. This power feeds directly into the LMD18200 which powers the motors.
Conclusion
Overall, we feel the project is a success. We were able to achieve serial communication wirelessly, we were able to control the vehicle easily with only one stick and were able to receive some data back from the vehicle. It would have been nice to be able to receive the motor currents back as well, but for the first time attempt at serial communication with a PIC we have done quite well. Our mission statement was to ‘Create a wireless remote-controlled vehicle, with speed control, capable of moving in forward and reverse as well as steering left and right using the PIC18F4520 microcontroller’. We have achieved it.