Day 25: MC-1 Part IV: Steering using a servo

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.

1_MotorRoom

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.

4_InstalledMotor

The final result is very good, as we can see in the following pictures.

TurningLeft

Center

TurningRight

This picture shows the servo in the car with the wheels on the ground.

TurningTop

I am not using the whole range of positions the servo provides. The pulses width are from 1000 µs to 2000 µs.

Advertisements

Day 24: Controlling a relay with the Raspberry Pi

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.

Relay_Pi

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:

TruckDriver_Relay

And, voilà!

Green  Red

Day 23: Experimenting with a relay

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.

Relay_top Relay_bottom

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.

Relay_GreenLed Relay_RedLed

As expected, the green LED lights when the coil is turned off and the red LED lights when the coil is energized.

Day 22: MC-1 Part III: First test

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.

Day 21: MC-1 Part II: Software

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:

TruckDriver

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.