L297 stepper motor controller

I have been investigating stepper motor control for the last couple of months. I've been looking at lots of different solutions and right now I think that using the l297 chip is probably the best balance of features, price and useability.

First, here is what I have found about this chip that might be useful for others interested in stepper control.....

some useful docs....

STmicroelectronics l297 notes...
http://www.st.com/stonline/products/literature/an/1734.pdf

STmicroelectronics l297 datasheet...
http://www.st.com/stonline/products/literature/ds/1334.pdf

my understanding and brief summary....

The l297 can create the control signals for bipolar, unipolar and variable reluctance stepper motors.

In all cases, you can digitally select full stepping, half stepping and wave stepping modes.

The motor takes one step for each pulse sent from the arduino board. Direction is decided by taking a pin HIGH or LOW.

The l297 has another important feature. It includes two PWM chopper circuits to regulate the current in the motor windings. ??? what does that mean?? well, i found this page...

http://www.micromouseinfo.com/introduction/steppers.html

It's a nice and easy going explanation on stepper motors in general and it includes this bit on chopper control of steppers...

'To increase the torque at higher speeds, stepper motors are driven at several times their voltage rating. A designer might use 5 volt steppers and then run them at 12 or 14 volts. To avoid destroying the motors, the current through the windings is monitored and power is cut off when the current reaches a critical level. When it falls back down, the power is reapplied. This technique is known as "chopper drive" and it allows the motor to increase its top speed.'

So that kinda explains the functions of the chip.

I don't yet understand how to implement the chopper drive properly. Also, I have not yet tried any circuits!! but from reading and researching, I believe the following to be true....

If you don't want the chopper drive......

If you want to control a bipolar stepper, you can use the l297 with the l293.

If you want to control a unipolar stepper, you can use the l297 with the L702B or any darlington transistor array. I'm not sure if you would need a buffer.

If you do want the chopper drive......

If you want to control a bipolar stepper, you can use the l297 with the l298.

If you want to control a unipolar stepper, you can use the l297 with the ULN2075B

In all cases, you will need a few extra components to complete the circuit.

So, now I have some questions for you!

Does anybody have any experience using the chip?? or any good circuit designs for using it??

The chip has an input Vref. This is used for giving the reference voltage for controlling the Chopper circuit. Can anybody explain how to connect up this pin??

I would like to compile circuit designs using the l297 to control bipolar and unipolar steppers, with and without chopper control. I want to find the easiest possible solution for each circuit. :wink: Please post if you already have a good solution for one of these circuits.

I will now start trying some circuits, i'll post when I get one working.

Thank YOU!

PS. maybe I made some mistakes above. Please correct me! I'm just a beginner still!

Hi

I made some stepper motor drivers with the L297 and L298 five years ago, and they still work great!

The schematic for it is on page one of the L297/298 datasheet: http://www.allelectronics.com/spec/L297.pdf#search='L297'

Here is what I recall from building them:

  • the L297 will give you three-pin control of the motor: on/off, direction and step.

  • The L298 takes care of the power circuitry. I hooked some quite large steppers up to it and it never failed.. almost indestructible.

  • Use a heatsink for the L298. I put the whole circuit in a Hammond 1590B box, and the box acts as a heatsink.

  • Use an onboard regulator (7805) to provide nice clean power to the L297, and lots of bypass capacitors.

  • I recall that while there were a lot of settings, as you mention above, they mostly weren't critical... I just put a trimpot on for Vref etc, and tuned it so that it worked well.

  • Be sure to use some nice Schottky diodes on the motor leads to suppress transients, which are quite large on a good-sized stepper motor. I think OnSemi
    will still send you a few dozen or so free diodes as samples, but you have to pay shipping now it seems:
    http://www.diyaudio.com/forums/showthread.php?postid=657178

good luck!

Thanks Daniel! You keep coming to my rescue ;D

I am planning to try the schematic on the l297 datasheet. I'm glad to hear that this one worked well for you! I have a few questions about it....

  1. As i am planning to control the l297 from the arduino board, can i just use 5V output from that to power the l297 or do you suggest an external power supply using the 7805??

  2. In the schematic there is a .33 capacitor and 22K resistor connected to the 'osc' pin. What is their purpose??

  3. I'm new to electronics. I will investigate tonight, but perhaps you can explain... what is a trimpot and how do i connect it to the vref pin?? How do I know when it is adjusted right??

  4. Am i right that the l297/l298 setup is for bipolar steppers only?? If so, have you tried some other setup using the l297 with unipolar steppers??

If you can answer any of these questions, I would be very grateful! Thanks / Jonathan

hi jonathan

  1. The 5v cominoug from arduino when connected to the USB are supplied from the computer. this means that if you overload it you risk damaging the computer (altough it's a very remote risk)
    Whenever you plan to power anything bigger than a couple of LED use an external power supply. Anyway motors (unless tiny) should not be powered from the regulated 5V supply but should use the unregulated voltage supplied to the board (this usually floats between 7.5 and 9v)

  2. Going from memory the OSC pin determines the PWM frequency used to drive the motors. if you change those values you change the pwm freq.

  3. a trimpot is a potentiometre that can be adjusted with a screwdriver. connect one end of the trimpot to 5v, the other end to ground and the pin in the middle to vref. tweak until the motor runs smoothly

  4. You can use it with unipolars. you'll have to hook up the motor in a different way. (look http://www.st.com/stonline/products/literature/an/1734.pdf here for details)

you can drive the 298 directly from arduino if you dont need any of the sofisticated features it has.

for simple circuits a nice L293D (D not E or B) has power drivers and diodes integrated.. you can see a circuit here http://www.potemkin.org/cms/Pid/StepperMotor

massimo

for power, you need a separate supply (in the manufacturer's schematic they specify 36V, but I uses 12V/2A), and from this suply you can just drop in a 5V regulator for the L297, an LM78L05 or a LM7805 will work fine. As Massimo says, you shouldn't load the Arduino with anything more than a few milliamps! The driver will draw such large currents that connecting it's power suply to the Arduino's risks passing the power supply transients back to the Arduino.

Thanks guys!

I'm getting closer to actually trying to build this thing! Just a few more questions.....

I'm gonna start with this circuit....

I have a few simple questions....

1. Daniel - you recommended a 12V/2A power supply. I can only find basic AC adapters at maximum 1.2A. Could you give me a link to one like you recommend?? - I just didn't look properly - Forget this stupid question!

  1. The diagram suggests using the L6210 which is a '2 schottky bridge motor controller'. This seems to be discontinued. Would you recommend another IC or is it cheaper to use seperate diodes?? Daniel suggested Schottky diodes. Can you give me a part number?? I have found so many different diodes. I don't understand how to select the appropriate one. Also, maybe I'm confused, but I was thinking, can I use the l293d instead of the L6210??

  2. Daniel - you wrote 'Use an onboard regulator (7805) to provide nice clean power to the L297, and lots of bypass capacitors'. Does this mean that I need to use some capacitors with the 7805 or are they included inside the 7805?? If i do need to use the 7805 with some external capacitors, how do I wire it up??

  3. Very simple one... Does 'Rs1Rs2=0.5ohms' mean that both resistors should equal 0.5 Ohms or that the total resistance of Rs1 and Rs2 should equal 0.5ohms??

Thanks for helping out a slow learning electronics geek wanabe! / Jonathan

Hi Jonathon,

in terms of the power supply current, the bigger the better, but of course this all depends on the size of motor(s) you will use.

Forget the "IC Bridge" diodes... just use discrete ones. In the diagram they call them 'fast diodes' which is synonymous with Schottky diodes. Try one of these Digikey part numbers, it's not very critical: SR305DICT-ND or SR306DICT-ND.

Basically any Schottky diode with a 50V voltage rating and a 2 or 3 amp current rating will do the trick. The bigger the motor, the bigger the power supply. If you can solder SMT parts, then you can get a package with all the diodes in it, see "Schottky barrier diode arrays" in the curent Digikey catalog.

For the regulator you need the old standby circuit for the 7805... see the diagram here:
http://www.tigoe.net/pcomp/img/7805-w-motor.jpg

which is part of an excellent explanation of motor controls done by ITP at NYU:
http://www.tigoe.net/pcomp/labs/lab-motors.shtml

Throw in a few extra 100uF capacitors on both sides of the regulator, just to be safe.

In my stepper driver, I used .47ohm power resistors for RS1 and RS2... they are there to sense the current flow int he motor windings. Two one-ohm 1/2 watt resistors in parallel for each one will do the trick.

Sounds like you aren't an electronics newbie anymore, you're doing great!

Daniel -> 'Throw in a few extra 100uF capacitors on both sides of the regulator, just to be safe.'

hmmm.... Like this ??

(which reminds me... what apps do you use for your schematics and PCBs?? I found tinyCAD and freePCB - Should I try something else?? Now back to the topic....)

What I don't understand is... what is the point of the 5V / 9V Power output pins on the Arduino board?? If i remember correctly, when arduino is powered by an external supply (ie not USB), the 9V pin actually outputs the same voltage as the supply voltage. So, if I run arduino on a 12V power supply, don't I get the clean 5V and unregulated 12V that i need?

hello jonathan

For schematic diagrams I recommend Eagle Cad. you can find it on http://www.cadsoft.de . there is a free edition that works up to 100mm x 80mm of pcb (on the schematic side there are virtually no limitations)

When I need to make beautiful schematic diagrams I use eagle, export into EPS and open it in illustrator. do a select all, change the font to a nice one and I get a print ready schematic.

BTW Arduino is designed always on Eagle.

going back to your circuit.

What you need around a 7805 is just 2 capacitors per side. 100n to clean up higher frequency noise and an electrolitic capacitor of 100uF or more that is used for compensating voltage fluctuactions.
when your motor starts there is a power surge and the voltage generally drops. the large capacitors compensate for this by releasing the "energy" they have "stored".

massimo

Thanks Massimo!

just to be sure.... like this?

Also, i'm still wondering....

what is the use of the 5V / 9V Power output pins on the Arduino board?? If i remember correctly, when arduino is powered by an external supply (ie not USB), the 9V pin actually outputs the same voltage as the supply voltage. So, if I run arduino on a 12V power supply, don't I get the clean 5V and unregulated 12V that i need?

Regards / Jonathan

Jonathon:

I think Massimo is in Sweden and I am in Canada, near the pacific, so here is part two of your international answer!

In terms of the 12V motor supply and the clean 5v supply, the answer lies with the motor. When a stepper motor turns on, it draws large amounts of current into its windings. A small motor could draw 10 amps for a few milliseconds, for example. These large current draws make the supply voltage drop, unless your power supply can handle it.

Supply voltage drops are bad news for microprocessors! This is why the two supplies are always best spearated: never run any inductive load from the same supply as the microprocessor. You are asking for unpredictable trouble if you do.

Another reason for separating the supplies is to prevent noise from getting back into the microprocessor. Motors and inductors put out a large voltage spike when their fields collapse, and you don't want this to get back into the microprocessor supply, so you use a separate supply.

The general rules are:

  • try not to drive anything with an arduino pin that draws more than a few milliamps- say 10ma or so.
  • try not to drive large loads that source their current from the arduino's regulator, as this might interfere with the stability of the Atmega8's power supplies.
    -never drive an inductive load that sources it's current from the processor power supply! Use a separate supply.

Hope this helps!

Daniel

PS: the larger the filter cap on the motor side of the regulator, the better: there really isn't a limit, but in practice anything up to 470uF on the 12V side would be reasonable. You can add as much as you want.

Daniel

Massimo is in milan , the capital of design :slight_smile:

I subscribe to everything you wrote in the post.

I guess the stuff we wrote here could be turned into a nice article for the website.

massimo

Well, I've certainly been finding both of your advice very helpful! so i would second that motion!

I'm planning to breadboard the circuit very soon, so I will post some pictures of that, and the final schematic that I use. After this, I intend to make a circuit using the l297 and the ULN2075B to control a unipolar stepper.

Also I have a nice working circuit that uses a TTL 74194 shift counter as the transalator. I'll post some picures of that too (under a different topic). I'm interested to compile a group of circuits to control both unipolar and bipolar steppers, that offer a range of price vs functionality options.

Just for the record...

Jonathan is in London, the capital of rain and tea!

(and i changed my user name to 'flat stanley' for those who remember my 'little accident' just after the London workshop!)

I just checked the farnell site for the l298 and it is listed as no longer stocked?????

Any idea why that might be?? I'm worried that these chips are on their way to retirement!!

Is there some other setup which I should be investigating??

any advice would be nice!

jonathan

any advice would be nice!

Jonathon,

It's probably not stocked anymore since Europe is going RoHS compliant, and it's not compliant.

Try this: usually a nice email to the local sales rep will get you three or four samples. Offer to credit them in your next show. Failing that, I believe the chip is still widely available in North America: try this!

PS: it is stocked somewhere in Europe, as the price at this place is in Euro's, five of them...
http://www.bmm-electronics.com/Product.asp?Product_ID=746

Well, its been about 3 weeks since my last post on this thread and by now I should have got a working L297/8 circuit. However, the reality of live, with a job and a family, has meant no electronics fun for 3 weeks and zero progress.

However, I have managed to buy the ICs and now I have a little time i've met my first problem >>> the L298 doesn't fit onto a breadboard. Looking on the data sheet, it is described as a 15 lead Multiwatt package.

Is there an easy way to fit this IC to the b/b?? Or do I need to go some other way??

Thanks as always / Jonathan

Is there an easy way to fit this IC to the b/b??

You are best to skip the breadboard and go straight to a hard-wired version, since there is a lot of power and noise floating around, and the chip has to be heatsinked in any case.

On a perf-board, put pins 1,3,5,7... in one row, and then put pins 2,4,6,8... in the row behind it. A little tricky, but it works. Some pin-bending required.

Once things slow down on my end I will design a stepper driver PCB for it that fits on the Arduino... unless someone else wants to in the meantime? I have the working design with schematics.

Daniel

Hi: this one is a miser solution, but works: I've used an IDE wire (cut it and use each extreme to connect to each file of pins) to put one L298 and one 7805 into a CPU heat sink+fan cooler. It hasn't heatsink grease or mica (I think it's bad).

Thanks for this great post (please, post the schemas ;)!!). Btw. someone could explain how connect the L297 to a darlington for unipolars (or two L297 plus one ULN28003)??

Regards:

Nach.

There is a schematic for using the L297 with a unipolar motor on the L297 application notes pdf (not the datasheet).....

http://www.st.com/stonline/products/literature/an/1734.pdf

its page 15, fig 22.

It involves a darlington array, 4 protection diodes and 4 AND gates.

I'm planning to try it once I get the L297/L298 working together nicely.

Allegro have some new ICs out for controlling unipolar steppers that do the job of the L297 and the darlington array in one chip. I contacted my local sales rep and got some free samples. I haven't tried them yet though. (i'm old fashioned, so I like to learn how to do things the hard way before I use the shortcuts!)

http://www.allegromicro.com/sf/97052/


Regarding heatsinking the L298.... If you plan to step your motor slowly, for instance just a few steps per second, will the IC still need sinking?? How hot does that guy get anyway??