Modified RC Vehicle: Difference between revisions

From Hive13 Wiki
Jump to navigation Jump to search
Line 71: Line 71:
= TODO List =
= TODO List =
* Re-analyze the steering sensor output, and refactor the steering code.
* Re-analyze the steering sensor output, and refactor the steering code.
* Put in some sort of average for the sensor output
* Test the averaging code for the sensor output.
* Figure out how exactly all the parts will fit inside the truck body, especially the batteries.
* Figure out how exactly all the parts will fit inside the truck body, especially the batteries.
** I think I am going to need to take a dremel to the extraneous innards to free up some room.
** I think I am going to need to take a dremel to the extraneous innards to free up some room.
* Create a test wiring with both sensors and both motors.
* Create a test wiring with both sensors and both motors.
* Look into creating a circuit board for the sensor input.
* Look into creating a circuit board for the sensor input. (because it would be cool)
** Actually ordered a spare proto-board for this.

= Work Log =
= Work Log =

Revision as of 08:30, 27 August 2009

Please feel free to leave comments on the "Discussion" Page.

Rccar assembled.JPG


This will be a project to modify an existing RC vehicle to have a micro-controller for a brain and use various sensors to navigate through a cluttered terrain.

We will start off simple with just turning to avoid obstacles as it moves forward, but I see this as a platform that we will be able to expand on for future projects.

Current Plan

I figure for the first set up we will use two distances sensors mounted on the front right and front left of the vehicle. By polling the distances reported from the sensors we should be able to sense if the vehicle should turn to the right or left to avoid the obstacle.


This is essentially how the main navigation loop works. Some stuff has been tweeked, but this is a good psuedo-code representation.

leftDistance = leftSensor.value();
rightDistance = rightSensor.value();

safeDistance = 40 inches
minDistance = 2 inches

if( rightDistance < minDistance || leftDistance < minDistance )
    while(GetRightDistance() < minDistance || GetLeftDistance() < minDistance)
        backup(2); // Backup in 2 second increments until we are safely back.
if( rightDistance < safeDistance || leftDistance < safeDistance )
    if( leftDistance < rightDistance )


Since tearing apart the body of the vehicle, I have found out a few things. I decided that I would get more flexibility in the long run if I scrapped the current circuit board and wired it up directly to the Arduino Motorshield.

The internal mechanicals for the truck are pretty cool. It currently has two motors, one motor in the rear turns a differential that then distributes power to the four wheels. The rear motor is also connected to a gear box that allows the truck to drive at two speeds. From what I recall of playing with this as an RC truck, the slow speed is incredibly slow, but you get some decent torque, while the fast speed has low torque, but can go pretty fast.

The front motor has an interest setup, and I am not sure if I am going to be able to use it in the final design. I don't know a lot about electrical parts, robotics, or motors, which is part of the reason I am working on this project. I have done some research on my own about how stepper motors work, there are multiple wires that go into the motor, and the motor works by turning on / off different coils in the motor to 'step' forward. I had assumed that a servo would work the same way. However, while I was working on cleaning the internals, Nate stopped by and said that the front motor looked like a servo. This led me to do some research online into what exactly a servo is, wikipedia has a good page: Servo Motors. I have yet to really look into this much further though. One of the big differences between the servo I have and the ones I have seen so far is that it has 7 wires going to it from the main circuit board of the RC car, 2 straight to the motor (red, blue) and 5 straight to the sensor pad (violet, grey, yellow, white, brown). If you look at the top right of this image you can see the 7 wires.

Rccar circuitboard.JPG The front gearbox with the contacts The front engine with the contact pads

I am not sure how well I will be able to use the front engine // gearbox assembly, I will have to experiment when the motorshield arrives. If that fails I might need to go out and get a servo that I can mount inside the case to turn the wheels.


The brain of the project will be based around an Arduino micro-controller. The Arduino will take input from various sensors and use that information to turn the vehicle.

Current electronic parts list:

  • Arduino
  • Arduino Motorshield
    • To control the various servos and motors without burning out the Arduino.
  • 2x Reflective Optical Sensors (IR Distance Sensors)
  • Alternate power source for the motors
    • I have a couple 7.2v rechargeable batteries, I should fine the charger...
  • 9v Battery for the arduino
  • Motors
    • RC Car's DC drive motor to power the wheels
    • The steering motor is currently in limbo. I might be using the one I salvaged from the RC Car, but that is currently undetermined.

Future Plans

We have several hackable PocketPC's at the space, maybe we can set up some kind of webcam on it and do some smart navigation. Or possible set up some kind of radio beacon in the space and we could have it so we could tell the robot to navigate to different beacons attempting to avoid obstacles.



  • Re-analyze the steering sensor output, and refactor the steering code.
  • Test the averaging code for the sensor output.
  • Figure out how exactly all the parts will fit inside the truck body, especially the batteries.
    • I think I am going to need to take a dremel to the extraneous innards to free up some room.
  • Create a test wiring with both sensors and both motors.
  • Look into creating a circuit board for the sensor input. (because it would be cool)
    • Actually ordered a spare proto-board for this.

Work Log

This section is for people to post a log what they have done on the project.

August 6, 2009 - Opened it up

First I worked on just wiping off the outside of the vehicle since it was coated in a layer of dust. After that I opened up a pack of batteries and put them in the car. After flicking the switch on I noticed that the "on" indicator LED flickered on/off. After a bit of fiddling it was clear that the 9v battery was a bit loose so I wedged it in with some paper. With the paper wedged behind the 9v battery the LED indicator stayed on nicely.

I then proceeded to take out the numerous screws holding the body together. Once all the screws were out the body came apart pretty easily. The vehicle's wheels are held onto the bottom by a removable hub. With the body removed I was able to see that the inside is coated in a layer of dirt and dust that is going to take a bit to clean out.

With the body removed it exposed a circuit board. I spent a little bit of time poking around on the board and determined that the Forward / Reverse motors are just regular motors and by shorting out the logic circuits on the chip I am able to easily make it run forward and backwards. However, I think the steering is done by a stepper motor, or possibly a servo, which can't be controlled just by shorting out the circuit board.

I was going to see how much power the motor was getting, but the fuse in my multi-meter is broken at the moment.

--Paul 13:18, 6 August 2009 (UTC)

August 9, 2009 - Parts hath been ordered

I was able to put in an order to both Mouser and Adafruit for parts I will be using in this project:

Total shipping charges ~$13
Total Cost: ~$57

--Paul 02:18, 10 August 2009 (UTC)

August 10, 2009 - Teardown

Rccar disassembled.JPG

I spent this evening taking the insides apart more fully. Last week I just took the case off and took a look at was inside. This week I worked on cleaning off the circuit board and taking a look at the motors.

The vehicle has 2 motors, both of which look like they are standard DC hobby motors.

  • Steering motor
    • The steering motor is a bit interesting, it connects to a gearbox that then turns both the front steering mechanism, and it goes into this strange sensor pad arrangement to let the circuit board know how far the motor has turned. I was hoping that this would be either a stepper motor or a servo. There are two problems with the current setup if I want to hook into it.
      1. The first problem is that I took apart the gearbox... and now I can't get it back together exactly right. oops.
      2. The second problem is that the RC car's circuit board used the gearbox sensors to detect when to stop turning the motor, and I currently do not know exactly how that setup worked.
        • I got the Motorshield for the arduino, and I will have to see if I can maybe just ignore the sensor reports. What I am supposed to do with the motorshield is adjust the speed of the motor, if I adjust the speed down far enough, I might be able to hold the steering to the left // right without strippping out the gears in the turning mechanism.
    • However, if using the motorshield fails, I might need to buy a servo to control the steering.
  • Drive Motor
    • This is pretty cool, it looks like a hobby motor hooked up to a gearbox, but this is a 2-speed gearbox. The speed was controlled by a switch on the outside of the vehicle. In anycase, the really cool part of this is that it has a differential gearbox setup as well.

-- Paul 01:38, 11 August 2009 (UTC)

August 12, 2009 - Cleaning... Part 1

Rccar CleanDirty.JPG

I spent several hours today using a paintbrush, a sponge, warm water, and Simple Green to brush / scrub / rinse as much caked on dirt and grease off the vehicle. I got through all of the detachable internal parts, but still have to do the outside shell and the front motor.

While dismantling and cleaning the truck, I had a few ideas for how to customize the body and make it look "cool".

  • I think I am going to also work on removing all of the decals that are currently on the body, they are a bit cheesy and I think I might also try my hand at doing some airbrushing // stencil work on it.
  • The headlights on it are transparent orange plastic, I could probably attach LED's to the back to make the headlights light up. Maybe make 'turn' signals to blink as it turns.
  • The body has a large fake plastic engine that sits on the hood, it could be fun to run a red LED up into it so that the intake holes glow red.

In any case, next time @ the space I will be working on cleaning out the actual drive gears and the chassis

--Paul 17:07, 13 August 2009 (UTC)

August 13, 2009 - Motorshield Assembly

Rccar CompletedMotorshield.JPG

All of the parts I ordered just arrived today, so I spent today working on assembling the motorshield. I also realized that I have forgotten to order the 3 pin wire that makes it easy to connect to the IR Sensors, however I am hoping to be able to salvage something from the space.

Plans for the next stop at the space include:

  • Testing out the motors with the motorshield
  • Figure out how I am going to wire up the sensors. (need some 3 pin adapter or something, maybe direct solder onto the board?)
  • Finish cleaning out the vehicle case and gears.

--Paul 14:05, 14 August 2009 (UTC)

August 15, 2009 - Motorshield Playing

A few things of interest today. The RC Car that I am using used to run off of a 9v battery and 4x 'C' 1.5v batteries. I am hoping to use a spare 7.2v rechargeable battery I have from a different RC car. The Arduino Motorshield has built in support for using an external battery pack to power the motors, so I will be using the 7.2v battery there.

Today I hooked up both the front steering motor and the rear drive motor to the Arduino and experimented with driving them. I was able to get both motors turning at various speeds and directions while connected to the motorshield and the external battery pack.

After figuring out that I could get the steering motor to turn left // right I was planning on just using timing to turn left // right, however Timon was looking at the circuit board in the gearbox and I think we have managed to figure out how to use it to determine the position of the motor. There are 5 wires that go into the sensor pad:

  1. Wire 1: Source "High" voltage
  2. Wire 2: Source "High" voltage
  3. Wire 3: When "High" motor is either all the way left, or all the way right.
  4. Wire 4: When "High" motor is in the middle.
  5. Wire 5: When "High" motor is either all the way right, or all the way left.

I also did a little bit more cleaning on the cars drive gears and the base of the chassis. I still need to clean the top of the car.

--Paul 22:40, 16 August 2009 (UTC)

August 17, 2009 - Final Cleaning & Sensor Setup

Rccar sensorTesting.jpg

I started out today by finishing up the cleaning, washed the tires again, then washed the top of the chassis. Looks nice now, but my hands are dried out...

After the cleaning I moved on to working on the IR distance sensors. It is essentially this sensor without the handy wire. I got them for $8 each from here. So I had to figure out some way to wire them up. I decided to try my hand at soldering on some wires to the back of the connection pins. It went fairly well. I soldered 3 wires onto each sensor then spent the next hour or so testing them out.

My original plan was to swap back and forth between the sensors, however the logic I/O pins don't quite deliver enough juice, and the beams of the IR LED's are fairly focused so I don't think I will need to do the swapping.

Plans for the next visit include:

  • Possibly using a Dremel tool to gut the inside of the old RC to free up some more room for electronics.
  • Testing out a program to tie everything together. So far I have done motor tests and sensor tests, now time to do some motor // sensor tests.
  • Test out the 5 wire sensor for the front motor.

--Paul 04:07, 18 August 2009 (UTC)

August 18, 2009 - Steering Motor Tests

Rccar frontengine.JPG

I did a few things today. Earlier today I worked on coding up a rough draft of the Arduino navigation code, however my findings tonight are going to require I rethink a few areas.

After the weekly meeting I hooked my steering motor back up to the motor shield and then wired up the 5 sensor wires to the arduino. As per my previous thoughts on the project I hooked the two left most wires up to a 5v source, and I wired the next three wires up to pins 2, 5, 6 (chosen because they will not interfere with the motor shield). I tested out my original theory of how the sensor wires worked, and found it to be flawed. It seemed that when I had the motor all the way left, or all the way right, I was always getting a test result of "1 1 1" (right middle left). By luck after one of my tests the motor stopped in the middle, and I noticed that I was getting a result of (0 1 0). So I decided to run the motor at the lowest possible speed, and check the sensor status every 100ms, this was the result with redundant numbers trimmed out:

Left Middle Right
1    1      1    Far Left
0    1      1
0    1      0    Middle
1    1      0
1    1      1    far right

Looking at the numbers now, I wonder if I somehow screwed up the middle sensor, because it looks like it is always "HIGH" and never goes "LOW". However, now this gives me something to go on to determine what position the motor currently is in. The only annoying thing is that both "far left" and "far right" seem to mirror each other.

Looking at the sensor pad, I am not sure how much sense any of this makes though, especially with regards to the "Middle" pin.

--Paul 05:12, 19 August 2009 (UTC)

August 20, 2009 - More Steering Motor Tests

I started off tonight by trying out some code I wrote yesterday, but I immediately ran into some problems. First off, my battery was low so I slapped it in the charger. While that was charging I dismantled the front engine and cleaned it thoroughly. Before fully assembling it, I sprayed some white lithium lubricant onto the front gears. After the cleaning and lubing the front motor runs much, much better.

After the battery finished charging I started testing out some of the code I wrote. I am having some odd problems. The way the turning code is working is getting kind of complex.

For example, to turn the motor right:

  1. First check to see if we are already turned right, if we are, exit the function.
  2. Check to see if we are either "Far Left" or "Left"
    1. If we are, then turn the motor until we reach the middle.
  3. Now Check to see if we are stopping at the middle (part of my "Center the wheels" routine)
    1. If we are not, then finish turning the motor to the right.
  4. Set the steering position variable to "Far Right"

The problem is that when I turn off the motor, it has some inertia, so if I stop it at the "middle" if the motor is going fast, it will coast on over to the "right" position, or "Far Right" position. Which then if I try to turn the motor right again, causes the engine to be in an "undefined" state. At least that is what I think is going on. I am going to refactor my code tomorrow.

However, after trial and error I got the steering working about 97% of the time, so I wired up the sensors and the drive motor and started seeing how everything worked together. I ran into more problems here... For some reason the turning logic is triggering even when the distance sensors are not reporting a close obstacle.

Things added to the TODO list:

  • Re-factor the code
    • This includes re-thinking the turn logic from the ground up.
    • Average out the last 3-4 distances readings to prevent crazy output.

-- 15:10, 25 August 2009 (UTC)

August 25, 2009 - One step forward, Two steps back

Short update for now. While playing around with a couple of stepper motors I fried my motor shield (hopefully just my motor shield). If I also somehow damaged my arduino hopefully I can borrow someone elses for this weekend. I have a replacement motorshield on order along with a servo motor, they should be here on thursday. If the steering motor falls through I can fall back onto the servo.

The one step forward was that I learned a little bit more about the steering sensors, the middle pin was always "HIGH" because the sensor wires were bent a little bit making them touch two or more pads at a time. I bent them back into shape, but could not really test them because the motor shield is out of commission.

Plan for Tuesday is to do a little more troubleshooting with the motor shield (friend is coming down to the space with me and he has a nice multimeter and more electrical knowledge). -- 15:10, 25 August 2009 (UTC)