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.

Advertisements

Day 20: MC-1 Part I: Hardware

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.

Relay-Workaround

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.

MC1-Board MC1-Chassis

I used Velcro to attach the breadboard and the Raspberry Pi to the car. This is how the final assembly looks like.

MC1-v1.0

Day 17: Controlling a DC motor

I bought this car in a second-hand-stuff shop. Originally it was remote-controlled but when I bought it, it no longer had the remote control. I don’t know the motor specification. This car has five AA batteries (7.5V), so I think it is safe to use my 5V power source. I put it on a box to avoid it to run away.

???????????????????????????????

This time I used the L293D attached to GPIO 18 and 23 in a way I can make the motor run forwards or backwards.

???????????????????????????????

I used the Servo Blaster library as presented on Day 14. In order to run the motor forwards, I kept one signal at zero and changed the other one.


echo "2=0" > /dev/servoblaster

echo "5=500" > /dev/servoblaster

To run backwards, I inverted the signals:


echo "5=0" > /dev/servoblaster

echo "2=500" > /dev/servoblaster

It worked with values from 300 to 2000.

When the motor runs forwards, the white LED is on. The LED is connected after the L293D.

???????????????????????????????

When the motor runs backwards, the green LED is on. The LED is connected before the L293D.

???????????????????????????????

Day 14: Controlling a servo using ServoBlaster

I connected the servo control wire (the white one) in the GPIO-24 pin and connected an external 5V power source to the red and black wires:

???????????????????????????????

As usual, the external power source ground is connected to the Raspberry Pi ground.

Using the Servo Blaster library was pretty simple. The first step was setting up the library:


sudo ./servod --min=50 --max=250

By default, Servo Blaster assigns servo 6 to GPIO24. For my servos, the valid pulse width values go from 75 to 225 (750 µs to 2250 µs), centering in 150:


echo "6=75" > /dev/servoblaster
echo "6=150" > /dev/servoblaster
echo "6=225" > /dev/servoblaster

To stop the Servo Blaster deamon:

killall servod

Day 12: Playing with LEDs (III) – PWM and L293D

This time I replaced the red LED in the circuit I used on Day 11 for a ultra bright white LED.

The white LED requires more power than the Pi can provide, so I added the external power source used on Day 9 and a motor control chip, the L293D. I did the wiring based on this Adafruit tutorial but my Cobbler is connected in the inverted position.

This is the final circuit:

???????????????????????????????

Notes:

  • I used the following wire color guidelines: Black for ground, Red for Vcc, Yellow for data, and Blue for control.
  • The white LED can take up to 80mA and is connected to 100/3 = 33 Ohms resistor.
  • The green LED is connected to a 330 Ohms resistor.
  • I used an external 5V power source connected to the bottom-right corner.

The following picture shows the connections from another direction:

???????????????????????????????

This is the final result: