The first version of the MC-1 (Monster Car 1) presented on days 20, 21, and 22 used a solenoid to steer the wheels. Unfortunately, that approach did not work at all–I think I broke the solenoid 😦 –so I decided to replace it by a servo.
The first step was remove the solenoid and the enclosing box and cut the plastic to make room for the servo.
I have made a hole in the plastic to attach the servo using a machine screw and a nut. I have attached the other side of the servo to a L-shape servo support. The support itself was fixed to the chassis using a self tapping screw because that part of the chassis was very thick.
I have made a hole in the steering bar and connected it to the servo wheel using a paper clip.
The final result is very good, as we can see in the following pictures.
This picture shows the servo in the car with the wheels on the ground.
I am not using the whole range of positions the servo provides. The pulses width are from 1000 µs to 2000 µs.
In order to control the circuit presented on Day 23 with the Raspberry Pi, I used the L293D motor driver.
The relay requires 40 mA and the GPIO can provide up to 16 mA. Using the L293D motor is a little overkill since it can handle up to 600 mA. I believe that the ideal solution would be using a transistor as shown in this article but I don’t have one now.
It is extremely important to use the protection diode in the proper position. I have been told that the 1N4148 is more suitable for this because it has a better response time. By now, I only have a 1N4001. I have read in some blogs people saying they use the 1N4001 without problems, so I gave it a chance.
I used the GPIO #17 pin to activate the relay through the L293D. I connected +5V from a external power source to the line in the top of the image and its ground to the line in the bottom of the image.
As usual, I used my PiEater library to control the GPIO from my desktop computer. Since this is just a quick test, I added a new check box in my previous Truck Driver program:
Although the L293D is very handy, it has two important constraints: It is limited to 600 mA and it causes the voltage to drop.
The relay below has a 5V 40mA coil. It can deal with a charge up to 1A at 30V. It has the size of a 14-pin IC. Its lower part has a drawing explaining what every pin is for.
In the following circuit, a 330 Ohms resistor is connected to the common pin, a green LED is connected to the normally closed pin and a red LED is connected to the normally open pin. The power provided is 5V.
As expected, the green LED lights when the coil is turned off and the red LED lights when the coil is energized.
Although nothing caught fire, things did not work the way I intended them to:
- The workaround used to activate the solenoid did not work. The front wheel barely turned.
- The speed slider was calibrated with the wheels on the air. When the car was on the ground, it took almost full power to start moving it, although it was possible slowing it down once it was moving.
- The live video feed (as described on Day 18) presented two to four seconds of lagging.
- The camera shakes a lot when the car is moving.
Despite these enhancement opportunities, I consider it a success. It is my first successful circuit since I was in the 6th grade. I learnt a lot of things and had lots of fun. When I was at the University, I had a very frustrating experience trying to use the 8031 micro-controller.
For the future, I am considering the following possibilities:
- Use relays to activate the solenoid or replace it for a servo to turn the front wheels.
- Replace the L293D (600mA) for the L298N(2A).
- Replace the nc program used to stream the video over the network for a home made one. Maybe replace the video for still pictures.
- Change the camera position and/or add some shock absorber device.
Since programming and testing on the Raspberry Pi itself is not very productive, I have created a TCP/IP library to send commands to the ServoBlaster from a Windows .NET program. I named it PiEater. My Raspberry Pi has a WiFi USB token, so I can access it without the usage of cables.
I wrote the “Truck Driver” program for the MC-1:
The speed slider changes the pulse width sent to the motors through the L293D. Since it is a little harder to find the center of the slider, I added a “Stop” button that does that. The slider allows going from full power to back to full power to front.
The camera position sliders act on the servos mounted under the camera. The “Center” button centers the camera in both horizontal and vertical axes.
The MC-1, abbreviation for Monster Car 1, is based on parts of a car that once was remote controlled. My wife chose this name because she thinks it is ugly as a monster.
The front wheels are turned by a solenoid. Since the current provided by the L293D is limited, I created this workaround. When the servo moves, it causes the paper clips to close an electric circuit and activate the solenoid.
I have created a standard for the wiring–The connectors that provide power are females and the one that receive power are males. Hence, I don’t have energized male connectors touching each other causing short-circuits. I used glued tape to group the wires together and label them. In this way, it will be easier reconnect the chassis to the board.
I used Velcro to attach the breadboard and the Raspberry Pi to the car. This is how the final assembly looks like.
Actually, the hot glue gun was the very first piece of hardware I have bought when I decided to make robots.
I followed the tutorial on wikiHow. The aluminum paper sheet was very useful to clean the nozzle.
My first try was not successful because I did not wait enough for the gun to heat. My gun has two temperature options (low and high), so I used the high position for this work.
I have cut and drilled holes in wooden sticks in order to hold the camera. After that, I glued everything together:
I have put the servo between two sticks in each side and screwed the sticks together. This way, the servo is properly fixed but it is not glued in the car.