Robodave   Robots   Projects   Controllers   Circuits   Sensors   Motors   Tools   Links   Email me  
     Circuits      Last Modified: March 15, 2001   


Robot Circuits

H Bridges

H-BridgeH-Bridges allow forward and reverse motor control. To get a motor to turn in one direction, simply close an opposing pair of switches. For instance, in the diagram if you close the A and D switches, the motor should turn in one direction, perhaps clockwise. If the B and C switches are to be closed with A and D open, then the motor turns the opposite direction, in this case counter clockwise. Now to actually use this, you need some way to control the switches. In some cases 4 relays will work as the switches or 4 transistors or even all of the circuit packaged in a chip. Chips usually include an enable line (turns it all on or off), power lines (for the chip and the motor), switching inputs, and the outputs to drive the motor.

H-Bridge hookup I've used the Texas Instruments 754410, an advanced version of the L293D dual h bridge. In my use the enables are tied high and each input pin is directly connected to an output line of the controller. To make a motor turn, a high (+5 volts or logic 1) is sent to the 1A line while a low (0 volts or logic 0) is delivered to the 2A line, causing the motor to turn. To reverse the motor, just output a high on 2A and a low on 1A. The other motor runs based on the 3A and 4A inputs. Better circuits might connect an inverter (74xx04) between a single controller output pin and the 2A input of the h-bridge, with that same controller line being directly connected to the 1A input. That way you use one controller line to completely control motor direction but the motor is constantly driven, unless you then control the enables.

Even better circuits exist that implement speed and position control. To do this an postion device of some sort has to be connected to the motor shaft, to show how fast or where the motor is in it's rotation. This can be a slotted wheel similar to those found in computer mice, or a continuous potentiometer, or a hall effect (magnetic) sensor. To control the motor speed, most use a technique called pulse width modulation or PWM. PWM pulses the voltage to the motor in such a way that an average voltage is achieved. Say that full voltage is 12 volts, a PWM duty cycle (ratio of on time to off time) of 50% is used, then an average voltage of 6 volts is delivered. By defining how fast you want the motor to turn and counting pulses from the encoder over a time period to tell how fast it actually is turning, you can adjust the PWM duty cycle to get the motor speed you want. Position control would involve taking close account of the pulses or perhaps a resistance level in a potentiometer. If you only want the motor to make 1/2 turn, then you might count the number of pulses it takes to make that turn, then brake the motor once it arrives there or quickly switch it between clockwise and counterclockwise signals for a net braking effect. There are various discussions as to what a good frequency for PWM which discuss mechanical time constants, electrical time constants and efficiency, but in general, it seems best to experiment with the value. Some have good success with 1-3 kHz, others find values of 20 kHz and higher better, depending on the motor and probably the method of applying PWM. Many commercial controllers use the higher 20kHz plus frequencies, but are meant for higher power commercial motors. Methods of implementing PWM include sign magnitude and locked antiphase.

Sign Magnitude requires a direction input and the PWM input. The direction is set either forward or reverse (sign) and the PWM controls how much power (magnitude) is output to the motor. One form of sign magnitude PWM applies the signal to an enable line to cycle the power to the motor. On the 754410, a direction input can set 1A high and through an inverter or another controller line set 2A low while the PWM switches the 1,2 enable input. The motor simply goes from driven to free coast in this case. Another form of sign magnitude involves PWM applied to one input of the driver, where the direction controls the other side. For example, on the 754410, input 2A is set low by the direction signal, while the PWM signal switches input 1A. The output in this case goes from clockwise (1A high, 2A low) to brake (1A and 2A low). If you want to reverse direction, input 2A can be set high while 1A still recieves the PWM signal. In this case the motor goes from counterclockwise (1A low, 2A high) to brake (1A high and 2A high). In other h-bridge designs, especially discrete components, driving both sides high can be a problem in that it creates a short through the chip from the supply to ground and can cook the circuit.

Locked antiphase uses only the PWM signal to determine both delivered power and direction. An inverter is hooked between the one side and the other to reverse the PWM for one side. In the high part of the PWM cycle, the motor is driven clockwise, in the low part, counterclockwise. At a 50% duty cycle, the motor is stopped. Higher duty cycles drive the motor one direction, lower drives it the other. An example using the 754410 would use the PWM signal going into the 1A input and also into an inverter (74xx04) that then connects to the 2A input with the enable tied high. At 50%, the motor shouldn't move or might vibrate if the freqency isn't high enough. At 75% the motor should get a net turn clockwise, while at 25% it should turn counterclockwise Other methods of motor control do exist, but are not widely used. Other h-bridge chips include Nationals LM18200, Allegros 3952, the L298, and the L293D. What you use will generally depend on what kind of motors you want to drive, specifically how much voltage and current they require. Please know how your chip works and don't try any of this at home since I still haven't, only read and tried to understand what the data sheets told me, and other peoples web pages explaining how they got it to work.



goto Top  
Bumper Switches

SwitchIn order to allow your robot to control itself, it needs to know where it is in relation to objects that may be in its' path. This can be something as simple as a switch that triggers when the robot runs into something, on up to camera input to provide vision. A bumper switch is a sensor of last resort that can work when other sensors fail to do their job. It can be a simple wire that completes a circuit when depressed. Or a regular switch that doesn't require a lot of force to make contact. Most momentary contact switches work well here. One thing to remember in using a switch is to protect the controller input it feeds into. Grounding the input pin when the switch makes contact should be ok, but when the switch is open as in the picture, a current limiting resistor should be in place.

Switch If you wanted a bumper that gave a high on contact, the picture might show a good possibility if the lower resistor was about 10 times the size of the current limiting upper resistor. Or you could simply feed the input of the first bumper circuit into an inverter to then go to the controller. One other thing to remember about hooking switchs to logic inputs, is that switchs have bounce. Logic circuits operate fast enough that they are affected by how a switch, when activated, will "bounce" off it's contacts a few times before finally settling to it's new position. Several hardware and software solutions exist to cover this mechanical error.


Analog Interface

comparator circuitGetting analog signals to work with the digital environment of the controller is another basic application. Some types of sensors only provide analog information and this must be converted into some type of digital signal. The analog signal is usually in some form of a voltage change based on the environment change the sensor detects. The simplest method is to convert the analog voltage in to an on/off state for a single digital input. For this a comparator like the LM339 can be used. A comparator compares a voltage at one input to a reference voltage at the other input and output,and with a pull-up resistor, can output a good digital high or low. The LM339 has 4 comparators to use for 4 possible analog sensor inputs and outputs.

comparator circuit The picture shows a possible circuit for wiring one of these comparators. The sensor changes resistance with incoming light levels or sound changes or magnetic fields. Since it is the top of a resistive divider, the voltage between the sensor and lower resistor changes as the sensed property changes. This voltage is compared to a reference voltage set from a potentiometer (an adjustable voltage divider) and if higher, will produce a low output with the conection shown. If it is lower, then the comparator will output a high with the help of the pull up resistor. If you want to reverse the logic output, simply change where the reference and sensor dividers connect to the comparator, on the opposite + and - inputs. Or you could move the sensor to the lower half of the resistive divider.

Sometimes the robot may need to know more than just an on/off version of an analog signal. This is where an analog to digital (ADC) converter is used. This device can also take the voltage input from the analog sensor resistive divider, but converts it to several on/off signals (bits) to be read by your controller. It can output these all at once to be read by several controller inputs or in different chips can output a serial version to be read by 1 input of the controller, if the controller is capable of reading serial signals. Serial ADCs include the MAX186 by Maxim and the TLC1541 by Texas Instruments. Some controllers even have ADCs as part of their input lines, in which case you can tie the sensor resistive divider directly to these. You must adjust all resistances to suit the input requirements of any given controller or ADC.


Voltage Regulators and Boosters

regulatorRobots need fairly specific voltages for the controller, less so for the motors and other components. Very simple circuits can help provide a regulated source for the controller. Some people use a seperate voltage supply for the motors, since this component can place a big demand on batteries and "glitch" the power for other components, like the controller. I've had no real problems with using a single supply voltage so far, though some software problems made it appear that glitches occured while running a program. The LM7805 is a basic 3 terminal regulator. The picture shows one in a TO220 package, different power capacities come in smaller (TO92) or larger (TO3) cases.

Switch One circuit that shows the general use of a 3 terminal regulator simply adds a capacitor on the output to maintain a steady 5 volts. The capacitor is usually an electrolytic, with values ranging from 10 uF to even 100 uFor higher. Sometimes a capacitor is placed on the input if it is greater than 6" wire length from the battery that ranges from 0.1 to 0.33 uF, ceramic typically.

Voltage requirements of a robot, whether it be for the motors or controller, do not necessarily match up with the batteries that you have or want to use on that robot.


Encoders

SwitchTravel can only be a known by your controller if there is some way to keep track of it. Encoders can provide that information and can be hooked up to your controller or some other counter.



goto Top