Tech Tidbit

The term Hi-Z is just a fancy way of saying that an I/O pin is for all practical purposes connected to neither the positive voltage nor ground. It is as if there is no connection at all.

L293D, L298, and LMD18200. This column will discuss the L293D. It is the least expensive of the three chips and can carry the least amount of current (600 mA). It is sufficient though for small gear motors.

The L293D is a dual H-bridge that has built-in diodes to catch the reverse voltage spikes that were mentioned

Figure 7. Code to drive a two-wheeled robot using the L293 and a PIC.

// This program is a demonstration program for a two-wheeled robot. It slowly // accelerates the robot forward and then slows back down to a stop. It then // turns and backs up.

// This program compiles with the CCS C compiler and is meant to be run on a // PIC16F873 with a 20 Mhz oscillator.

#include <16F873.h> #device adc=8 #use delay(clock=20000000) #fuses NOWDT,HS, PUT, NOPROTECT,


const int8 forward = 0b00100100 const int8 backward = 0b00011000

const int8 right = 0b00101000

const int8 left = 0b00010100 #byte portA = 5

int i, PWMvalue;








portA = forward;

// slowly ramp up over five seconds for(i = 0; i < 255; i++) {

// slow back down over five seconds for(i = 255; i > 0; i-) {

// turn portA = right; set_pwm1_duty(255); set_pwm2_duty(255); delay_ms(700); // go backwards portA = backward; delay_ms(2000); // stop set_pwm1_duty(0); set_pwm2_duty(0);

Invest in the best trainer for your Robotics program!

the motor to go the other direction, then you would want to hold the second pin low and send a PWM signal to the first pin.

You may be asking yourself right now why you would want to use one type of driving an H-bridge over another. The first method — where the motor is either driven or is coasting — is easy to set up a circuit for if you are driving a motor in only one direction. It also requires no extra circuitry when connecting to an H-bridge that has an enable line. The down side of driving a motor this way is that it is not that good at controlling the actual speed of a motor. This method primarily controls the amount of torque that the motor puts out. If there is no load on the motor, then it will achieve top speed with a fairly low PWM value.

The second method where the motor is rapidly driven in opposite directions turns out to be a pretty good way of controlling a motor's speed. The speed versus PWM value ends up being pretty linear. There are certain situations where this method of driving an H-bridge fits in nicely with the type of math that you are using on your microcontroller.

The third method also produces a fairly linear speed versus PWM, but requires that you manually change the direction of the motor. This method gives you double the number of distinct speeds that you can command your motor to go, but — in reality — you are unlikely to notice much of a difference.

One question that arises when working with PWM is how fast should you do your PWM. The simple answer is that it depends on your application. You can successfully do PWM at rates of 1,000 Hz or lower, but you may find that the constant whine caused by the PWM quickly becomes annoying. On the other hand, you don't want to do your PWM too fast because the transistors or FETs used in H-bridges are not digital devices. They do not transition from fully off to fully on instantly. There is some amount of time during switching where they are not quite off and not quite on. During this time, a larger than normal amount of voltage will be dropped through these devices, causing them to dissipate more wattage as heat.

For the L293D H-bridge, it takes an average of 600 nanoseconds to transition from fully on to fully off and then fully on again. If you did your PWM at a rate of 1,666,666 Hz, you would be forcing the H-bridge to be in transition 100% of the time and would cause it to burn up almost immediately even with a small load attached to it. Even at much lower rates, the transition times can still cause the part to heat up significantly.

A general rule of thumb for setting the PWM rate for a motor is to put the frequency just high enough that the sound coming out of the motor is not loud enough to be

Science and Engineering Tools for Schools - GEARS-IDS™

DESIGN, BUILD, TEST & LEARN with GEARS-IDS™ Invention & Design System


* Hands-on projects with curriculum resources help students learn math, science and engineering principles.

* High-torque all metal gear head motors.

* World-class pneumatics.

* Electronics include speed controllers, switches, wire, and connectors.

* Interfaces with Radio Controllers or Parallax BASIC® Stamp programmable micro-controller.

* Gears 3D solid models.

* Precision-machined Steel and Aluminum drive components.

* All components organized in a storage container for classroom management.

* Used in high schools and colleges across the country.

Using GEARS-IDS™ every school can participate in engineering design competitions similar to those played at universities and national robotics events!

GEARS-IDS™ is more than robotics. Use it to illustrate physical science principles, pre-engineering or as the basis for a year-round technology education.

GEARS-IDS™ is rugged enough to customize your designs with additional manipulator, actuators or cameras.

Find out how your school can get the GEARS-IDS™ advantage. Contact Mark Newby at [email protected]

Note: Licensed SolidWorks users are eligible to receive a free copy of Prof. Marie Planchard's SolidWorks 2004 Tutorial with their first Gears Kit.


Educational Systems, LLC

Gears Educational Systems, LLC 105 Webster Street, Hanover, MA 02339 781.878.1512 •

Gears Educational Systems, LLC 105 Webster Street, Hanover, MA 02339 781.878.1512 •

Circle #25 on the Reader Service Card.

0 0

Post a comment