CHAPTER 26

image

Smoother, Smaller, Cheaper

Sandwich uses a “preprogrammed” chip and large through-hole parts so that the circuitry is easy to learn and build. This chapter explores the benefits that can be achieved without such constraints.

The first design modification takes the wiggle out of the robot—sacrificing goofiness for speed. After that, a much more radical change uses modern tiny parts around a programmable brain. Guess how that impacts the price!

Playing with Sensor Circuitry

A reader and nearby robot builder, Terry Jackson, increased the line-following efficiency of Sandwich with some ingenious revisions to the sensor portion of the schematic. Figure 26-1 presents the original and revised circuits. Notice that the parts are the same; they are just wired differently. The only exception is that R1 has been duplicated to become R1A and R1B.

9781484213605_Fig26-01.jpg

Figure 26-1. Revision to the Sandwich light-sensor circuitry for smoother line following

Lowering Light Sensor Resistance

Let’s break down the circuit. The first alteration places each pair of light sensors in parallel rather than series (see Figure 26-2). In series, the resistances of the photocells are added together (R3+R4). In parallel, the formula is more complex (R3×R4)/(R3+R4). This greatly decreases total resistance. For example, a sensor over dark flooring (440,000 Ω) paired with a sensor over a light line (120 Ω) has a total resistance of 440,120 Ω in series but only 119 Ω in parallel.

9781484213605_Fig26-02.jpg

Figure 26-2. Arranging sensors in series versus parallel significantly changes the total resistance

Why is the resistance always lower in parallel? In series, the electricity has no choice but to pass through both resistive sensors. In parallel, electricity could choose to go through only the least resistant path by itself. Moreover, each additional path makes things at least a little bit easier. Therefore, parallel resistance is never going to be any greater than the lowest resistance resistor.

So, the parallel sensors always have a lower resistance. Why does that matter for this robot? Recall that the standard comparator chip can’t operate accurately in the uppermost voltage range. By keeping the sensor resistance low, at least one of the voltages seen by the comparator chip is always low enough to make the correct decision.

Driving Straight

To drive straight, Sandwich quickly alternates between powering one motor and then powering the other motor. Although this provides an amusing effect of dancing about the line, it would be technically superior if the robot drove with both motors simultaneously when the robot was centered over a line.

Terry Jackson further altered my original circuit to provide a left-turn region, a right-turn region, and an overlapping region to drive straight. The overlapping region is accomplished by inserting two resistors in the middle of the circuit (refer to the earlier Figure 26-1) and having the comparator chip measure different points (TP1 and TP2A, TP2 and TP1A) for each side.

For example, let’s say the robot is roughly centered over a dark line. However, the lighting in the room is slightly darker on one side, causing the sensors on that side to be 50 Ω more resistant each. Figure 26-3 shows the resistance at each of the test points.

9781484213605_Fig26-03.jpg

Figure 26-3. Resistances calculated for each test point, given the resistance of the light sensors

In the old arrangement, the comparator would compare TP1 to TP2 for one motor and compare TP2 to TP1 for the other motor. In this case, 105 Ω < 144 Ω, so the first motor would be powered on. But, 144 Ω > 105 Ω, so the other motor would be powered off. As the robot oscillates back and forth over the line, the motors will swap receiving power, and the overall effect will roughly drive the robot forward.

But, we’d like the robot to use both motors to drive straight forward when the resistances are so similar. What happens if the comparator is wired to compare TP1 to TP2B and TP2 to TP1A? In that case, 105 Ω < 294 Ω, so the first motor would be powered on. And, 144 Ω < 255 Ω, so the other motor would also be powered on!

The value of the fixed resistors determines how similar the light sensors values can be and still be considered near enough to drive straight. Depending on your particular light sensors, you may find a larger value, such as 1000 Ω, to be a better choice for your robot.

Revising or Leaping?

These wiring changes greatly improve the capability of the robot, without upsetting its cost or complexity. In the remainder of this chapter, you’ll learn what happens if you radically alter the design of the Sandwich circuit.

Reducing Cost and Improving Capabilities

A truly modern take on Sandwich would probably be something like a smart phone. The camera would envision the path, accelerometers would provide feedback about actual movement, the display would chart progress, and an app store would have a variety of programs the robot could run.

Figure 26-4 pictures a Sandwich robot that is not as sophisticated as a phone but that still benefits from advancements in sensing, miniaturization, and software control.

9781484213605_Fig26-04.jpg

Figure 26-4. A modern Sandwich robot with small parts, a lithium battery, and small motors

Like most new electronic devices, the modern Sandwich is powered by a rechargeable lithium polymer battery, rather than a classic 9 V alkaline. The lithium polymer battery has a voltage of about 3.7 V, which directly supports more recent electronic parts without requiring voltage-regulating circuitry.

Looking at the schematic in Figure 26-5, notice that the modern Sandwich retains aspects of the basic model, even down to many of the part numbers. The most obvious change is a 32-pin microprocessor brain instead of an 8-pin comparator chip.

9781484213605_Fig26-05.jpg

Figure 26-5. Schematic for a modern Sandwich robot

Don’t panic! This robot has the same basic circuit elements presented earlier in this book; the schematic just looks busier.

  • The LEDs are now individually wired instead of in series. Because the 9 V battery has been replaced with a 3.7 V lithium polymer battery, there is no longer enough voltage to power the LEDs in series.
  • The white LED headlamps and the sensors are now powered by transistor Q9. This is the same method of supplying power that the Sandwich motors have always used. This allows the microcontroller to turn off this circuitry to save power, if desired.
  • The power and line-following switches have been replaced by pushbuttons. Through the transistors, microcontroller pins, and microcontroller commands, all power is now controlled by software. Likewise, light and dark line-following modes can be detected algorithmically rather than set electrically.
  • The sensor and headlight potentiometers have been removed. Instead of manually adjusting and balancing a voltage for a comparator chip, the programmable microcontroller can normalize readings and trigger points in memory.
  • The cadmium sulfide photoresistors have been replaced by phototransistors (QP3-QP7) wired in parallel. Phototransistors use less power, change values faster in reaction to changes in light, and are manufactured with consistent light sensitivity (no hand sorting necessary).

Shrinking Packages

By using tiny surface-mount electronics, instead of finger-friendly through-hole packages, the robot’s board can be considerably smaller, about one-third the size (see Figure 26-6). The board is less expensive and fits into smaller containers.

9781484213605_Fig26-06.jpg

Figure 26-6. Comparison of Sandwich implemented using surface-mount parts (smaller board) and hobbyist-friendly through-hole parts (larger board)

Although it took magnifying glasses, liquid flux, and patience, this small board was soldered by hand (see Figure 26-7). Automated manufacturing could reduce the spacing between parts and would have cleaner soldering.

9781484213605_Fig26-07.jpg

Figure 26-7. Finished board with hand-soldered surface-mount parts

Size is not the only benefit of surface-mount parts. Because these parts are used in high volume for commercial electronics, they are cheaper than similar through-hole varieties, which are no longer commonly used in production.

More significantly, using surface-mount parts provides access to advanced technologies that are simply not being released in older packages. For example, the elegantly named NSS12200LT1G transistor can provide 4000 mA of current to the motors, compared to 600 mA for the classic 2907A transistor.

Looking Tiny

The basic operation of the robot is unchanged. White LEDs reflect light off the floor into light-sensitive sensors. The brain compares the voltages of the sensors against each other and then turns on transistors to power the motors.

The underside of the board (Figure 26-8) features Vishay TEMT6000X01 phototransistors and 2-PLCC white LEDs. Notice that the sensors are smaller than the head of the 4-40 screw that holds the board to the robot’s case.

9781484213605_Fig26-08.jpg

Figure 26-8. Line-following sensors soldered onto the bottom of the board

Despite being transistors, most phototransistors are not externally connected to the base pin. Instead, a light-sensitive region provides an internal signal to the base pin. As such, the transistor permits a varying amount of current to flow depending on the amount of light it is seeing. A close-up photo (Figure 26-9) shows that the lower-left pin (what would be the base pin) is not connected. That is, if you follow the paths from each of the three external pads, you’ll notice the lower-left pin does not connect to the center of the chip. Therefore, you can think of this light sensor as a simple two-pin device.

9781484213605_Fig26-09.jpg

Figure 26-9. Close-up of a 1206 package phototransistor, approximately 4 mm long × 2 mm wide × 1 mm high

This small part was nearly impossible to solder with a soldering iron. The package is intended to be attached using soldering paste on the pads underneath. I had to pre-tin the PCB pads (heat a little coating of solder), gently place the part, and then reheat the end of the PCB pads to get the solder to attach.

Increasing Functionality

The modern Sandwich robot is controlled by a programmable microcontroller, rather than a fixed general-purpose chip. A developer writes software to control the operations of pins and then downloads the program to storage on the chip. This allows the robot to be capable of much more complex functionality. For example, it can self-calibrate, choose a line-following mode, smoothly navigate, and power off when idle to save battery life.

Calibrating Good Times

This smart Sandwich robot is programmed such that if you hold down a button at power-up, it causes the robot to enter calibration mode. Next, place the robot over a black surface and press the button; then repeat this over a white surface. The robot’s microcontroller reads all the sensors and records their values in internal storage.

Knowing the voltage range of each individual sensor allows the robot to mathematically compensate during line following. Even if the robot still used photoresistors, the ability to calibrate eliminates the need for a human to test and sort sensors prior to soldering. Furthermore, this can correct for changes in sensor quality as they age and can detect damaged (or accidentally covered) sensors that no longer change value significantly in response to changes in lighting.

Automatically Detecting Line Type

The original Sandwich includes a physical toggle switch to follow either light lines or dark lines. But, the smart Sandwich simply looks at whether the center sensors are brighter or darker than the outer sensors at the start of a course. A lighter center indicates the robot should follow a light line.

Driving Smoothly

Similar to the circuit revisions described at the beginning of this chapter, the smart Sandwich can power both motors when the total sensor voltages on both sides are near enough to each other to assume the line is centered beneath the robot. In fact, if the robot sees that each individual sensor has approximately the same voltage, then the line is not beneath any of the sensors, and the motors should be powered off because the robot is no longer on the course.

Saving Power

Instead of a bulky, expensive power switch, a tiny pushbutton toggles the smart Sandwich between sleeping and waking states. Because the microcontroller controls the rest of the robot circuitry, it can turn off everything to save power. The sleeping microcontroller itself uses only a few microamps of power. Although the robot isn’t fully turned off like it would be through a physical switch, it can sleep for years without draining the battery.

When awake, the microcontroller supplies power to the side LEDs and motors as needed. More importantly, the microcontroller supplies power to the line-following white LEDs and sensors via a transistor (Q9), similar to how it powers the motors.

Because the brains control the power, this robot can go to sleep automatically when idle to save battery life.

Shrinking Costs

So, how much would you pay for this increase in functionality and decrease in size? If you are like most consumers, you’d say “less!”

The lithium polymer battery is about the same cost as a rechargeable 9V battery. The added capacitors, resistors, and transistor are offset by the decrease in cost of the surface-mount parts. So, for the sake of clarity, Table 26-1 focuses on the most significant cost differences.

Table 26-1. Major Cost Differences Between Original Sandwich and Modern Sandwich

Tab1

The total savings is $39.28. Wow!

Saving Money

The cost difference in the motors is overwhelming. The original motors are 12 V and more powerful but available from only a single supplier. The replacement motors are 6 V and smaller but available from multiple suppliers. The specific price I’m quoting is for the knock-offs from an auction web site, rather than retail.

Interestingly, the need to replace the motors originally came from the desire to run the robot from a lithium polymer battery. This was fortuitous not only for reasons of price but also because the new motors have ready-made mounts and wheels available for them (look at the wheels in the earlier Figure 26-4). This reminds me, yet again, that you often need to start your robot from the motors and work everything else around them.

The following are the other price differences:

  • The printed circuit board is one-third the size but not quite one-third the price because there is usually a small fixed cost per board regardless of size.
  • The potentiometers are no longer necessary, so that’s an easy win.
  • Toggle switches are more expensive than pushbuttons because they contain more material and require more complex manufacturing. Although there will always be a need for physical switches, modern devices use a greater quantity of pushbuttons, which further reduces their cost because of economies of scale.

It shouldn’t be a surprise that the parts that save money on the modern Sandwich are the same parts that have been swapped out on other modern devices. Why do fewer consumer electronic devices contain physical power switches, large motors, large boards, and trimming dials (see Figure 26-10)? Because they add cost and because alternatives exist.

9781484213605_Fig26-10.jpg

Figure 26-10. Commonly swapped-out parts for cost reduction

Spending Money

There were a couple of parts that increased the cost of the robot.

The microcontroller cost only $1 but replaced just one small chip. Oftentimes, a microcontroller replaces multiple logic chips in a design and thereby can result in immediate and direct savings. In this case, the microcontroller does allow the robot to swap out the pushbuttons and trimpots as well as the comparator, so the overall result is still net positive.

The phototransistors are considerably more expensive than the cadmium photocells, which is one reason why cadmium photocells are still used in low-cost products. To be fair, there are less expensive phototransistors on the market, and the price I quoted for the cadmium photocells is from a surplus grab bag that requires hand sorting.

Ever Changing

As you saw in this chapter, surface-mount parts and microcontrollers can reduce the size and cost of robots while adding functionality. Often, the circuits aren’t that much more complex because software replaces some of the hardware.

There is nothing wrong with sticking with through-hole parts and proven designs. There is a significant time cost to researching, selecting, and applying a new part. Most cutting-edge packages are not intended for use with hobbyist tools. Then again, sometimes it is just fun to try something new (see Figure 26-11).

9781484213605_Fig26-11.jpg

Figure 26-11. The new-fangled Sandwich fits nicely into a new-fangled container

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.245.1