We can build a roving robot that behaves like a self-propelled toy car that follows the instructions in a program that we write. It might not look much like a car though.
Goals
Components
Chassis
The chassis holds the parts of the rover together. We could use a sophisticated metal frame, but that would require planning, so instead we may use a slab of plywood. When we want to add another part to the rover, we can drill a hole in the plywood and bolt it on.
Gear Motor
When voltage is applied across the terminals of the gear motor, its output shaft spins. The higher the voltage that is applied, the faster the shaft will spin, but there are limits. The output shaft is inserted into the hub of a wheel, so when the motor spins the wheel will turn and the rover will rove.
The motor can spin in two directions. There are two electrical terminals on the motor, let's call them terminal A and terminal B. When terminal A is at a higher voltage than terminal B, the motor will spin in one direction, and when terminal B is at a higher voltage, the motor will spin in the opposite direction. We can control the voltage that we connect to the terminals, so we can spin the wheel clockwise or counter-clockwise. How do we know which terminal leads to which direction? In practice, we hook things up and see what happens.
Wheel
The wheel transfers force from the motor to the floor. Some people think a good looking wheel makes for a good looking rover. This wheel is yellow, so this rover looks really good.
Here's a bit of abstract thought - the rover moves along the ground, often in a straight line, but the electrical motors that power it spin, or turn in a circle. The wheel helps change the motion from rotational motion to linear motion.
H Bridge
The H Bridge is a circuit that allows you to direct voltages to the terminals on the motor. The circuit diagram on the right shows a battery as a power source and the H Bridge circuit connected to a motor. The H Bridge name comes from the H shape (in blue) on the right side of the circuit. Four switches control how the motor is connected to the battery. With S1 closed, S2 open, S3 open and S4 closed, there is positive voltage at motor terminal A and ground at motor terminal B. With S1 open, S2 closed, S3 closed and S4 open, there is ground at motor terminal A and positive voltage at motor terminal B. By setting the switches in the H Bridge, we can control the direction that the motor turns.
Controller
Here is where we get to the coding part of the rover. The controller is a small computer that can run a program to control the rover. A typical controller is a circuit board that includes a processor, circuitry to provide power to the processor and condition its input and outputs, and connectors to hook up the controller to the system it controls.
The controller is the most complex part of the rover, but programming the controller can be relatively simple. We will use a Motorola FRDM development board which is compact, provides plenty of I/O signals and it can be programmed using a web browser.
Battery
There are many options in batteries. Rechargeable cells are attractive because you should be able to experiment with the rover for a long time and when it runs down put it on the charger. Lithium Ion cells have good power density and are popular for use in RC vehicles. Li-Ion batteries provide 3.7 volts per cell. This is a two-cell, 7.4V Li-Ion battery which should be a good match for driving 6 volt DC motors.
Obstacle sensor
The obstacle sensor uses an LED and a photoreceptor to detect objects in front of the sensor. A potentiometer on the top of the sensor can be used to adjust the distance to the obstacle that will trip the sensor. When the sensor is tripped, an indicator LED on top of the sensor will light, and the output from the sensor will go high.
Distance sensor
The distance sensor is similar to the obstacle sensor, but it also tells you how far it is to the object in front of the sense. The distance sensor sends out audio pulses and listens for an echo, like a bat. The processor can request a reading from the distance sensor, and the sensor might reply "there is an object 22 centimeters away from the sensor". Then the program running on the processor might decide that is too close, and command the motors to turn to the left.
To simplify the process of getting distance readings from the the sensor, we can use this library.
Display
The display allows the rover to tell us what it sees and what it is trying to do. This is useful for debugging the rover program if it isn't working the way we expect it to. This display is an Organic Light Emitting Diode (OLED) display. It's very bright and easy to read, but also very small.
Questions
How fast can the rover move?
Will someone accidentally step on the Rover?
If we ask the Rover to follow a given path two times, will it end up in the same place both times?
Which combination of motors and wheels works best for us?
How long will the Rover's batteries last?