Friday, March 18, 2011

AVC Bot: Kill Switch

Dramatic, automated, high speed crashes, robotic parts flying, babies wailing in the background, gnashing of teeth... now that's what I call fun times!  And it describes perfectly what happened during the Maiden Voyages of Data Bus.

I had a remote kill switch installed. Turn on the RC remote and the robot would drop out of its main loop, turn off the throttle and steering... and crash anyway.

Remote kill switches are a good idea but if I could've taken control of the robot remotely I could've avoided crashes and saved having to chase after the wayward robot on foot. I could've driven it back to me.

Time to implement a combination kill switch / remote takeover circuit. Turn on the RC transmitter and immediately take control of the robot, steering it to safety, applying the brakes, etc.

I started with this website and circuit design.

WARNING: I'm not making any expressed or implied guarantees about the reliability or performance of this circuit. It's your responsibility to determine the best method of implementing safety measures for your situation.

Nevertheless, I hope this discussion is helpful and, perhaps, encourages other roboticists (and particularly AVC competitors) to implement remote kill switches and even 'take control' devices on their autonomous robots.

In subscribing to the Open Source Hardware ideal, the Eagle files for this and other Data Bus electronics can be found here --- Warning: the Rev 0.1 board has a couple bugs!

Detect Servo Pulses

First trick: a circuit to detect servo pulses. The circuit on the website above does this.

It implements a high pass filter, buffers the signal with an op amp, and rectifies it to build up a voltage in a capacitor. The output is high when the transmitter is on, low when it is off.

I modified the rest of the circuit for my own purposes. I wanted to build something quickly with parts on hand so I can get back to testing and refining the robot.

The "Switch"

I selected a 74*244 tri-state octal bus driver* as I had several on hand and it was an easily implemented solution. The 74*244 has two sections consisting of 4 inputs and 4 outputs (see picture).

Each section has an active-low enable that connects the section's inputs to their respective outputs. My circuit needs to switch between MCU servo signals and Radio servo signals so here's how I wired it up.

Certainly, a number of analog switches with smaller form factors than DIP-20 are available.

The Switch Driver

Note that each "servo" output and each "esc" output are tied together above. Only one of the sections of the *244 will be enabled at any given time, so between the detection circuit and the switch circuit, some "logic" driver circuitry was needed.

I breadboarded the heck out of the circuit to be sure it'd work. I had to try various configurations and designs before arriving at one that seemed to work reliably and which provided TTL/CMOS compatible high and low logic voltages.

The voltage signal from the detection circuit (left, middle line above) is amplified through the other half of the dual op amp.

Why? Servo pulses occur only about every 50ms and last only 1-2ms, and the pulses out of the filter are even shorter, so there's not a lot of current going into that 4.7uF capacitor. Its voltage is pretty low, too.

The amplifier has high input impedance so it doesn't draw down the capacitor voltage. When the transmitter is on, the circuit amplifies the signal to peg it near the supply rail, comfortably above the *244's threshold voltage. That way there's enough voltage and current to drive the *244 enable pin.

To drive the opposite enable pin a small signal transistor (2N2222A in this case) in common emitter configuration inverts the detect signal, drawing a tiny current out of the 4.7uF capacitor through a current limiting resistor and driving the opposite pin low (about 0.2V, well below the *244's threshold voltage) when the transmitter is on.

When the transmitter is off, the capacitor signal is at 0V. Thus, no base current is available to drive the NPN transistor, so only a minimal voltage drop occurs from current drawn through the collector resistor. Its output voltage is very near Vcc.

Recycling Components

I wanted to build the circuit with parts on hand, minimize board size, and avoid drilling holes. I'm sick of drilling holes.

Well, I didn't have any 74*244s or LM258 op amps in SOIC packages. But I did have some surface mount components that I could reclaim from some boards I salvaged out of PCs, CD and DVD players, and other audio equipment.

The board has a mix of size 1206 and 0603 resistors and capacitors. It also uses a tiny, salvaged 4mm, through-hole, 4.7uF electrolytic cap.

Beggars can't be choosers so I was stuck with some odd component values that I had to test on the breadboard before I could use them on the PCB. Fortunately the circuit seems relatively tolerant to variations in most of the components.

I also borrowed a (tiny!) SOT-23 2N2222A's from another project of mine that's on hold.


I've been honing my PCB fab skills over the last several months and have some new-to-me techniques to share.

I used the toner transfer method I've been practicing to fabricate the board with 16 mil traces. I etched it in Ferric Chloride in a warm water bath, a new technique that significantly speeds up etching time. The first attempt was over-etched because I left the board in too long.

I drilled holes with the rotary tool in a drill press as usual, then tossed the SMDs on after tinning and coating the board with flux paste to hold the parts in place.

I did the reflow on my reflow skillet. Then I used toner transfer method to "silkscreen" the board and, another new technique, sprayed the top of the board with clear gloss acrylic paint which I think makes the board look more professional. In fact, all the Data Bus boards are sprayed this way.

Note the two brown wire jumpers...
I soldered the through-hole parts on, and this time tried polishing the copper side with the rotary tool and a brass wire wheel, and then sprayed the bottom with acrylic. Looks nice. That should help prevent corrosion. I may go back and do this on the other Data Bus boards.


Filed under "colossal goof-ups" are the following:

I realized only after I'd plugged in everything that the robot's new ESC outputs 6VDC not 5VDC. Oops. What'd I fry? Possibly the original 74LS244 I selected.

But, by some absolute miracle, it turns out all the other 5V devices on the robot were tolerant to 6V! I seriously dodged a bullet there.

I switched the *244 for a 6V-tolerant 74HC244 and wired in a Pololu 5V regulator to power the mbed and attached 5V devices.

Next, I discovered that I had reversed the enable signals to each of the 'switches' on the *244. Argh! The quickest solution was to use jumper wires. I pulled the 244, bent pins 1 and 19 horizontally so they would no longer engage in the socket, soldered on wires, and plugged the wires into the appropriate socket holes. It worked!

Oh, and the input/output connectors are mislabeled. Oops. I hope that doesn't bite me on race day. (I hope I didn't just jinx myself)


I incorporated some changes into the Rev 0.2 version of the board in case I need to re-do it at some point, probably in preparation for 2012. I fixed the enable wiring bug and I made space for a SOT-223-sized, 5V, 1117 LDO regulator.

Ideally I'd probably switch over to a dedicated, DPDT analog switch IC. I'd likely keep the DIP-8 op amp as it makes single layer layout much easier.

But, I can make this board work. I need to focus my remaining time and energy on object avoidance and improving the accuracy and precision of the robot's navigation.

* So now Data Bus has a bus driver on board...

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.