(article continued from previous page)
Theoretically, a robot could be designed to solve a line maze with only a single sensor. However, it would spend a fair amount of time waving the sensor over the floor to read the maze. The All-Right robot takes the opposite approach. It uses nine reflective-pair light sensors to do the job.
Power supply and 24 inputs plugged into three 74LV4051 multiplexer ICs.
The robot’s power supply is almost straight out of the book Intermediate Robot Building.
Most sensors output an analog voltage. Practically speaking for hobbyists, you can think of analog voltages as any value between 0V and 5V. Such as 2.57643V.
Microcontrollers have a limited number of pins that can read analog voltages. These are called analog-to-digital (AD or ADC) input pins. For example, the Atmel ATMega 8-bit microcontroller family features chips with between six and ten ADC pins.
My design for the All Right robot calls for at least 13 analog sensors (9 for the floor line sensors and 4 for the quadrature encoder discs). That’s more than the maximum number of analog pins that are available on almost all microcontrollers. What can I do?
The 4051 integrated circuit features 8 input/output pins that all can connect to a single shared pin. There are three address pins (2^3=8) that control which of the 8 I/O pins is currently connected to the shared pin. Thus, a microcontroller can toggle the address pins to read each of the 8 sensors one at a time.
From the above example, you can see how the microcontroller trades 3 digital pins (for addressing) and 1 analog pin to read 8 analog sensors, one at a time. That’s an 8:4 pin ratio (2× improvement). Nevertheless, we can do better than that.
If a total of three 4051 chips are attached to the same 3 digital address pins, then they can all share the same addressing. If I hook up three analog microcontroller pins (one for each 4051 chip), I can set the address and read three sensors (one from each 4051 chip). In this example, the trade is 3 digital pins (addressing all chips) and 3 analog pins (one for each chip) to read 24 analog sensors, one at a time. That’s a 24:6 ratio (4× improvement).
If desired, you can go crazy and add a 74138 chip to the enable lines on eight 4051 chips. In that case, the trade will be 6 digital pins (3 addressing the 4051 chips and 3 addressing the 74138 chip) and 1 analog pin to read 64 analog sensors, one at a time. That’s a 64:7 ratio (9.1× improvement).
But, I digress.
Power supply and HC4051 multiplexer PCB layout.
Looking at the far right side of the circuit layout, there is a connector labeled “Multi-plexed Inputs". The bottom six pins are those that I described in one of the above examples. That is, there are three address lines and three analog microcontroller lines. Follow those lines to each of the HC4051 chips to see how they are hooked up.
I’ve used the term “4051” loosely. The pin layout and feature functionality of this particular type of analog multiplexer first appeared in a CMOS chip numbered 4051. The same pin layout is now available using more advanced semiconductor technology, such as the 74HC4051 (high-speed CMOS) and 74LV4051 (low voltage CMOS).
Although the printed circuit board was designed for 74HC4051 chips, they have the same pinouts as the 74LV4051 chips. Yet, the 74LV4051 chips have lower resistance and lower power usage. Therefore, I decided to install 74LV4051 chips into this robot.
In the above PCB layout picture, to the left of each 4051 chip is a yellow square with 14 pins. The top pins have +5V and the bottom pins have 0V (GND) [this layout causes a problem that is discussed later on]. The other pins are sensor inputs. A standard 14-pin ribbon cable can be connected to each yellow square and brought to whatever board contains the sensors.
Multiplexing sensor ribbon cables.
Pictured above is how the sensor board is actually implemented. There are three Texas Instruments SN74LV4051AN chips with several ribbon cables connected beside them. Each cable is hand labeled with a letter that refers to the sensor board to which they connect.
Ribbon cables are good at reducing the number of discrete wires running throughout your robot. However, I blew it by not placing a +5V and GND at both the top and bottom pins of my connector layout. Instead, I concentrated all of the GND pins at the bottom and all of the +5V pins at the top of the connector.
This layout prevented me from being able to use an off-the-shelf 14-pin ribbon cable connector, while splitting the ribbon down the middle to go to separate boards. In the split cable, all of the GND lines would have gone to one sensor board, and all of the +5V lines would have gone to the other. Both sensor boards need +5V and GND.
Instead, I was stuck with the nasty work of having to hand-solder tiny ribbon cable wires to each connector pin. Usually, you can just insert a ribbon cable into a ribbon connector, snap on the top, and it instantly pierces the wire insulation to connect the cable to the connector. Oh well. You live, you learn.
Oval hole to pass ribbon cables through the base of the robot.
The four ribbon cables and three discrete wires (for an extra sensor) pass through a hole in the center of the robot’s base. The hole must be wide enough to pass a rigid connector. Actually, the hole must be wide enough to pass the final rigid connector when all of the other cables are already inserted into the hole.
The hole could be made circular. However, it would need to be a larger hole than most drill machines allow. A circular hole saw would be a better choice for such a large diameter circular hole.
Instead, I placed a 1/2-inch diameter end mill into my milling machine and cut a long oval hole. This allows a wide connector to pass through without needing to create a gigantic opening in the base.
Let’s see where those ribbon cables go to...