Pressing a Switch on the Back And Forth Robot

On the previous page, you saw the schematic for a robot that drives forwards and backwards. You also saw the starting state of moving forward.

When the robot hits its front bumper switch on an obstacle, the circuit reverses almost instantaneously. By almost, I mean about 100 nanoseconds, which is the time it takes for the signals to race through the chip (called “propagation delay) twice.

I’ve broken the changes down into three steps to make it easier to illustrate.

2 Front bumper pressed Reversing step one

2. Front bumper pressed. Reversing step one.

When the bumper is pressed, SW3 connects Input B (IC1 pin 4) to the battery’s low (0 V) terminal, which is represented by the three little horizontal lines underneath SW3. If resistor R3 wasn’t included, there would be a conflict between Output A at 6 V and SW3 at 0 V. This would result in a short circuit that could damage the battery, chip, switch, or board, or just cause the robot to stop. Thankfully, we have a resistor that not only reduces the current, but drops the conflicting voltage as a little bit of heat.

The 0 V signal dominates the voltage at Input B. This is because SW3 is connected directly to the battery ground (no resistance), whereas the 6 V signal is comparatively weak due to passing through R3.

3 Front bumper pressed Reversing step two

3. Front bumper pressed. Reversing step two.

Now that Input B (pin 4) is low (0 V), the chip sets Output B (pin 5) to the opposite (inverted), which is high (6 V). Everything connected to Output B must also be high. Notice the high signal passes through R2 and controls Input A (pin 2) because SW2 is open and therefore does not provide a conflicting signal.

4 Front bumper pressed Reversing step three

4. Front bumper pressed. Reversing step three.

Since Input A (pin 2) is set to high (6 V), the chip sets Output A (pin 7) to the opposite (inverted), which is low (0 V). Everything connected to Output A must also be low.

And now, there is no conflict between Output A and SW3. They both agree that Input B (pin 4) should be low. No power is wasted on R3 as heat anymore.

Check out the motor (M1). The terminals are now the opposite of what they were before the switch was pressed. The motor now drives in reverse.

5 Reverse No buttons pressed

5. Reverse. No buttons pressed.

The robot is now backing away from the wall or obstacle. The front switch is no longer pressed. But, the robot remembers its state.

Why?

Well, letting go of the switch doesn’t change the value of Input B (pin 4). It was low (0 V) when the switch was pressed, and it is still low due to Output A (pin 7) passing through R3. Therefore, the robot continues in the reverse state.

If releasing the switch injected a high signal, then the robot would drive up to a wall, press the button, go into reverse, release the button, go forward into the wall again, and so on. But, the switch only provides a low value (pressed) or nothing (released).

Let’s see what happens when a robot driving backwards hits the back switch.