You are on page 1of 86

Basic Stepping Motor Control Circuits

%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science

Introduction Variable Reluctance Motors Unipolar Motors Bipolar Motors Bifilar Motors Multiphase Motors

Introduction
Stepping motors come in two varieties, permanent magnet and variable reluctance (there are also hybrid motors, which are indistinguishable from permanent magnet motors from the controller's point of view ! "ac#ing a label on the motor, $ou can generall$ tell the two apart b$ feel when no power is applied! %ermanent magnet motors tend to &cog& as $ou twist the rotor with $our fingers, while variable reluctance motors almost spin freel$ (although the$ ma$ cog slightl$ because of residual magneti'ation in the rotor ! (ou can also distinguish between the two varieties with an ohmmeter! Variable reluctance motors usuall$ have three (sometimes four windings, with a common return, while permanent magnet motors usuall$ have two independent windings, with or without center taps! )enter*tapped windings are used in unipolar permanent magnet motors! Stepping motors come in a wide range of angular resolution! +he coarsest motors t$picall$ turn ,degrees per step, while high resolution permanent magnet motors are commonl$ able to handle .!/ or even -!01 degrees per step! 2ith an appropriate controller, most permanent magnet and h$brid motors can be run in half*steps, and some controllers can handle smaller fractional steps or microsteps! 3or both permanent magnet and variable reluctance stepping motors, if 4ust one winding of the motor is energised, the rotor (under no load will snap to a fi5ed angle and then hold that angle until the tor6ue e5ceeds the holding tor6ue of the motor, at which point, the rotor will turn, tr$ing to hold at each successive e6uilibrium point!

Variable Reluctance Motors

Figure 1.1

If $our motor has three windings, t$picall$ connected as shown in the schematic diagram in 3igure .!., with one terminal common to all windings, it is most li#el$ a variable reluctance stepping

motor! In use, the common wire t$picall$ goes to the positive suppl$ and the windings are energi'ed in se6uence! +he cross section shown in 3igure .!. is of >- degree per step variable reluctance motor! +he rotor in this motor has ? teeth and the stator has @ poles, with each winding wrapped around two opposite poles! 2ith winding number . energised, the rotor teeth mar#ed A are attracted to this winding's poles! If the current through winding . is turned off and winding 1 is turned on, the rotor will rotate >- degrees cloc#wise so that the poles mar#ed ( line up with the poles mar#ed 1! =n animated BI3 of figure .!. is available! +o rotate this motor continuousl$, we 4ust appl$ power to the > windings in se6uence! =ssuming positive logic, where a . means turning on the current through a motor winding, the following control se6uence will spin the motor illustrated in 3igure .!. cloc#wise 1? steps or 1 revolutionsC
Winding 1 1001001001001001001001001 Winding 2 0100100100100100100100100 Winding 3 0010010010010010010010010 time --->

+he section of this tutorial on Mid*"evel )ontrol provides details on methods for generating such se6uences of control signals, while the section on )ontrol )ircuits discusses the power switching circuitr$ needed to drive the motor windings from such control se6uences! +here are also variable reluctance stepping motors with ? and D windings, re6uiring D or @ wires! +he principle for driving these motors is the same as that for the three winding variet$, but it becomes important to wor# out the correct order to energise the windings to ma#e the motor step nicel$! +he motor geometr$ illustrated in 3igure .!., giving >- degrees per step, uses the fewest number of rotor teeth and stator poles that performs satisfactoril$! Using more motor poles and more rotor teeth allows construction of motors with smaller step angle! +oothed faces on each pole and a correspondingl$ finel$ toothed rotor allows for step angles as small as a few degrees!

Unipolar Motors

Figure 1.2

Unipolar stepping motors, both %ermanent magnet and h$brid stepping motors with D or @ wires are usuall$ wired as shown in the schematic in 3igure .!1, with a center tap on each of two windings! In use, the center taps of the windings are t$picall$ wired to the positive suppl$, and the two ends of each winding are alternatel$ grounded to reverse the direction of the field provided b$ that winding! =n animated BI3 of figure .!1 is available! +he motor cross section shown in 3igure .!1 is of a >- degree per step permanent magnet or h$brid motor ** the difference between these two motor t$pes is not relevant at this level of abstraction! Motor winding number . is distributed between the top and bottom stator pole, while motor

winding number 1 is distributed between the left and right motor poles! +he rotor is a permanent magnet with @ poles, > south and > north, arranged around its circumfrence! 3or higher angular resolutions, the rotor must have proportionall$ more poles! +he >- degree per step motor in the figure is one of the most common permanent magnet motor designs, although .D and 0!D degree per step motors are widel$ available! %ermanent magnet motors with resolutions as good as .!/ degrees per step are made, and h$brid motors are routinel$ built with >!@ and .!/ degrees per step, with resolutions as fine as -!01 degrees per step available! =s shown in the figure, the current flowing from the center tap of winding . to terminal a causes the top stator pole to be a north pole while the bottom stator pole is a south pole! +his attracts the rotor into the position shown! If the power to winding . is removed and winding 1 is energised, the rotor will turn >- degrees, or one step! +o rotate the motor continuousl$, we 4ust appl$ power to the two windings in se6uence! =ssuming positive logic, where a . means turning on the current through a motor winding, the following two control se6uences will spin the motor illustrated in 3igure .!1 cloc#wise 1? steps or ? revolutionsC
Winding Winding Winding Winding Winding Winding Winding Winding 1a 1b 2a 2b 1a 1b 2a 2b 1000100010001000100010001 0010001000100010001000100 0100010001000100010001000 0001000100010001000100010 time ---> 1100110011001100110011001 0011001100110011001100110 0110011001100110011001100 1001100110011001100110011 time --->

;ote that the two halves of each winding are never energi'ed at the same time! Both se6uences shown above will rotate a permanent magnet one step at a time! +he top se6uence onl$ powers one winding at a time, as illustrated in the figure aboveE thus, it uses less power! +he bottom se6uence involves powering two windings at a time and generall$ produces a tor6ue about .!? times greater than the top se6uence while using twice as much power! +he section of this tutorial on Mid*"evel )ontrol provides details on methods for generating such se6uences of control signals, while the section on )ontrol )ircuits discusses the power switching circuitr$ needed to drive the motor windings from such control se6uences! +he step positions produced b$ the two se6uences above are not the sameE as a result, combining the two se6uences allows half stepping, with the motor stopping alternatel$ at the positions indicated b$ one or the other se6uence! +he combined se6uence is as followsC
Winding Winding Winding Winding 1a 1b 2a 2b 11000001110000011100000111 00011100000111000001110000 01110000011100000111000001 00000111000001110000011100 time --->

Bipolar Motors

Figure 1.3

Bipolar permanent magnet and h$brid motors are constructed with e5actl$ the same mechanism as is used on unipolar motors, but the two windings are wired more simpl$, with no center taps! +hus, the motor itself is simpler but the drive circuitr$ needed to reverse the polarit$ of each pair of motor poles is more comple5! +he schematic in 3igure .!> shows how such a motor is wired, while the motor cross section shown here is e5actl$ the same as the cross section shown in 3igure .!1! +he drive circuitr$ for such a motor re6uires an H-bridge control circuit for each windingE these are discussed in more detail in the section on )ontrol )ircuits! Briefl$, an 9*bridge allows the polarit$ of the power applied to each end of each winding to be controlled independentl$! +he control se6uences for single stepping such a motor are shown below, using F and * s$mbols to indicate the polarit$ of the power applied to each motor terminalC
Terminal Terminal Terminal Terminal 1a 1b 2a 2b +---+---+---+----+---+---+---+-+---+---+---+----+---+---+---+ time ---> ++--++--++--++---++--++--++--++ -++--++--++--+++--++--++--++--+

;ote that these se6uences are identical to those for a unipolar permanent magnet motor, at an abstract level, and that above the level of the 9*bridge power switching electronics, the control s$stems for the two t$pes of motor can be identical! ;ote that man$ full 9*bridge driver chips have one control input to enable the output and another to control the direction! Biven two such bridge chips, one per winding, the following control se6uences will spin the motor identicall$ to the control se6uences given aboveC
Enable Direction Enable Direction 1 1 2 2 1010101010101010 1x0x1x0x1x0x1x0x 0101010101010101 x1x0x1x0x1x0x1x0 time ---> 1111111111111111 1100110011001100 1111111111111111 0110011001100110

+o distinguish a bipolar permanent magnet motor from other ? wire motors, measure the resistances between the different terminals! It is worth noting that some permanent magnet stepping motors have ? independent windings, organi'ed as two sets of two! 2ithin each set, if the two windings are wired in series, the result can be used as a high voltage bipolar motor! If the$ are wired in parallel, the result can be used as a low voltage bipolar motor! If the$ are wired in series with a center tap, the result can be used as a low voltage unipolar motor!

Bifilar Motors
Bifilar windings on a stepping motor are applied to the same rotor and stator geometr$ as a bipolar motor, but instead of winding each coil in the stator with a single wire, two wires are wound in parallel with each other! =s a result, the motor has / wires, not four!

In practice, motors with bifilar windings are alwa$s powered as either unipolar or bipolar motors! 3igure .!? shows the alternative connections to the windings of such a motor!

Figure 1.4

+o use a bifilar motor as a unipolar motor, the two wires of each winding are connected in series and the point of connection is used as a center*tap! 2inding . in 3igure .!? is shown connected this wa$! +o use a bifilar motor as a bipolar motor, the two wires of each winding are connected either in parallel or in series! 2inding 1 in 3igure .!? is shown with a parallel connectionE this allows low voltage high*current operation! 2inding . in 3igure .!? is shown with a series connectionE if the center tap is ignored, this allows operation at a higher voltage and lower current than would be used with the windings in parallel! It should be noted that essentiall$ all @*wire motors sold for bipolar use are actuall$ wound using bifilar windings, so that the e5ternal connection that serves as a center tap is actuall$ connected as shown for winding . in 3igure .!?! ;aturall$, therefore, an$ unipolar motor ma$ be used as a bipolar motor at twice the rated voltage and half the rated current as is given on the nameplate! +he 6uestion of the correct operating voltage for a bipolar motor run as a unipolar motor, or for a bifilar motor with the motor windings in series is not as trivial as it might first appear! +here are three issuesC +he current carr$ing capacit$ of the wire, cooling the motor, and avoiding driving the motor's magnetic circuits into saturation! +hermal considerations suggest that, if the windings are wired in series, the voltage should onl$ be raised b$ the s6uare root of 1! +he magnetic field in the motor depends on the number of ampere turnsE when the two half*windings are run in series, the number of turns is doubled, but because a well*designed motor has magnetic circuits that are close to saturation when the motor is run at its rated voltage and current, increasing the number of ampere*turns does not ma#e the field an$ stronger! +herefore, when a motor is run with the two half*windings in series, the current should be halved in order to avoid saturationE or, in other words, the voltage across the motor winding should be the same as it was! 3or those who salvage old motors, finding an /*wire motor poses a challengeG 2hich of the / wires is whichH It is not hard to figure this out using an ohm meter, an =) volt meter, and a low voltage =) source! 3irst, use the ohm meter to identif$ the motor leads that are connected to each other through the motor windings! +hen, connect a low*voltage =) source to one of these windings! +he =) voltage should be below the advertised operating voltage of the motorE voltages under . volt are recommended! +he geometr$ of the magnetic circuits of the motor guarantees that the two wires of a bifilar winding will be strongl$ coupled for =) signals, while there should be almost no coupling to the other two wires! +herefore, probing with an =) volt meter should disclose which of the other three windings is paired to the winding under power!

Multiphase Motors

Figure 1.5

= less common class of permanent magnet or h$brid stepping motor is wired with all windings of the motor in a c$clic series, with one tap between each pair of windings in the c$cle, or with onl$ one end of each motor winding e5posed while the other ends of each winding are tied together to an inaccessible internal connection! In the conte5t of >*phase motors, these configurations would be described as 7elta and ( configurations, but the$ are also used with D*phase motors, as illustrated in 3igure .!D! Some multiphase motors e5pose all ends of all motor windings, leaving it to the user to decide between the 7elta and ( configurations, or alternativel$, allowing each winding to be driven independentl$! )ontrol of either one of these multiphase motors in either the 7elta or ( configuration re6uires .I1 of an 9*bridge for each motor terminal! It is noteworth$ that D*phase motors have the potential of delivering more tor6ue from a given pac#age si'e because all or all but one of the motor windings are energised at ever$ point in the drive c$cle! Some D*phase motors have high resolutions on the order of -!01 degrees per step (D-- steps per revolution ! Man$ automotive alternators are built using a >*phase h$brid geometr$ with either a permanent magnet rotor or an electromagnet rotor powered through a pair of slip*rings! +hese have been successfull$ used as stepping motors in some heav$ dut$ industrial applicationsE step angles of .degrees per step have been reported! 2ith a D*phase motor, there are .- steps per repeat in the stepping c$cle, as shown belowC
Terminal Terminal Terminal Terminal Terminal 1 2 3 4 5 +++-----+++++-----++ --+++++-----+++++--+-----+++++-----++++ +++++-----+++++--------+++++-----+++++time --->

2ith a >*phase motor, there are @ steps per repeat in the stepping c$cle, as shown belowC
Terminal 1 Terminal 2 Terminal 3 +++---+++----+++---++++---+++---++ time --->

9ere, as in the bipolar case, each terminal is shown as being either connected to the positive or negative bus of the motor power s$stem! ;ote that, at each step, onl$ one terminal changes polarit$! +his change removes the power from one winding attached to that terminal (because both terminals of the winding in 6uestion are of the same polarit$ and applies power to one winding that was previousl$ idle! Biven the motor geometr$ suggested b$ 3igure .!D, this control se6uence will drive the motor through two revolutions!

+o distinguish a D*phase motor from other motors with D leads, note that, if the resistance between two consecutive terminals of the D*phase motor is R, the resistance between non*consecutive terminals will be .!DR! ;ote that some D*phase motors have D separate motor windings, with a total of .- leads! +hese can be connected in the star configuration shown above, using D half*bridge driver circuits, or each winding can be driven b$ its own full*bridge! 2hile the theoretical component count of half*bridge drivers is lower, the availabilit$ of integrated full*bridge chips ma$ ma#e the latter approach preferable!

1. Stepping Motor Types


%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science Introduction Statics * 9alf*Stepping and Microstepping * 3riction and the 7ead Jone 7$namics * Resonance * "iving with Resonance * +or6ue versus Speed :lectromagnetic Issues

Introduction
In an$ presentation covering the 6uantitative ph$sics of a class of s$stems, it is important to beware of the units of measurement usedG In this presentation of stepping motor ph$sics, we will assume standard ph$sical unitsC Engli sh M"SS #$RCE slug C S gram M!S #ilogra m newton

pound d$ne centimet %IST"&CE foot meter er secon TIME second second d "& 'E radian radian radian = force of one pound will accelerate a mass of one slug at one foot per second s6uared! +he same relationship holds between the force, mass, time and distance units of the other measurement s$stems! Most people prefer to measure angles in degrees, and the common engineering practice of specif$ing mass in pounds or force in #ilograms will not $ield correct results in the formulas given hereG )are must be ta#en to convert such irregular units to one of the standard s$stems outlined above before appl$ing the formulas given hereG

Statics
3or a motor that turns S radians per step, the plot of tor6ue versus angular position for the rotor relative to some initial e6uilibrium position will generall$ appro5imate a sinusoid! +he actual shape of the curve depends on the pole geometr$ of both rotor and stator, and neither this curve nor the geometr$ information is given in the motor data sheets I've seenG 3or permanent magnet and h$brid motors, the actual curve usuall$ loo#s sinusoidal, but loo#s can be misleading! 3or variable reluctance motors, the curve rarel$ even loo#s sinusoidalE trape'oidal and even ass$metrical sawtooth curves are not uncommon! 3or a three*winding variable reluctance or permanent magnet motors with S radians per step, the period of the tor6ue versus position curve will be >SE for a D*phase permanent magnet motor, the period will be DS! 3or a two*winding permanent magnet or h$brid motor, the most common t$pe, the period will be ?S, as illustrated in 3igure 1!.C

Figure 2.1

=gain, for an ideal 1 winding permanent magnet motor, this can be mathematicall$ e5pressed asC + K *h sin( (( I1 I S 2hereC + ** tor6ue h ** holding tor6ue S ** step angle, in radians K shaft angle, in radians But remember, subtle departures from the ideal sinusoid described here are ver$ common! +he single-winding holding torque of a stepping motor is the pea# value of the tor6ue versus position curve when the ma5imum allowed current is flowing through one motor winding! If $ou attempt to appl$ a tor6ue greater than this to the motor rotor while maintaining power to one winding, it will rotate freel$! It is sometimes useful to distinguish between the electrical shaft angle and the mechanical shaft angle! In the mechanical frame of reference, 1 radians is defined as one full revolution! In the electrical frame of reference, a revolution is defined as one period of the tor6ue versus shaft angle curve! +hroughout this tutorial, refers to the mechanical shaft angle, and (( I1 IS gives the electrical angle for a motor with ? steps per c$cle of the tor6ue curve! =ssuming that the tor6ue versus angular position curve is a good appro5imation of a sinusoid, as long as the tor6ue remains below the holding tor6ue of the motor, the rotor will remain within .I? period of the e6uilibrium position! 3or a two*winding permanent magnet or h$brid motor, this means the rotor will remain within one step of the e6uilibrium position! 2ith no power to an$ of the motor windings, the tor6ue does not alwa$s fall to 'eroG In variable reluctance stepping motors, residual magneti'ation in the magnetic circuits of the motor ma$ lead to a small residual tor6ue, and in permanent magnet and h$brid stepping motors, the combination of pole geometr$ and the permanentl$ magneti'ed rotor ma$ lead to significant tor6ue with no applied power!

+he residual tor6ue in a permanent magnet or h$brid stepping motor is fre6uentl$ referred to as the cogging torque or detent torque of the motor because a naive observer will fre6uentl$ guess that there is a detent mechanism of some #ind inside the motor! +he most common motor designs $ield a detent tor6ue that varies sinusoidall$ with rotor angle, with an e6uilibrium position at ever$ step and an amplitude of roughl$ .-L of the rated holding tor6ue of the motor, but a 6uic# surve$ of motors from one manufacturer (%h$tron shows values as high as 1>L for one ver$ small motor to a low of 1!@L for one mid*si'ed motor!

Half-Stepping and Microstepping


So long as no part of the magnetic circuit saturates, powering two motor windings simultaneousl$ will produce a tor6ue versus position curve that is the sum of the tor6ue versus position curves for the two motor windings ta#en in isolation! 3or a two*winding permanent magnet or h$brid motor, the two curves will be S radians out of phase, and if the currents in the two windings are e6ual, the pea#s and valle$s of the sum will be displaced SI1 radians from the pea#s of the original curves, as shown in 3igure 1!1C

Figure 2.2

+his is the basis of half-stepping! +he two-winding holding torque is the pea# of the composite tor6ue curve when two windings are carr$ing their ma5imum rated current! 3or common two* winding permanent magnet or h$brid stepping motors, the two*winding holding tor6ue will beC h1 K 1-!D h. whereC h. ** single*winding holding tor6ue h1 ** two*winding holding tor6ue +his assumes that no part of the magnetic circuit is saturated and that the tor6ue versus position curve for each winding is an ideal sinusoid! Most permanent*magnet and variable*reluctance stepping motor data sheets 6uote the two*winding holding tor6ue and not the single*winding figureE in part, this is because it is larger, and in part, it is because the most common full*step controllers alwa$s appl$ power to two windings at once! If an$ part of the motor's magnetic circuits is saturated, the two tor6ue curves will not add linearl$! =s a result, the composite tor6ue will be less than the sum of the component tor6ues and the e6uilibrium position of the composite ma$ not be e5actl$ SI1 radians from the e6uilibria of the original! Microstepping allows even smaller steps b$ using different currents through the two motor windings, as shown in 3igure 1!>C

Figure 2.3

3or a two*winding variable reluctance or permanent magnet motor, assuming nonsaturating magnetic circuits, and assuming perfectl$ sinusoidal tor6ue versus position curves for each motor winding, the following formula gives the #e$ characteristics of the composite tor6ue curveC h K ( a1 F b1 -!D x K ( S I ( I1 arctan( b I a 2hereC a ** tor6ue applied b$ winding with e6uilibrium at - radians! b ** tor6ue applied b$ winding with e6uilibrium at S radians! h ** holding tor6ue of composite! x ** e6uilibrium position, in radians! S ** step angle, in radians! In the absence of saturation, the tor6ues a and b are directl$ proportional to the currents through the corresponding windings! It is 6uite common to wor# with normali'ed currents and tor6ues, so that the single*winding holding tor6ue or the ma5imum current allowed in one motor winding is .!-!

Friction and the Dead Zone


+he tor6ue versus position curve shown in 3igure 1!. does not ta#e into account the tor6ue the motor must e5ert to overcome frictionG ;ote that frictional forces ma$ be divided into two large categories, static or sliding friction, which re6uires a constant tor6ue to overcome, regardless of velocit$, and d$namic friction or viscous drag, which offers a resistance that varies with velocit$! 9ere, we are concerned with the impact of static friction! Suppose the tor6ue needed to overcome the static friction on the driven s$stem is .I1 the pea# tor6ue of the motor, as illustrated in 3igure 1!?!

Figure 2.4

+he dotted lines in 3igure 1!? show the tor6ue needed to overcome frictionE onl$ that part of the tor6ue curve outside the dotted lines is available to move the rotor! +he curve showing the available tor6ue as a function of shaft angle is the difference between these curves, as shown in 3igure 1!DC

Figure 2.5

;ote that the conse6uences of static friction are twofold! 3irst, the total tor6ue available to move the load is reduced, and second, there is a dead zone about each of the e6uilibria of the ideal motor! If

the motor rotor is positioned an$where within the dead 'one for the current e6uilibrium position, the frictional tor6ue will e5ceed the tor6ue applied b$ the motor windings, and the rotor will not move! =ssuming an ideal sinusoidal tor6ue versus position curve in the absence of friction, the angular width of these dead 'ones will beC d K 1 ( S I ( I1 arcsin( f I h K ( S I ( I? arcsin( f I h whereC d ** width of dead 'one, in radians S ** step angle, in radians f ** tor6ue needed to overcome static friction h ** holding tor6ue +he important thing to note about the dead 'one is that it limits the ultimate positioning accurac$G 3or the e5ample, where the static friction is .I1 the pea# tor6ue, a ,-M per step motor will have dead*'ones @-M wideG +hat means that successive steps ma$ be as large as .D-M and as small as >-M, depending on where in the dead 'one the rotor stops after each stepG +he presence of a dead 'one has a significant impact on the utilit$ of microsteppingG If the dead 'one is 5M wide, then microstepping with a step si'e smaller than 5M ma$ not move the rotor at all! +hus, for s$stems intended to use high resolution microstepping, it is ver$ important to minimi'e static friction!

%yna(ics
:ach time $ou step the motor, $ou electronicall$ move the e6uilibrium position S radians! +his moves the entire curve illustrated in 3igure 1!. a distance of S radians, as shown in 3igure 1!@C

Figure 2.6

+he first thing to note about the process of ta#ing one step is that the ma5imum available tor6ue is at a minimum when the rotor is halfwa$ from one step to the ne5t! +his minimum determines the running torque, the ma5imum tor6ue the motor can drive as it steps slowl$ forward! 3or common two*winding permanent magnet motors with ideal sinusoidal tor6ue versus position curves and holding tor6ue h, this will be hI(1-!D ! If the motor is stepped b$ powering two windings at a time, the running tor6ue of an ideal two*winding permanent magnet motor will be the same as the single* winding holding tor6ue! It shoud be noted that at higher stepping speeds, the running tor6ue is sometimes defined as the pull-out torque! +hat is, it is the ma5imum frictional tor6ue the motor can overcome on a rotating load before the load is pulled out of step b$ the friction! Some motor data sheets define a second tor6ue figure, the pull-in torque! +his is the ma5imum frictional tor6ue that the motor can overcome to accelerate a stopped load to s$nchronous speed! +he pull*in tor6ues documented on stepping motor data sheets are of 6uestionable value because the pull*in tor6ue depends on the moment of inertia of the load used when the$ were measured, and few motor data sheets document thisG In practice, there is alwa$s some friction, so after the e6uilibrium position moves one step, the rotor is li#el$ to oscillate briefl$ about the new e6uilibrium position! +he resulting tra4ector$ ma$ resemble the one shown in 3igure 1!0C

Figure 2.7

9ere, the tra4ector$ of the e6uilibrium position is shown as a dotted line, while the solid curve shows the tra4ector$ of the motor rotor!

Resonance
+he resonant fre6uenc$ of the motor rotor depends on the amplitude of the oscillationE but as the amplitude decreases, the resonant fre6uenc$ rises to a well*defined small*amplitude fre6uenc$! +his fre6uenc$ depends on the step angle and on the ratio of the holding tor6ue to the moment of inertia of the rotor! :ither a higher tor6ue or a lower moment will increase the fre6uenc$G 3ormall$, the small*amplitude resonance can be computed as followsC 3irst, recall ;ewton's law for angular accelerationC +KN= 2hereC + ** tor6ue applied to rotor N ** moment of inertia of rotor and load = ** angular acceleration, in radians per second per second 2e assume that, for small amplitudes, the tor6ue on the rotor can be appro5imated as a linear function of the displacement from the e6uilibrium position! +herefore, 9oo#e's law appliesC + K *k whereC k ** the &spring constant& of the s$stem, in tor6ue units per radian ** angular position of rotor, in radians 2e can e6uate the two formulas for the tor6ue to getC N = K *k ;ote that acceleration is the second derivitive of position with respect to timeC = K d1 Idt1 so we can rewrite this the above in differential e6uation formC d1 Idt1 K *(kIN +o solve this, recall that, forC f( t K a sin bt +he derivitives areC df( t Idt K ab cos bt d1f( t Idt1 K *ab1 sin bt K *b1 f(t ;ote that, throughout this discussion, we assumed that the rotor is resonating! +herefore, it has an e6uation of motion something li#eC K a sin (1 f t a K angular amplitude of resonance f K resonant fre6uenc$ +his is an admissable solution to the above differential e6uation if we agree thatC bK1 f b1 K kIN Solving for the resonant fre6uenc$ f as a function of k and N, we getC f K ( kIN -!D I 1

It is crucial to note that it is the moment of inertia of the rotor plus an$ coupled load that matters! +he moment of the rotor, in isolation, is irrelevantG Some motor data sheets include information on resonance, but if an$ load is coupled to the rotor, the resonant fre6uenc$ will changeG In practice, this oscillation can cause significant problems when the stepping rate is an$where near a resonant fre6uenc$ of the s$stemE the result fre6uentl$ appears as random and uncontrollable motion!

Resonance and the Ideal Motor


Up to this point, we have dealt onl$ with the small*angle spring constant k for the s$stem! +his can be measured e5perimentall$, but if the motor's tor6ue versus position curve is sinusoidal, it is also a simple function of the motor's holding tor6ue! Recall thatC + K *h sin( (( I1 IS +he small angle spring constant k is the negative derivitive of + at the origin! k K *d+ I d K * (* h (( I1 IS cos( - K ( I1 (h I S Substituting this into the formula for fre6uenc$, we getC f K ( ( I1 (h I S I N -!D I 1 K ( h I ( / N S -!D Biven that the holding tor6ue and resonant fre6uenc$ of the s$stem are easil$ measured, the easiest wa$ to determine the moment of inertia of the moving parts in a s$stem driven b$ a stepping motor is indirectl$ from the above relationshipG N K h I ( / f1 S 3or practical purposes, it is usuall$ not the tor6ue or the moment of inertia that matters, but rather, the ma5imum sustainable acceleration that mattersG )onvenientl$, this is a simple function of the resonant fre6uenc$G Starting with the ;ewton's law for angular accelerationC =K+IN 2e can substitute the above formula for the moment of inertia as a function of resonant fre6uenc$, and then substitute the ma5imum sustainable running tor6ue as a function of the holding tor6ue to getC = K ( h I ( 1-!D I ( h I ( / f1 S K / S f1 I (1-!D Measuring acceleration in steps per second s6uared instead of in radians per second s6uared, this simplifies toC =steps K = I S K / f1 I (1-!D +hus, for an ideal motor with a sinusoidal tor6ue versus rotor position function, the ma5imum acceleration in steps per second s6uared is a trivial function of the resonant fre6uenc$ of the motor and rigidl$ coupled loadG 3or a two*winding permanent*magnet or variable*reluctance motor, with an ideal sinusoidal tor6ue* versus*position characteristic, the two*winding holding tor6ue is a simple function of the single* winding holding tor6ueC h1 K 1-!D h. 2hereC h. ** single*winding holding tor6ue h1 ** two*winding holding tor6ue Substituting this into the formula for resonant fre6uenc$, we can find the ratios of the resonant fre6uencies in these two operating modesC f. K ( h. I !!! -!D f1 K ( h1 I !!! -!D K ( 1-!D h. I !!! -!D K 1-!1D ( h. I !!! -!D K 1-!1D f. K .!./,!!! f. +his relationship onl$ holds if the tor6ue provided b$ the motor does not var$ appreciabl$ as the stepping rate varies between these two fre6uencies!

In general, as will be discussed later, the available tor6ue will tend to remain relativel$ constant up until some cutoff stepping rate, and then it will fall! +herefore, this relationship onl$ holds if the resonant fre6uencies are below this cutoff stepping rate! =t stepping rates above the cutoff rate, the two fre6uencies will be closer to each otherG

Living with Resonance


If a rigidl$ mounted stepping motor is rigidl$ coupled to a frictionless load and then stepped at a fre6uenc$ near the resonant fre6uenc$, energ$ will be pumped into the resonant s$stem, and the result of this is that the motor will literall$ lose control! +here are three basic wa$s to deal with this problemC

Controlling resonance in the (echanis(


Use of elastomeric motor mounts or elastomeric couplings between motor and load can drain energ$ out of the resonant s$stem, preventing energ$ from accumulating to the e5tent that it allows the motor rotor to escape from control! <r, viscous damping can be used! 9ere, the damping will not onl$ draw energ$ out of the resonant modes of the s$stem, but it will also subtract from the total tor6ue available at higher speeds! Magnetic edd$ current damping is e6uivalent to viscous damping for our purposes! 3igure 1!/ illustrates the use of elastomeric couplings and viscous damping in two t$pical stepping motor applications, one using a lead screw to drive a load, and the other using a tendon driveC

Figure 2.8

In 3igure 1!/, elastomeric moter mounts are shown at a and elastomeric couplings between the motor and load are shown at b and c! +he end bearing for the lead screw or tendon, at d, offers an opportunit$ for viscous damping, as do the wa$s on which the load slides, at e! :ven the friction found in sealed ballbearings or teflon on steel wa$s can provide enough damping to prevent resonance problems!

Controlling resonance in the lo)*le+el dri+e circuitry


= resonating motor rotor will induce an alternating current voltage in the motor windings! If some motor winding is not currentl$ being driven, shorting this winding will impose a drag on the motor rotor that is e5actl$ e6uivalent to using a magnetic edd$ current damper! If some motor winding is currentl$ being driven, the =) voltage induced b$ the resonance will tend to modulate the current through the winding! )lamping the motor current with an e5ternal inductor will counteract the resonance! Schemes based on this idea are incorporated into some of the drive circuits illustrated in later sections of this tutorial!

Controlling resonance in the high*le+el control syste(


+he high level control s$stem can avoid driving the motor at #nown resonant fre6uencies, accelerating and decelerating through these fre6uencies and never attempting sustained rotation at these speeds! Recall that the resonant fre6uenc$ of a motor in half*stepped mode will var$ b$ up to 1-L from one half*step to the ne5t! =s a result, half*stepping pumps energ$ into the resonant s$stem less efficientl$ than full stepping! 3urthermore, when operating near these resonant fre6uencies, the motor control s$stem ma$ preferentiall$ use onl$ the two*winding half steps when operating near the single*winding resonant fre6uenc$, and onl$ the single*winding half steps when operating near the two*winding resonant fre6uenc$! 3igure 1!, illustrates thisC

Figure 2.9

+he dar#ened curve in 3igure 1!, shows the operating tor6ue achieved b$ a simple control scheme that delivers useful tor6ue over a wide range of speeds despite the fact that the available tor6ue drops to 'ero at each resonance in the s$stem! +his solution is particularl$ effective if the resonant fre6uencies are sharpl$ defined and well separated! +his will be the case in minimall$ damped s$stems operating well below the cutoff speed defined in the ne5t section!

Torque versus Speed


=n important consideration in designing high*speed stepping motor controllers is the effect of the inductance of the motor windings! =s with the tor6ue versus angular position information, this is fre6uentl$ poorl$ documented in motor data sheets, and indeed, for variable reluctance stepping motors, it is not a constantG +he inductance of the motor winding determines the rise and fall time of the current through the windings! 2hile we might hope for a s6uare*wave plot of current versus time, the inductance forces an e5ponential, as illustrated in 3igure 1!.-C

Figure 2.10

+he details of the current*versus*time function through each winding depend as much on the drive circuitr$ as the$ do on the motor itselfG It is 6uite common for the time constants of these e5ponentials to differ! +he rise time is determined b$ the drive voltage and drive circuitr$, while the fall time depends on the circuitr$ used to dissipate the stored energ$ in the motor winding!

=t low stepping rates, the rise and fall times of the current through the motor windings has little effect on the motor's performance, but at higher speeds, the effect of the inductance of the motor windings is to reduce the available tor6ue, as shown in 3igure 1!..C

Figure 2.11

+he motor's maximum speed is defined as the speed at which the available tor6ue falls to 'ero! Measuring ma5imum speed can be difficult when there are resonance problems, because these cause the tor6ue to drop to 'ero prematurel$! +he cutoff speed is the speed above which the tor6ue begins to fall! 2hen the motor is operating below its cutoff speed, the rise and fall times of the current through the motor windings occup$ an insignificant fraction of each step, while at the cutoff speed, the step duration is comparable to the sum of the rise and fall times! ;ote that a sharp cutoff is rare, and therefore, statements of a motor's cutoff speed are, of necessit$, appro5imate! +he details of the tor6ue versus speed relationship depend on the details of the rise and fall times in the motor windings, and these depend on the motor control s$stem as well as the motor! +herefore, the cutoff speed and ma5imum speed for an$ particular motor depend, in part, on the control s$stemG +he tor6ue versus speed curves published in motor data sheets occasionall$ come with documentation of the motor controller used to obtain that curve, but this is far from universal practiceG Similarl$, the resonant speed depends on the moment of inertia of the entire rotating s$stem, not 4ust the motor rotor, and the e5tent to which the tor6ue drops at resonance depends on the presence of mechanical damping and on the nature of the control s$stem! Some published tor6ue versus speed curves show ver$ clear resonances without documenting the moment of inertia of the hardware that ma$ have been attached to the motor shaft in order to ma#e tor6ue measurements! +he tor6ue versus speed curve shown in 3igure 1!.. is t$pical of the simplest of control s$stems! More comple5 control s$stems sometimes introduce electronic resonances that act to increase the available tor6ue above the motor's low*speed tor6ue! = common result of this is a pea# in the available tor6ue near the cutoff speed!

Electro(agnetic Issues
In a permanent magnet or h$brid stepping motor, the magnetic field of the motor rotor changes with changes in shaft angle! +he result of this is that turning the motor rotor induces an =) voltage in each motor winding! +his is referred to as the counter EMF because the voltage induced in each motor winding is alwa$s in phase with and counter to the ideal waveform re6uired to turn the motor in the same direction! Both the fre6uenc$ and amplitude of the counter :M3 increase with rotor speed, and therefore, counter :M3 contributes to the decline in tor6ue with increased stepping rate!

Variable reluctance stepping motors also induce counter :M3G +his is because, as the stator winding pulls a tooth of the rotor towards its e6uilibrium position, the reluctance of the magnetic circuit declines! +his decline increases the inductance of the stator winding, and this change in inductance demands a decrease in the current through the winding in order to conserve energ$! +his decrease is evidenced as a counter :M3! +he reactance (inductance and resistance of the motor windings limits the current flowing through them! +hus, b$ ohms law, increasing the voltage will increase the current, and therefore increase the available tor6ue! +he increased voltage also serves to overcome the counter :M3 induced in the motor windings, but the voltage cannot be increased arbitraril$G +hermal, magnetic and electronic considerations all serve to limit the useful tor6ue that a motor can produce! +he heat given off b$ the motor windings is due to both simple resistive losses, edd$ current losses, and h$steresis losses! If this heat is not conducted awa$ from the motor ade6uatel$, the motor windings will overheat! +he simplest failure this can cause is insulation brea#down, but it can also heat a permanent magnet rotor to above its curie temperature, the temperature at which permanent magnets lose their magneti'ation! +his is a particular ris# with man$ modern high strength magnetic allo$s! :ven if the motor is attached to an ade6uate heat sin#, increased drive voltage will not necessaril$ lead to increased tor6ue! Most motors are designed so that, with the rated current flowing through the windings, the magnetic circuits of the motor are near saturation! Increased current will not lead to an appreciabl$ increased magnetic field in such a motorG Biven a drive s$stem that limits the current through each motor winding to the rated ma5imum for that winding, but uses high voltages to achieve a higher cutoff tor6ue and higher tor6ues above cutoff, there are other limits that come into pla$! =t high speeds, the motor windings must, of necessit$, carr$ high fre6uenc$ =) signals! +his leads to edd$ current losses in the magnetic circuits of the motor, and it leads to s#in effect losses in the motor windings! Motors designed for ver$ high speed running should, therefore, have magnetic structures using ver$ thin laminations or even nonconductive ferrite materials, and the$ should have small gauge wire in their windings to minimi'e s#in effect losses! )ommon high tor6ue motors have large*gauge motor windings and coarse core laminations, and at high speeds, such motors can easil$ overheat and should therefore be derated accordingl$ for high speed runningG It is also worth noting that the best wa$ to demagneti'e something is to e5pose it to a high fre6uenc$*high amplitude magnetic field! Running the control s$stem to spin the rotor at high speed when the rotor is actuall$ stalled, or spinning the rotor at high speed against a control s$stem tr$ing to hold the rotor in a fi5ed position will both e5pose the rotor to a high amplitude high*fre6uenc$ field! If such operating conditions are common, particularl$ if the motor is run near the curie temperature of the permanent magnets, demagneti'ation is a serious ris# and the field strengths (and e5pected tor6ues should be reduced accordingl$G

,. Stepping Motor -hysics


%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science

Introduction Variable Reluctance Motors Unipolar %ermanent Magnet and 9$brid Motors %ractical Unipolar and Variable Reluctance 7rivers Bipolar Motors and 9*Bridges %ractical Bipolar 7rive )ircuits

Introduction
+his section of the stepper tutorial deals with the basic final stage drive circuitr$ for stepping motors! +his circuitr$ is centered on a single issue, switching the current in each motor winding on and off, and controlling its direction! +he circuitr$ discussed in this section is connected directl$ to the motor windings and the motor power suppl$, and this circuitr$ is controlled b$ a digital s$stem that determines when the switches are turned on or off! +his section covers all t$pes of motors, from the elementar$ circuitr$ needed to control a variable reluctance motor, to the 9*bridge circuitr$ needed to control a bipolar permanent magnet motor! :ach class of drive circuit is illustrated with practical e5amples, but these e5amples are not intended as an e5haustive catalog of the commerciall$ available control circuits, nor is the information given here intended to substitute for the information found on the manufacturer's component data sheets for the parts mentioned! +his section onl$ covers the most elementar$ control circuitr$ for each class of motor! =ll of these circuits assume that the motor power suppl$ provides a drive voltage no greater than the motor's rated voltage, and this significantl$ limits motor performance! +he ne5t section, on current limited drive circuitr$, covers practical high*performance drive circuits!

Variable Reluctance Motors


+$pical controllers for variable reluctance stepping motors are variations on the outline shown in 3igure >!.C

Figure 3.1

In 3igure >!., bo5es are used to represent switchesE a control unit, not shown, is responsible for providing the control signals to open and close the switches at the appropriate times in order to spin the motors! In man$ cases, the control unit will be a computer or programmable interface controller, with software directl$ generating the outputs needed to control the switches, but in other cases, additional control circuitr$ is introduced, sometimes gratuitousl$G Motor windings, solenoids and similar devices are all inductive loads! =s such, the current through the motor winding cannot be turned on or off instantaneousl$ without involving infinite voltagesG 2hen the switch controlling a motor winding is closed, allowing current to flow, the result of this is a slow rise in current! 2hen the switch controlling a motor winding is opened, the result of this is a voltage spi#e that can seriousl$ damage the switch unless care is ta#en to deal with it appropriatel$! +here are two basic wa$s of dealing with this voltage spi#e! <ne is to bridge the motor winding with a diode, and the other is to bridge the motor winding with a capacitor! 3igure >!1 illustrates both approachesC

Figure 3.2

+he diode shown in 3igure >!1 must be able to conduct the full current through the motor winding, but it will onl$ conduct briefl$ each time the switch is turned off, as the current through the winding deca$s! If relativel$ slow diodes such as the common .;?--A famil$ are used together with a fast switch, it ma$ be necessar$ to add a small capacitor in parallel with the diode! +he capacitor shown in 3igure >!1 poses more comple5 design problemsG 2hen the switch is closed, the capacitor will discharge through the switch to ground, and the switch must be able to handle this brief spi#e of discharge current! = resistor in series with the capacitor or in series with the power suppl$ will limit this current! 2hen the switch is opened, the stored energ$ in the motor winding will charge the capacitor up to a voltage significantl$ above the suppl$ voltage, and the switch must be able to tolerate this voltage! +o solve for the si'e of the capacitor, we e6uate the two formulas for the stored energ$ in a resonant circuitC K ! "1 I 1 K # $1 I 1 2hereC ** stored energ$, in watt seconds or coulomb volts ! ** capacit$, in farads " ** voltage across capacitor # ** inductance of motor winding, in henr$s $ ** current through motor winding Solving for the minimum si'e of capacitor re6uired to prevent overvoltage on the switch is fairl$ eas$C ! O # $1 I ("b * "s 1 2hereC "b ** the brea#down voltage of the switch "s ** the suppl$ voltage Variable reluctance motors have variable inductance that depends on the shaft angle! +herefore, worst*case design must be used to select the capacitor! 3urthermore, motor inductances are fre6uentl$ poorl$ documented, if at all!

+he capacitor and motor winding, in combination, form a resonant circuit! If the control s$stem drives the motor at fre6uencies near the resonant fre6uenc$ of this circuit, the motor current through the motor windings, and therefore, the tor6ue e5erted b$ the motor, will be 6uite different from the stead$ state tor6ue at the nominal operating voltageG +he resonant fre6uenc$ isC f K . I ( 1 (# ! -!D =gain, the electrical resonant fre6uenc$ for a variable reluctance motor will depend on shaft angleG 2hen a variable reluctance motors is operated with the e5citing pulses near resonance, the oscillating current in the motor winding will lead to a magnetic field that goes to 'ero at twice the resonant fre6uenc$, and this can severel$ reduce the available tor6ueG

Unipolar -er(anent Magnet and .ybrid Motors


+$pical controllers for unipolar stepping motors are variations on the outline shown in 3igure >!>C
Figure 3.3

In 3igure >!>, as in 3igure >!., bo5es are used to represent switchesE a control unit, not shown, is responsible for providing the control signals to open and close the switches at the appropriate times in order to spin the motors! +he control unit is commonl$ a computer or programmable interface controller, with software directl$ generating the outputs needed to control the switches! =s with drive circuitr$ for variable reluctance motors, we must deal with the inductive #ic# produced when each of these switches is turned off! =gain, we ma$ shunt the inductive #ic# using diodes, but now, ? diodes are re6uired, as shown in 3igure >!?C

Figure 3.4

+he e5tra diodes are re6uired because the motor winding is not two independent inductors, it is a single center*tapped inductor with the center tap at a fi5ed voltage! +his acts as an autotransformerG 2hen one end of the motor winding is pulled down, the other end will fl$ up, and visa versa! 2hen a switch opens, the inductive #ic#bac# will drive that end of the motor winding to the positive suppl$, where it is clamped b$ the diode! +he opposite end will fl$ downward, and if it was not floating at the suppl$ voltage at the time, it will fall below ground, reversing the voltage across the switch at that end! Some switches are immune to such reversals, but others can be seriousl$ damaged! = capacitor ma$ also be used to limit the #ic#bac# voltage, as shown in 3igure >!DC

Figure 3.5

+he rules for si'ing the capacitor shown in 3igure >!D are the same as the rules for si'ing the capacitor shown in 3igure >!1, but the effect of resonance is 6uite differentG 2ith a permanent magnet motor, if the capacitor is driven at or near the resonant fre6uenc$, the tor6ue will increase to

as much as twice the low*speed tor6ueG +he resulting tor6ue versus speed curve ma$ be 6uite comple5, as illustrated in 3igure >!@C

Figure 3.6

3igure >!@ shows a pea# in the available tor6ue at the electrical resonant fre6uenc$, and a valle$ at the mechanical resonant fre6uenc$! If the electrical resonant fre6uenc$ is placed appropriatel$ above what would have been the cutoff speed for the motor using a diode*based driver, the effect can be a considerable increase in the effective cutoff speed! +he mechanical resonant fre6uenc$ depends on the tor6ue, so if the mechanical resonant fre6uenc$ is an$where near the electrical resonance, it will be shifted b$ the electrical resonanceG 3urthermore, the width of the mechanical resonance depends on the local slope of the tor6ue versus speed curveE if the tor6ue drops with speed, the mechanical resonance will be sharper, while if the tor6ue climbs with speed, it will be broader or even split into multiple resonant fre6uencies!

-ractical Unipolar and Variable Reluctance %ri+ers


In the above circuits, the details of the necessar$ switches have been deliberatel$ ignored! =n$ switching technolog$, from toggle switches to power M<S3:+S will wor#G 3igure >!0 contains some suggestions for implementing each switch, with a motor winding and protection diode included for orientation purposesC

Figure 3.7

:ach of the switches shown in 3igure >!0 is compatible with a ++" input! +he D volt suppl$ used for the logic, including the 0?-0 open*collector driver used in the figure, should be well regulated! +he motor power, t$picall$ between D and 1? volts, needs onl$ minimal regulation! It is worth noting that these power switching circuits are appropriate for driving solenoids, 7) motors and other inductive loads as well as for driving stepping motors! +he SP>./- transistor shown in 3igure >!0 is a power darlington with a current gain over .---E thus, the .- milliamps flowing through the ?0- ohm bias resistor is more than enough to allow the

transistor to switch a few amps current through the motor winding! +he 0?-0 buffer used to drive the darlington ma$ be replaced with an$ high*voltage open collector chip that can sin# at least .milliamps! In the event that the transistor fails, the high*voltage open collector driver serves to protects the rest of the logic circuitr$ from the motor power suppl$! +he IR) IR"D?- shown in 3igure >!0 is a power field effect transistor! +his can handle currents of up to about 1- amps, and it brea#s down nondestructivel$ at .-- voltsE as a result, this chip can absorb inductive spi#es without protection diodes if it is attached to a large enough heat sin#! +his transistor has a ver$ fast switching time, so the protection diodes must be comparabl$ fast or b$passed b$ small capacitors! +his is particularl$ essential with the diodes used to protect the transistor against reverse biasG In the event that the transistor fails, the 'ener diode and .-- ohm resistor protect the ++" circuitr$! +he .-- ohm resistor also acts to somewhat slow the switching times on the transistor! 3or applications where each motor winding draws under D-- milliamps, the U";1--5 famil$ of darlington arra$s from =llegro Micros$stems, also available as the 7S1--5 from ;ational Semiconductor and as the Motorola M).?.> darlington arra$ will drive multiple motor windings or other inductive loads directl$ from logic inputs! 3igure >!/ shows the pinout of the widel$ available U";1--> chip, an arra$ of 0 darlington transistors with ++" compatible inputsC

Figure 3.8

+he base resistor on each darlington transistor is matched to standard bipolar ++" outputs! :ach ;%; darlington is wired with its emitter connected to pin /, intended as a ground pin, :ach transistor in this pac#age is protected b$ two diodes, one shorting the emitter to the collector, protecting against reverse voltages across the transistor, and one connecting the collector to pin ,E if pin , is wired to the positive motor suppl$, this diode will protect the transistor against inductive spi#es! +he U";1/-> chip is essentiall$ the same as the U";1--> chip described above, e5cept that it is in an ./*pin pac#age, and contains / darlingtons, allowing one chip to be used to drive a pair of common unipolar permanent*magnet or variable*reluctance motors! 3or motors drawing under @-- milliamps per winding, the U7;1D?0B 6uad power driver made b$ =llegro Micros$stems will handle all ? windings of common unipolar stepping motors! 3or motors drawing under >-- milliamps per winding, +e5as Instruments S;0D?., 0D?1 and 0D?> dual power drivers are a good choiceE both of these alternatives include some logic with the power drivers!

Bipolar Motors and .*Bridges


+hings are more comple5 for bipolar permanent magnet stepping motors because these have no center taps on their windings! +herefore, to reverse the direction of the field produced b$ a motor

winding, we need to reverse the current through the winding! 2e could use a double*pole double throw switch to do this electromechanicall$E the electronic e6uivalent of such a switch is called an 9*bridge and is outlined in 3igure >!,C

Figure 3.9

=s with the unipolar drive circuits discussed previousl$, the switches used in the 9*bridge must be protected from the voltage spi#es caused b$ turning the power off in a motor winding! +his is usuall$ done with diodes, as shown in 3igure >!,! It is worth noting that 9*bridges are applicable not onl$ to the control of bipolar stepping motors, but also to the control of 7) motors, push*pull solenoids (those with permanent magnet plungers and man$ other applications! 2ith ? switches, the basic 9*bridge offers .@ possible operating modes, 0 of which short out the power suppl$G +he following operating modes are of interestC Forward mode, switches = and 7 closed! %everse mode, switches B and ) closed! +hese are the usual operating modes, allowing current to flow from the suppl$, through the motor winding and onward to ground! 3igure >!.- illustrates forward modeC

Figure 3.10

Fast decay mode or coasting mode, all switches open!

=n$ current flowing through the motor winding will be wor#ing against the full suppl$ voltage, plus two diode drops, so current will deca$ 6uic#l$! +his mode provides little or no d$namic bra#ing effect on the motor rotor, so the rotor will coast freel$ if all motor windings are powered in this mode! 3igure >!.. illustrates the current flow immediatel$ after switching from forward running mode to fast deca$ mode!

Figure 3.11

&low decay modes or dynamic braking modes! In these modes, current ma$ recirculate through the motor winding with minimum resistance! =s a result, if current is flowing in a motor winding when one of these modes is entered, the current will deca$ slowl$, and if the motor rotor is turning, it will induce a current that will act as a bra#e on the rotor! 3igure >!.1 illustrates one of the man$ useful slow*deca$ modes, with switch 7 closedE if the motor winding has recentl$ been in forward running mode, the state of switch B ma$ be either open or closedC

Figure 3.12

Most 9*bridges are designed so that the logic necessar$ to prevent a short circuit is included at a ver$ low level in the design! 3igure >!.> illustrates what is probabl$ the best arrangementC

Figure 3.13

9ere, the following operating modes are availableC "BC /0 Mode % --. .---.--. -..fast deca$ for)ard re+erse

..

slow deca$ +he advantage of this arrangement is that all of the useful operating modes are preserved, and the$ are encoded with a minimum number of bitsE the latter is important when using a microcontroller or computer s$stem to drive the 9*bridge because man$ such s$stems have onl$ limited numbers of bits available for parallel output! Sadl$, few of the integrated 9*bridge chips on the mar#et have such a simple control scheme! -.-.

-ractical Bipolar %ri+e Circuits


+here are a number of integrated 9*bridge drivers on the mar#et, but it is still useful to loo# at discrete component implementations for an understanding of how an 9*bridge wor#s! =ntonio Raposo (a4rQc$bill!inesc!pt suggested the 9*bridge circuit shown in 3igure >!.?E

Figure 3.14

+he A and ( inputs to this circuit can be driven b$ open collector ++" outputs as in the darlington* based unipolar drive circuit in 3igure >!0! +he motor winding will be energised if e5actl$ one of the A and ( inputs is high and e5actl$ one of them is low! If both are low, both pull*down transistors will be off! If both are high, both pull*up transistors will be off! =s a result, this simple circuit puts the motor in d$namic bra#ing mode in both the .. and -- states, and does not offer a coasting mode! +he circuit in 3igure >!.? consists of two identical halves, each of which ma$ be properl$ described as a push*pull driver! +he term half 9*bridge is sometimes applied to these circuitsG It is also worth noting that a half 9*bridge has a circuit 6uite similar to the output drive circuit used in ++" logic! In fact, ++" tri*state line drivers such as the 0?"S.1D= and the 0?"S1?? can be used as half 9* bridges for small loads, as illustrated in 3igure >!.DC

Figure 3.15

+his circuit is effective for driving motors with up to about D- ohms per winding at voltages up to about ?!D volts using a D volt suppl$! :ach tri*state buffer in the "S1?? can sin# about twice the current it can source, and the internal resistance of the buffers is sufficient, when sourcing current, to evenl$ divide the current between the drivers that are run in parallel! +his motor drive allows for all of the useful states achieved b$ the driver in 3igure >!.>, but these states are not encoded as efficientl$C /0E Mode fast deca$ slower --deca$ -.for)ard .-re+erse ..- slow deca$ +he second d$namic bra#ing mode, A(:K..-, provides a slightl$ wea#er bra#ing effect than the first because of the fact that the "S1?? drivers can sin# more current than the$ can source! +he Microchip (formerl$ +elcom Semiconductor +)??@0 Ruad )M<S driver is another e5ample of a general purpose driver that can be used as ? independent half 9*bridges! Unli#e earlier drivers, the data sheet for this driver even suggests using it for motor control applicatons, with suppl$ voltages up to ./ volts and up to 1D- milliamps per motor winding! <ne of the problems with commerciall$ available stepping motor control chips is that man$ of them have relativel$ short mar#et lifetimes! 3or e5ample, the Seagate I%5M55 series of dual 9*bridge chips (I%.M.- through I%>M.1 were ver$ well thought out, but unfortunatel$, it appears that Seagate onl$ made these when the$ used stepping motors for head positioning in Seagate dis# drives! +he +oshiba +=010, dual 9*bridge driver would be another another e5cellent choice for motors under . amp, but again, it appears to have been made for internal use onl$! +he SBS*+hompson (and others "1,> dual 9*bridge is a close competitor for the above chips, but unli#e them, it does not include protection diodes! +he "1,>7 chip, introduced later, is pin compatible and includes these diodes! If the earlier "1,> is used, each motor winding must be set across a bridge rectifier (.;?--. e6uivalent ! +he use of e5ternal diodes allows a series resistor to be put in the current recirculation path to speed the deca$ of the current in a motor winding when it is turned offE this ma$ be desirable in some applications! +he "1,> famil$ offers e5cellent choices for driving small bipolar steppers drawing up to one amp per motor winding at up to >@ volts! 3igure >!.@ shows the pinout common to the "1,>B and "1,>7 chipsC **.

Figure 3.16

+his chip ma$ be viewed as ? independent half 9*bridges, enabled in pairs, or as two full 9* bridges! +his is a power 7I% pac#age, with pins ?, D, .1 and .> designed to conduct heat to the %) board or to an e5ternal heat sin#! +he SBS*+hompson (and others "1,/ dual 9*bridge is 6uite similar to the above, but is able to handle up to 1*amps per channel and is pac#aged as a power componentE as with the "S1??, it is safe to wire the two 9*bridges in the "1,/ pac#age into one ?*amp 9*bridge (the data sheet for this chip provides specific advice on how to do this ! <ne warning is appropriate concerning the "1,/E this chip ver$ fast switches, fast enough that commonplace protection diodes (.;?--A e6uivalent don't wor#! Instead, use a diode such as the B(V10! +he ;ational Semiconductor "M7./1-- 9* bridge is another good e5ampleE this handles up to > amps and has integral protection diodes! 2hile integrated 9*bridges are not available for ver$ high currents or ver$ high voltages, there are well designed components on the mar#et to simplif$ the construction of 9*bridges from discrete switches! 3or e5ample, International Rectifier sells a line of half 9*bridge driversE two of these chips plus ? M<S3:+ switching transistors suffice to build an 9*bridge! +he IR1.-., IR1.-1 and IR1.-> are basic half 9*bridge drivers! :ach of these chips has 1 logic inputs to directl$ control the two switching transistors on one leg of an 9*bridge! +he IR1.-? and IR1... have similar output* side logic for controlling the switches of an 9*bridge, but the$ also include input*side logic that, in some applications, ma$ reduce the need for e5ternal logic! In particular, the 1.-? includes an enable input, so that ? 1.-? chips plus / switching transistors can replace an "1,> with no need for additional logic! +he data sheet for the Microchip (formerl$ +elcom Semiconductor +)??@0 famil$ of 6uad )M<S drivers includes information on how to use drivers in this famil$ to drive the power M<S3:+s of 9*bridges running at up to .D volts! = number of manufacturers ma#e comple5 9*bridge chips that include current limiting circuitr$E these are the sub4ect of the ne5t section! It is also worth noting that there are a number of >*phase bridge drivers on the mar#et, appropriate for driving ( or delta configured >*phase permanent magnet steppers! 3ew such motors are available, and these chips were not developed with steppers in mind! ;onetheless, the +oshiba +=01//%, the B"0?>/, the +=/?-- and +=/?-D are clean designs, and 1 such chips, with one of the @ half*bridges ignored, will cleanl$ control a D*winding .- step per revolution motor!

Introduction Variable Reluctance Motors Unipolar %ermanent Magnet and 9$brid Motors %ractical Unipolar and Variable Reluctance 7rivers Bipolar Motors and 9*Bridges %ractical Bipolar 7rive )ircuits

Introduction

+his section of the stepper tutorial deals with the basic final stage drive circuitr$ for stepping motors! +his circuitr$ is centered on a single issue, switching the current in each motor winding on and off, and controlling its direction! +he circuitr$ discussed in this section is connected directl$ to the motor windings and the motor power suppl$, and this circuitr$ is controlled b$ a digital s$stem that determines when the switches are turned on or off! +his section covers all t$pes of motors, from the elementar$ circuitr$ needed to control a variable reluctance motor, to the 9*bridge circuitr$ needed to control a bipolar permanent magnet motor! :ach class of drive circuit is illustrated with practical e5amples, but these e5amples are not intended as an e5haustive catalog of the commerciall$ available control circuits, nor is the information given here intended to substitute for the information found on the manufacturer's component data sheets for the parts mentioned! +his section onl$ covers the most elementar$ control circuitr$ for each class of motor! =ll of these circuits assume that the motor power suppl$ provides a drive voltage no greater than the motor's rated voltage, and this significantl$ limits motor performance! +he ne5t section, on current limited drive circuitr$, covers practical high*performance drive circuits!

Variable Reluctance Motors


+$pical controllers for variable reluctance stepping motors are variations on the outline shown in 3igure >!.C

Figure 3.1

In 3igure >!., bo5es are used to represent switchesE a control unit, not shown, is responsible for providing the control signals to open and close the switches at the appropriate times in order to spin the motors! In man$ cases, the control unit will be a computer or programmable interface controller, with software directl$ generating the outputs needed to control the switches, but in other cases, additional control circuitr$ is introduced, sometimes gratuitousl$G Motor windings, solenoids and similar devices are all inductive loads! =s such, the current through the motor winding cannot be turned on or off instantaneousl$ without involving infinite voltagesG 2hen the switch controlling a motor winding is closed, allowing current to flow, the result of this is a slow rise in current! 2hen the switch controlling a motor winding is opened, the result of this is a voltage spi#e that can seriousl$ damage the switch unless care is ta#en to deal with it appropriatel$! +here are two basic wa$s of dealing with this voltage spi#e! <ne is to bridge the motor winding with a diode, and the other is to bridge the motor winding with a capacitor! 3igure >!1 illustrates both approachesC

Figure 3.2

+he diode shown in 3igure >!1 must be able to conduct the full current through the motor winding, but it will onl$ conduct briefl$ each time the switch is turned off, as the current through the winding deca$s! If relativel$ slow diodes such as the common .;?--A famil$ are used together with a fast switch, it ma$ be necessar$ to add a small capacitor in parallel with the diode! +he capacitor shown in 3igure >!1 poses more comple5 design problemsG 2hen the switch is closed, the capacitor will discharge through the switch to ground, and the switch must be able to handle this brief spi#e of discharge current! = resistor in series with the capacitor or in series with the power suppl$ will limit this current! 2hen the switch is opened, the stored energ$ in the motor winding will charge the capacitor up to a voltage significantl$ above the suppl$ voltage, and the switch must be able to tolerate this voltage! +o solve for the si'e of the capacitor, we e6uate the two formulas for the stored energ$ in a resonant circuitC K ! "1 I 1 K # $1 I 1 2hereC ** stored energ$, in watt seconds or coulomb volts ! ** capacit$, in farads " ** voltage across capacitor # ** inductance of motor winding, in henr$s $ ** current through motor winding Solving for the minimum si'e of capacitor re6uired to prevent overvoltage on the switch is fairl$ eas$C ! O # $1 I ("b * "s 1 2hereC "b ** the brea#down voltage of the switch "s ** the suppl$ voltage Variable reluctance motors have variable inductance that depends on the shaft angle! +herefore, worst*case design must be used to select the capacitor! 3urthermore, motor inductances are fre6uentl$ poorl$ documented, if at all! +he capacitor and motor winding, in combination, form a resonant circuit! If the control s$stem drives the motor at fre6uencies near the resonant fre6uenc$ of this circuit, the motor current through the motor windings, and therefore, the tor6ue e5erted b$ the motor, will be 6uite different from the stead$ state tor6ue at the nominal operating voltageG +he resonant fre6uenc$ isC f K . I ( 1 (# ! -!D =gain, the electrical resonant fre6uenc$ for a variable reluctance motor will depend on shaft angleG 2hen a variable reluctance motors is operated with the e5citing pulses near resonance, the oscillating current in the motor winding will lead to a magnetic field that goes to 'ero at twice the resonant fre6uenc$, and this can severel$ reduce the available tor6ueG

Unipolar -er(anent Magnet and .ybrid Motors


+$pical controllers for unipolar stepping motors are variations on the outline shown in 3igure >!>C

Figure 3.3

In 3igure >!>, as in 3igure >!., bo5es are used to represent switchesE a control unit, not shown, is responsible for providing the control signals to open and close the switches at the appropriate times in order to spin the motors! +he control unit is commonl$ a computer or programmable interface controller, with software directl$ generating the outputs needed to control the switches! =s with drive circuitr$ for variable reluctance motors, we must deal with the inductive #ic# produced when each of these switches is turned off! =gain, we ma$ shunt the inductive #ic# using diodes, but now, ? diodes are re6uired, as shown in 3igure >!?C

Figure 3.4

+he e5tra diodes are re6uired because the motor winding is not two independent inductors, it is a single center*tapped inductor with the center tap at a fi5ed voltage! +his acts as an autotransformerG 2hen one end of the motor winding is pulled down, the other end will fl$ up, and visa versa! 2hen a switch opens, the inductive #ic#bac# will drive that end of the motor winding to the positive suppl$, where it is clamped b$ the diode! +he opposite end will fl$ downward, and if it was not floating at the suppl$ voltage at the time, it will fall below ground, reversing the voltage across the switch at that end! Some switches are immune to such reversals, but others can be seriousl$ damaged! = capacitor ma$ also be used to limit the #ic#bac# voltage, as shown in 3igure >!DC

Figure 3.5

+he rules for si'ing the capacitor shown in 3igure >!D are the same as the rules for si'ing the capacitor shown in 3igure >!1, but the effect of resonance is 6uite differentG 2ith a permanent magnet motor, if the capacitor is driven at or near the resonant fre6uenc$, the tor6ue will increase to as much as twice the low*speed tor6ueG +he resulting tor6ue versus speed curve ma$ be 6uite comple5, as illustrated in 3igure >!@C

Figure 3.6

3igure >!@ shows a pea# in the available tor6ue at the electrical resonant fre6uenc$, and a valle$ at the mechanical resonant fre6uenc$! If the electrical resonant fre6uenc$ is placed appropriatel$ above what would have been the cutoff speed for the motor using a diode*based driver, the effect can be a considerable increase in the effective cutoff speed! +he mechanical resonant fre6uenc$ depends on the tor6ue, so if the mechanical resonant fre6uenc$ is an$where near the electrical resonance, it will be shifted b$ the electrical resonanceG 3urthermore, the width of the mechanical resonance depends on the local slope of the tor6ue versus speed curveE if the tor6ue drops with speed, the mechanical resonance will be sharper, while if the tor6ue climbs with speed, it will be broader or even split into multiple resonant fre6uencies!

-ractical Unipolar and Variable Reluctance %ri+ers


In the above circuits, the details of the necessar$ switches have been deliberatel$ ignored! =n$ switching technolog$, from toggle switches to power M<S3:+S will wor#G 3igure >!0 contains some suggestions for implementing each switch, with a motor winding and protection diode included for orientation purposesC

Figure 3.7

:ach of the switches shown in 3igure >!0 is compatible with a ++" input! +he D volt suppl$ used for the logic, including the 0?-0 open*collector driver used in the figure, should be well regulated! +he motor power, t$picall$ between D and 1? volts, needs onl$ minimal regulation! It is worth noting that these power switching circuits are appropriate for driving solenoids, 7) motors and other inductive loads as well as for driving stepping motors! +he SP>./- transistor shown in 3igure >!0 is a power darlington with a current gain over .---E thus, the .- milliamps flowing through the ?0- ohm bias resistor is more than enough to allow the transistor to switch a few amps current through the motor winding! +he 0?-0 buffer used to drive the darlington ma$ be replaced with an$ high*voltage open collector chip that can sin# at least .milliamps! In the event that the transistor fails, the high*voltage open collector driver serves to protects the rest of the logic circuitr$ from the motor power suppl$! +he IR) IR"D?- shown in 3igure >!0 is a power field effect transistor! +his can handle currents of up to about 1- amps, and it brea#s down nondestructivel$ at .-- voltsE as a result, this chip can absorb inductive spi#es without protection diodes if it is attached to a large enough heat sin#! +his transistor has a ver$ fast switching time, so the protection diodes must be comparabl$ fast or b$passed b$ small capacitors! +his is particularl$ essential with the diodes used to protect the transistor against reverse biasG In the event that the transistor fails, the 'ener diode and .-- ohm resistor protect the ++" circuitr$! +he .-- ohm resistor also acts to somewhat slow the switching times on the transistor! 3or applications where each motor winding draws under D-- milliamps, the U";1--5 famil$ of darlington arra$s from =llegro Micros$stems, also available as the 7S1--5 from ;ational Semiconductor and as the Motorola M).?.> darlington arra$ will drive multiple motor windings or other inductive loads directl$ from logic inputs! 3igure >!/ shows the pinout of the widel$ available U";1--> chip, an arra$ of 0 darlington transistors with ++" compatible inputsC

Figure 3.8

+he base resistor on each darlington transistor is matched to standard bipolar ++" outputs! :ach ;%; darlington is wired with its emitter connected to pin /, intended as a ground pin, :ach transistor in this pac#age is protected b$ two diodes, one shorting the emitter to the collector, protecting against reverse voltages across the transistor, and one connecting the collector to pin ,E if pin , is wired to the positive motor suppl$, this diode will protect the transistor against inductive spi#es! +he U";1/-> chip is essentiall$ the same as the U";1--> chip described above, e5cept that it is in an ./*pin pac#age, and contains / darlingtons, allowing one chip to be used to drive a pair of common unipolar permanent*magnet or variable*reluctance motors! 3or motors drawing under @-- milliamps per winding, the U7;1D?0B 6uad power driver made b$ =llegro Micros$stems will handle all ? windings of common unipolar stepping motors! 3or motors drawing under >-- milliamps per winding, +e5as Instruments S;0D?., 0D?1 and 0D?> dual power drivers are a good choiceE both of these alternatives include some logic with the power drivers!

Bipolar Motors and .*Bridges


+hings are more comple5 for bipolar permanent magnet stepping motors because these have no center taps on their windings! +herefore, to reverse the direction of the field produced b$ a motor winding, we need to reverse the current through the winding! 2e could use a double*pole double throw switch to do this electromechanicall$E the electronic e6uivalent of such a switch is called an 9*bridge and is outlined in 3igure >!,C

Figure 3.9

=s with the unipolar drive circuits discussed previousl$, the switches used in the 9*bridge must be protected from the voltage spi#es caused b$ turning the power off in a motor winding! +his is usuall$ done with diodes, as shown in 3igure >!,! It is worth noting that 9*bridges are applicable not onl$ to the control of bipolar stepping motors, but also to the control of 7) motors, push*pull solenoids (those with permanent magnet plungers and man$ other applications! 2ith ? switches, the basic 9*bridge offers .@ possible operating modes, 0 of which short out the power suppl$G +he following operating modes are of interestC Forward mode, switches = and 7 closed! %everse mode, switches B and ) closed! +hese are the usual operating modes, allowing current to flow from the suppl$, through the motor winding and onward to ground! 3igure >!.- illustrates forward modeC

Figure 3.10

Fast decay mode or coasting mode, all switches open! =n$ current flowing through the motor winding will be wor#ing against the full suppl$ voltage, plus two diode drops, so current will deca$ 6uic#l$! +his mode provides little or no d$namic bra#ing effect on the motor rotor, so the rotor will coast freel$ if all motor windings are powered in this mode! 3igure >!.. illustrates the current flow immediatel$ after switching from forward running mode to fast deca$ mode!

Figure 3.11

&low decay modes or dynamic braking modes! In these modes, current ma$ recirculate through the motor winding with minimum resistance! =s a result, if current is flowing in a motor winding when one of these modes is entered, the current will deca$ slowl$, and if the motor rotor is turning, it will induce a current that will act as a bra#e on the rotor! 3igure >!.1 illustrates one of the man$ useful slow*deca$ modes, with switch 7 closedE if the motor winding has recentl$ been in forward running mode, the state of switch B ma$ be either open or closedC

Figure 3.12

Most 9*bridges are designed so that the logic necessar$ to prevent a short circuit is included at a ver$ low level in the design! 3igure >!.> illustrates what is probabl$ the best arrangementC

Figure 3.13

9ere, the following operating modes are availableC "BC /0 Mode % --. .fast deca$ for)ard re+erse slow .. -.-. deca$ +he advantage of this arrangement is that all of the useful operating modes are preserved, and the$ are encoded with a minimum number of bitsE the latter is important when using a microcontroller or computer s$stem to drive the 9*bridge because man$ such s$stems have onl$ limited numbers of bits available for parallel output! Sadl$, few of the integrated 9*bridge chips on the mar#et have such a simple control scheme! ---.--. -..-

-ractical Bipolar %ri+e Circuits


+here are a number of integrated 9*bridge drivers on the mar#et, but it is still useful to loo# at discrete component implementations for an understanding of how an 9*bridge wor#s! =ntonio Raposo (a4rQc$bill!inesc!pt suggested the 9*bridge circuit shown in 3igure >!.?E

Figure 3.14

+he A and ( inputs to this circuit can be driven b$ open collector ++" outputs as in the darlington* based unipolar drive circuit in 3igure >!0! +he motor winding will be energised if e5actl$ one of the A and ( inputs is high and e5actl$ one of them is low! If both are low, both pull*down transistors will be off! If both are high, both pull*up transistors will be off! =s a result, this simple circuit puts

the motor in d$namic bra#ing mode in both the .. and -- states, and does not offer a coasting mode! +he circuit in 3igure >!.? consists of two identical halves, each of which ma$ be properl$ described as a push*pull driver! +he term half 9*bridge is sometimes applied to these circuitsG It is also worth noting that a half 9*bridge has a circuit 6uite similar to the output drive circuit used in ++" logic! In fact, ++" tri*state line drivers such as the 0?"S.1D= and the 0?"S1?? can be used as half 9* bridges for small loads, as illustrated in 3igure >!.DC

Figure 3.15

+his circuit is effective for driving motors with up to about D- ohms per winding at voltages up to about ?!D volts using a D volt suppl$! :ach tri*state buffer in the "S1?? can sin# about twice the current it can source, and the internal resistance of the buffers is sufficient, when sourcing current, to evenl$ divide the current between the drivers that are run in parallel! +his motor drive allows for all of the useful states achieved b$ the driver in 3igure >!.>, but these states are not encoded as efficientl$C /0E Mode fast deca$ slower --deca$ -.for)ard .-re+erse ..- slow deca$ +he second d$namic bra#ing mode, A(:K..-, provides a slightl$ wea#er bra#ing effect than the first because of the fact that the "S1?? drivers can sin# more current than the$ can source! +he Microchip (formerl$ +elcom Semiconductor +)??@0 Ruad )M<S driver is another e5ample of a general purpose driver that can be used as ? independent half 9*bridges! Unli#e earlier drivers, the data sheet for this driver even suggests using it for motor control applicatons, with suppl$ voltages up to ./ volts and up to 1D- milliamps per motor winding! <ne of the problems with commerciall$ available stepping motor control chips is that man$ of them have relativel$ short mar#et lifetimes! 3or e5ample, the Seagate I%5M55 series of dual 9*bridge chips (I%.M.- through I%>M.1 were ver$ well thought out, but unfortunatel$, it appears that Seagate onl$ made these when the$ used stepping motors for head positioning in Seagate dis# drives! +he +oshiba +=010, dual 9*bridge driver would be another another e5cellent choice for motors under . amp, but again, it appears to have been made for internal use onl$! +he SBS*+hompson (and others "1,> dual 9*bridge is a close competitor for the above chips, but unli#e them, it does not include protection diodes! +he "1,>7 chip, introduced later, is pin **.

compatible and includes these diodes! If the earlier "1,> is used, each motor winding must be set across a bridge rectifier (.;?--. e6uivalent ! +he use of e5ternal diodes allows a series resistor to be put in the current recirculation path to speed the deca$ of the current in a motor winding when it is turned offE this ma$ be desirable in some applications! +he "1,> famil$ offers e5cellent choices for driving small bipolar steppers drawing up to one amp per motor winding at up to >@ volts! 3igure >!.@ shows the pinout common to the "1,>B and "1,>7 chipsC

Figure 3.16

+his chip ma$ be viewed as ? independent half 9*bridges, enabled in pairs, or as two full 9* bridges! +his is a power 7I% pac#age, with pins ?, D, .1 and .> designed to conduct heat to the %) board or to an e5ternal heat sin#! +he SBS*+hompson (and others "1,/ dual 9*bridge is 6uite similar to the above, but is able to handle up to 1*amps per channel and is pac#aged as a power componentE as with the "S1??, it is safe to wire the two 9*bridges in the "1,/ pac#age into one ?*amp 9*bridge (the data sheet for this chip provides specific advice on how to do this ! <ne warning is appropriate concerning the "1,/E this chip ver$ fast switches, fast enough that commonplace protection diodes (.;?--A e6uivalent don't wor#! Instead, use a diode such as the B(V10! +he ;ational Semiconductor "M7./1-- 9* bridge is another good e5ampleE this handles up to > amps and has integral protection diodes! 2hile integrated 9*bridges are not available for ver$ high currents or ver$ high voltages, there are well designed components on the mar#et to simplif$ the construction of 9*bridges from discrete switches! 3or e5ample, International Rectifier sells a line of half 9*bridge driversE two of these chips plus ? M<S3:+ switching transistors suffice to build an 9*bridge! +he IR1.-., IR1.-1 and IR1.-> are basic half 9*bridge drivers! :ach of these chips has 1 logic inputs to directl$ control the two switching transistors on one leg of an 9*bridge! +he IR1.-? and IR1... have similar output* side logic for controlling the switches of an 9*bridge, but the$ also include input*side logic that, in some applications, ma$ reduce the need for e5ternal logic! In particular, the 1.-? includes an enable input, so that ? 1.-? chips plus / switching transistors can replace an "1,> with no need for additional logic! +he data sheet for the Microchip (formerl$ +elcom Semiconductor +)??@0 famil$ of 6uad )M<S drivers includes information on how to use drivers in this famil$ to drive the power M<S3:+s of 9*bridges running at up to .D volts! = number of manufacturers ma#e comple5 9*bridge chips that include current limiting circuitr$E these are the sub4ect of the ne5t section! It is also worth noting that there are a number of >*phase bridge drivers on the mar#et, appropriate for driving ( or delta configured >*phase permanent magnet steppers! 3ew such motors are available, and these chips were not developed with steppers in mind! ;onetheless, the +oshiba +=01//%, the B"0?>/, the +=/?-- and +=/?-D are clean

designs, and 1 such chips, with one of the @ half*bridges ignored, will cleanl$ control a D*winding .- step per revolution motor!

1. Current 'i(iting for Stepping Motors


%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science

Introduction Resistive )urrent "imiters "inear )urrent "imiters <pen "oop Solutions * Use of a Voltage Boost * Use of %ulse 2idth Modulation <ne*Shot 3eedbac# )urrent "imiting * %ractical :5amples 9$steresis 3eedbac# )urrent "imiting * %ractical :5amples <ther )urrent Sensing +echnologies

Introduction
Small stepping motors, such as those used for head positioning on flopp$ dis# drives, are usuall$ driven at a low 7) voltage, and the current through the motor windings is usuall$ limited b$ the internal resistance of the winding! 9igh tor6ue motors, on the other hand, are fre6uentl$ built with ver$ low resistance windingsE when driven b$ an$ reasonable suppl$ voltage, these motors t$picall$ re6uire e5ternal current limiting circuitr$! +here is good reason to run a stepping motor at a suppl$ voltage above that needed to push the ma5imum rated current through the motor windings! Running a motor at higher voltages leads to a faster rise in the current through the windings when the$ are turned on, and this, in turn, leads to a higher cutoff speed for the motor and higher tor6ues at speeds above the cutoff! Microstepping, where the control s$stem positions the motor rotor between half steps, also re6uires e5ternal current limiting circuitr$! 3or e5ample, to position the rotor .I? of the wa$ from one step to another, it might be necessar$ to run one motor winding at full current while the other is run at appro5imatel$ .I> of that current! +he remainder of this section discusses various circuits for limiting the current through the windings of a stepping motor, starting with simple resistive limiters and moving up to choppers and other switching regulators! Most of these current limiters are appropriate for man$ other applications, including limiting the current through conventional 7) motors and other inductive loads!

Resisti+e Current 'i(iters

+he easiest to understand current limiter is a series resistor! Most motor manufacturers recommended this approach in their literature up until the earl$ .,/-'s, and most motor data sheets still give performance curves for motors driven b$ such circuits! +he t$pical circuits used to control the current through one winding of a permanent magnet or h$brid motor are shown in 3igure ?!.!

Figure 4.1

R. in this figure limits the current through the motor winding! Biven a rated current of I and a motor winding with a resistance Rw, <hm's law sets the ma5imum suppl$ voltage as I(RwFR. ! Biven that the inductance of the motor motor winding is "w, the time constant for the motor winding will be "wI(RwFR. ! 3igure ?!1 illustrates the effect of increasing the resistance and the operating voltage on the rise and fall times of the current through one winding of a stepping motor!

Figure 4.2

R1 is shown onl$ in the unipolar e5ample in 3igure ?!. because it is particularl$ useful there! 3or a bipolar 9*bridge drive, when all switches are turned off, current flows from ground to the motor suppl$ through R., so the current through the motor winding will deca$ 6uite 6uic#l$! In the unipolar case, R1 is necessar$ to e6ual this performance! ;oteC 2hen the switches in the 9*bridge circuit shown in 3igure ?!. are opened, the direction of current flow through R. will reverse almost instantaneousl$G If R. has an$ inductance, for e5ample, if it is wire*wound, it must either be b$passed with a capacitor to handle the voltage #ic# caused b$ this current reversal, or R1 must be added to the 9*bridge! Biven the rated ma5imum current through each winding and the suppl$ voltage, the resistance and wattage of R. is eas$ to compute! R1 if it is included, poses more interesting problems! +he resistance of R1 depends on the ma5imum voltage the switches can handle! 3or e5ample, if the suppl$ voltage is 1? volts, and the switches are rated at 0D volts, the drop across R1 can be as much as D. volts without harming the transistors! Biven an operating current of .!D amps, R1 can be a >? ohm resistor! ;ote that an interesting alternative is to use a 'ener diode in place of R1! 3iguring the pea# average power R1 must dissipate is a wonderful e5ercise in d$namicsE the inductance of the motor windings is fre6uentl$ undocumented and ma$ var$ with the rotor position! +he power dissapated in R1 also depends on the control s$stem! +he worst case occurs when the control s$stem chops the power to one winding at a high enough fre6uenc$ that the current through

the motor winding is effectivel$ constantE the ma5imum power is then a function of the dut$ c$cle of the chopper and the ratios of the resistances in the circuit during the on and off phases of the chopper! Under normal operating conditions, the pea# power dissipation will be significantl$ lower!

'inear Current 'i(iters


= pair of high wattage power resistors can cost more than a pair of power transistors plus a heat sin#, particularl$ if forced air cooling is available! 3urthermore, a transistori'ed constant current source, as shown in 3igure ?!>, will give faster rise times through the motor windings than the current limiting resistor shown in 3igure ?!.! +his is because a current source will deliver the full suppl$ voltage across the motor winding until the current reaches the rated currentE onl$ then will the current source drop the voltage!

Figure 4.3

In 3igure ?!>, a transistori'ed current source (+. plus R. has been substituted for the current limiting resistor R. used in the e5amples in 3igure ?!.! +he regulated voltage supplied to the base of +. serves to regulate the voltage across the sense resistor R., and this, in turn, maintains a constant current through R. so long as an$ current is allowed to flow through the motor winding! +$picall$, R. will have as low a resistance as possible, in order to avoid the high cost of a power resistor! 3or e5ample, if the forward voltage drops across the diode in series with the base +. and VB: for +. are both -!@D volts, and if a >!> volt 'ener diode is used for a reference, the voltage across R. will be maintained at about 1!- volts, so if R. is 1 ohms, this circuit will limit the current to . amp, and R. must be able to handle 1 watts! R> in 3igure ?!> must be si'ed in terms of the current gain of +. so that sufficient current flows through R. and R> to allow +. to conduct the full rated motor current! +he transistor +. used as a current regulator in 3igure ?!> is run in linear mode, and therfore, it must dissapate 6uite a bit of power! 3or e5ample, if the motor windings have a resistance of D ohms and a rated current of . amp, and a 1D volt power suppl$ is used, +. plus R. will dissapate, between them, 1- wattsG +he circuits discussed in the following sections avoid this waste of power while retaining the performance advantages of the circuit given here! 2hen an 9*bridge bipolar drive is used with a resistive current limiter, as shown in 3igure ?!., the resistor R1 was not needed because current could flow bac#wards through R.! 2hen a transistori'ed current limiter is used, current cannot flow bac#wards through +., so a separate current path bac# to

the positive suppl$ must be provided to handle the deca$ing current through the motor windings when the switches are opened! R1 serves this purpose here, but a 'ener diode ma$ be substituted to provide even faster turn*off! +he performance of a motor run with a current limited power suppl$ is noticabl$ better than the performance of the same motor run with a resistivel$ limited suppl$, as illustrated in 3igure ?!?C

Figure 4.4

2ith either a current limited suppl$ or a resistive current limiter, the initial rate of increase of the current through the inductive motor winding when the power is turned on depends onl$ on the inductance of the winding and the suppl$ voltage! =s the current increases, the voltage drop across a resistive current limiter will increase, dropping the voltage applied to the motor winding, and therefore, dropping the rate of increase of the current through the winding! =s a result, the current will onl$ approach the rated current of the motor winding as$mptoticall$ In contrast, with a pure current limiter, the current through the motor winding will increase almost linearl$ until the current limiter cuts in, allowing the current to reach the limit value 6uite 6uic#l$! In fact, the current rise is not linearE rather, the current rises as$mptoticall$ towards a limit established b$ the resistance of the motor winding and the resistance of the sense resistor in the current limiter! +his ma5imum is usuall$ well above the rated current for the motor winding!

$pen 'oop Current 'i(iters


Both the resistive and the linear transistori'ed current limiters discussed above automaticall$ limit the current through the motor winding, but at a considerable cost, in terms of wasted heat! +here are two schemes that eliminate this e5pense, although at some ris# because of the lac# of feebac# about the current through the motor!

Use of a oltage !oost


If $ou plot the voltage across the motor winding as a function of time, assuming the use of a transistori'ed current limiter such as is illustrated in 3igure ?!>, and assuming a . amp D ohm motor winding, the result will be something li#e that illustrated in 3igure ?!DC

Figure 4.5

=s long as the current is below the current limiter's set point, almost the full suppl$ voltage is applied across the motor winding! <nce the current reaches the set point, the voltage across the motor winding falls to that needed to sustain the current at the set point, and when the switches open, the voltage reverses briefl$ as current flows through the diode networ# and R1! =n alternative wa$ to get this voltage profile is to use a dual*voltage power suppl$, turning on the high voltage for as long as it ta#es to bring the current in the motor winding up to the rated current, and then turning off the high voltage and turning on the sustaining voltage! Some motor controllers do this directl$, without monitoring the current through the motor windings! +his provides e5cellent performance and minimi'es power losses in the regulator, but it offers a dangerous temptation! If the motor does not deliver enough tor6ue, it is tempting to simpl$ lengthen the high*voltage pulse at the time the motor winding is turned on! +his will usuall$ provide more tor6ue, although saturation of the magnetic circuits fre6uentl$ leads to less tor6ue than might be e5pected, but the cost is highG +he ris# of burning out the motor is 6uite real, as is the ris# of demagniti'ing the motor rotor if it is turned against the imposed field while running hot! +herefore, if a dual*voltage suppl$ is used, the temptation to raise the tor6ue in this wa$ should be avoidedG +he problems with dual voltage supplies are particularl$ serious when the time intervals are under software control, because in this case, it is common for the software to be written b$ a programmer who is insufficientl$ aware of the ph$sical and electrical characteristics of the control s$stem!

Use of "ulse #idth Modulation


=nother alternative approach to controlling the current through the motor winding is to use a simple power suppl$ controlled b$ pulse width modulaton (%2M or b$ a chopper! 7uring the time the current through the motor winding is increasing, the control s$stem leaves the suppl$ attached with a .--L dut$ c$cle! <nce the current is up to the full rated current, the control s$stem changes the dut$ c$cle to that re6uired to maintain the current! 3igure ?!@ illustrates this schemeC

Figure 4.6

3or an$ chopper or pulse width modulator, we can define the dut$*c$cle 7 as the fraction of each c$cle that the switch is closedC 7 K +on I (+on F +off 2here +on ** time the switch is closed during each c$cle +off ** time the switch is open during each c$cle +he voltage curve shown above indicates the full suppl$ voltage being applied to the motor winding during the on*phase of ever$ chopper c$cle, while when the chopper is off, a negative voltage is shown! +his is the result of the forward voltage drop in the diodes that are used to shunt the current when the switches turn off, plus the e5ternal resistance used to speed the deca$ of the current through the motor winding! 3or large values of +on or +off, the e5ponential nature of the rise and fall of the current through the motor winding is significant, but for sufficientl$ small values, we can appro5imate these as linear! =ssuming that the chopper is wor#ing to maintain a current of I and that the amplitude is small, we will appro5imate the rates of rise and fall in the current in terms of the voltage across the motor winding when the switch is closed and when it is openC Von K Vsuppl$ * I(Rwinding F Ron Voff K Vdiode F I(Rwinding F Roff 9ere, we lump together all resistances in series with the winding and power suppl$ in the on state as Ron, and we lump together all resistances in the current recirculation path when the switch(es are open as Roff! +he forward voltage drops of an$ diodes in the current recirculation path have been lumped as VdiodeE if the off*state recirculation path runs from ground to the power suppl$ (9*bridge fast deca$ mode , the suppl$ voltage must also be included in Vdiode! 3orward voltage drops of an$ switches in the on*state and off*state paths should also be incorporated into these voltages! +o solve for the dut$ c$cle, we first note thatC dIIdt K VI" 2here I ** current through the motor winding V ** voltage across the winding " ** inductance of the winding 2e then substitute the specific voltages for each phase of operationC Iripple I +off K Voff I " Iripple I +on K Von I " 2here Iripple ** the pea# to pea# ripple in the current

Solving for +off and +on and then substituting these into the definition of the dut$ c$cle of the chopper, we getC 7 K +on I (+on F +off K Voff I (Von F Voff If the forward voltage drops in diodes and switches are negligable, and if the onl$ significant resistance is that of the motor winding itself, this simplifies toC 7 K I Rwinding I Vsuppl$ K Vrunning I Vsuppl$ +his special case is particularl$ desirable because it delivers all of the power to the motor winding, with no losses in the regulation s$stem, without regard for the difference between the suppl$ voltage and the running voltage! +he =) ripple Iripple superimposed on the running current b$ a chopper can be a source of problemsE at high fre6uencies, it can be a source of R3 emissions, and at audio fre6uencies, it can be a source of anno$ing noise! 3or e5ample, with audio fre6uenc$ chopping, most stepper controlled s$stems will &s6ueel&, sometimes loudl$, when the rotor is displaced from the e6uilibrium position! 3or small s$stems, this is usuall$ no more than a minor nuisance, but in s$stems with large numbers of high power steppers, the ripple currents can induce dangerous =) voltages on nearb$ signal lines and dangerous currents in nearb$ ground lines! +o find the ripple amplitude, first recall thatC Iripple I +off K Voff I " +hen solve for IrippleC Iripple K +off Voff I " +hus, to reduce the ripple amplitude at an$ particular dut$ c$cle, it is necessar$ to increase the chopper fre6uenc$! +his cannot be done without limit because switching losses increase with fre6uenc$! ;ote that this change has no significant effect on =) lossesE the decrease in such losses due to decreased amplitude in the ripple is generall$ offset b$ the effect of increasing fre6uenc$! +he primar$ problem with use of a simple chopping or pulse*width modulation control scheme is that it is completel$ open loop! 7esign of good chopper based control s$stems re6uires #nowledge of motor characteristics such as inductance that are fre6uentl$ poorl$ documented, and as with dual* voltage supplies, when motor performance is marginal, it is ver$ tempting to increase the dut$*c$cle without attention to the long*term effects of this on the motor! In the designs that follow, this wea#ness will be addressed b$ introducing feedbac# loops into the low level drive s$stem to directl$ monitor the current and determine the dut$ c$cle!

$ne*Shot #eedbac2 Current 'i(iting


+he most common approach to automaticall$ ad4usting the dut$ c$cle of the switches in the stepper driver involves monitoring the current to the motor windingsE when it rises too high, the winding is turned off for a fi5ed interval! +his re6uires a current sensing s$stem and a one*shot, as illustrated in 3igure ?!0C

Figure 4.7

3igure ?!0 illustrates a unipolar drive s$stem! =s with the circuit given in 3igure ?!>, R. should be as small as possible, limited onl$ b$ the re6uirement that the sense voltage provided to the comparator must be high enough to be within its operating range! ;ote that when the one*shot output (SR is low, the voltage across R. no*longer reflects the current through the motor winding! +herefore, the one*shot must be insensitive to the output of the comparator between the time it fires and the time it resets! %ractical circuit designs using this approach involve some comple5it$ to meet this constraintG Selecting the value of R1 for the circuit shown in 3igure ?!0 poses problems! If R1 is large, the current through the motor windings will deca$ 6uic#l$ when the higher level control s$stem turns off this motor winding, but when the winding is turned on, the current ripple will be large and the power lost in R1 will be significant! If R1 is small, this circuit will be ver$ energ$ efficient but the current through the motor winding will deca$ onl$ slowl$ when this winding is turned off, and this will reduce the cutoff speed for the motor! +he pea# power dissapated in R1 will be I1R1 during +off and 'ero during +onE thus, the average power dissapated in R1 when the motor winding is on will beC %1 K I1R +off I (+on F +off Recall that the dut$ c$cle 7 is defined as +onI(+onF+off and ma$ be appro5imated as VrunningIVsuppl$! =s a result, we can appro5imate the power dissapation asC %1 K I1R1 (. * VrunningIVsuppl$ ! Biven the usual safet$ margins used in selecting power resistor wattages, a better appro5imation is not necessar$! 2hen designing a control s$stem based on pulse width modulation, note that the cutoff time for the one*shot determines +off, and that this is fi5ed, determined b$ the timing networ# attached to the one*shot! Ideall$, this should be set as followsC +off K " Iripple I Voff +his presumes that the inductance " of the motor winding is #nown, that the acceptable magnitude of Iripple is #nown, and that Voff, the total reverse voltage in the current recirculation path, is #nown and fi5ed! ;ote that this scheme leads to a variable chopping rate! =s with the linear current limiters shown in 3igure ?!>, the full suppl$ voltage will be applied during the turn*on phase, and the chopping action onl$ begins when the motor winding reaches the current limit set b$ Vref! +his circuit will var$ the

chopping rate to compensate for changes in the bac# :M3 of the motor winding, for e5ample, those caused b$ rotor motionE in this regard, it offers the same 6ualit$ of regulation as the linear current limiter! +he one*shot current regulator shown in 3igure ?!0 can also be applied to an 9*bridge regulator! +he encoded 9*bridge shown in 3igure >!.> is an e5cellent candidate for this application, as shown in 3igure ?!/C

Figure 4.8

Unli#e the circuit in 3igure ?!0, this circuit does not provide design tradeoffs in the selection of the resistance in the current deca$ pathE instead, it offers the same selection of deca$ paths as was available in the original circuit from 3igure >!.>! If the A and ( control inputs are held in a running mode (-. or .- , the current limiter will alternate between that running and slow deca$ modes, ma5imi'ing energ$ efficienc$! 2hen the time comes to turn off the current through the motor winding, the A and ( inputs ma$ be set to --, using fast deca$ mode to ma5imi'e the cutoff speed, while if the damping effect of d$namic bra#ing is needed to control resonance, A and ( ma$ be set to ..! ;ote that the current recirculation path during d$namic bra#ing does not pass through R., and as a result, if the motor generates a large amount of power, burnt out components in the motor or controller are li#el$! +his is unli#el$ to cause problems with stepping motors, but when d$namic bra#ing is used with 7) motors, the current limiter should be arranged to remain engaged while in bra#ing modeG

"ractical $%a&ples
SBS*+hompson (and others "1,> (.= and "1,/ (1= dual 9*bridges are designed for eas$ use with partial feedbac# current limiters! +hese chips have enable inputs for each 9*bridge that can be directl$ connected to the output of the one*shot, and the$ have ground connections for motor*power that are isolated from their logic ground connectionsE this allows sense resistors to be easil$ incorporated into the circuit! +he >,D1 9*bridge from =llegro Micros$stems can handle up to 1*amps at D- volts and incorporates all of the logic necessar$ for current control, including comparators and one*shot! +his chip is available in man$ pac#age st$lesE 3igure ?!, illustrates the 7I% configuration wired for a constant current limitC

Figure 4.9

If Rt is 1- Pohm, and )t is .---p3, +off for the pulse*width modulation will be fi5ed at 1- (T1 microseconds! +he >,D1 chip incorporates a .- to . voltage divider on the Vref input, so attaching Vref to the D volt logic suppl$ sets the actual reference voltage to -!D V! +hus, if the sense resistor Rs is -!D ohms, this arrangement will attempt to maintain a regulated current through the load of . =! ;ote that all power switching chips are potentiall$ serious sources of electromagnetic interfenceG +he ?0N3 capacitor shown between the motor power and ground should be as close to the chip as possible, and the path from the S:;S: pin through Rs to ground and bac# to a ground pin of the chip should be ver$ short and with a ver$ low resistance! <n the D volt side, because Vref is ta#en from Vcc, a small decoupling capacitor should be placed ver$ close to the chip! It ma$ even be appropriate to isolate the Vref input from Vcc with a small series resistor and a separate decoupling capacitor! If this is done, note that the resistance from the Vref pin to ground through the chip's internal voltage divider is around D- Pohms! <ne of the more disma$ing features of the >,D1 chip, as well as man$ of its competitors, is the large number of control inputs! +hese are summari'ed in the following tableC BR"!E . . . . . . E&"B' -."S M$% E E E * * . . * * * * . . . . . . $U Ta * * . . $U Tb * * . . &otes Bra#e "imited Bra#e Standb$ Sleep Reverse, Slow Reverse, 3ast 3orward, Slow 3orward, 3ast

In the forward and reverse running modes, the mode input determines whether fast or slow deca$ modes are used during +off! In the d$namic bra#ing modes, the mode input determines whether the current limiter is enabled! +his is of limited value with stepping motors, but use of d$namic bra#ing without a current limiter can be dangerous with 7) motors! In sleep mode, the power consumption of the chip is minimi'ed! 3rom the perspective of the load, sleep and standb$ modes put the load into fast deca$ mode (all switches off but in sleep mode, the chip draws considerabl$ less power, both from the logic suppl$ and the motor suppl$!

.ysteresis #eedbac2 Current 'i(iting


In man$ cases, motor control s$stems are e5pected to operate acceptabl$ with a number of different stepping motors! +he one*shot based current regulators illustrated in 3igures ?!0 to ?!, have an accurac$ that depends on the inductance of the motor windings! +herefore, if fi5ed accurac$ is re6uired, an$ motor substition must be balanced b$ changes to the R) networ# that determines the off*time of the one*shot! +his section deals with alternative designs that eliminate the need for this tuning! +hese alternative designs offer fi5ed precision current regulation over a wide range of load inductances! +he #e$ to this approach is arrange the recirculation paths so that the current*sense resistor R. is alwa$s in the circuit, and then turn the switches on or off depending onl$ on the current! +he usual$ wa$ to build this t$pe of controller is to use a comparator with a degree of h$steresis, for e5ample, b$ feeding the output of the comparator bac# into one of its inputs through a resistor networ#, as illustrated in 3igure ?!.-C

Figure 4.10

+o compute the desired values of R1 and R>, we note thatC Vripple O Vh$steresis 2hereC Vripple K Iripple R. Iripple ** the ma5imum ripple allowed in the current andC Vh$steresis K Vswing R1 I (R1 F R> Vswing ** the voltage swing at the output of the comparator 2e can solve this for the ratio of the resistancesC R1 I (R1 F R> U Iripple R. I Vswing

3or e5ample, if R. is -!D ohms and we wish to regulate the current to within .- milliamps, using a comparator with ++" compatable outputs and a voltage swing of ? volts, the ratio must be no greater than !--.1D! ;ote that the sum R1 F R> determines the loading on Vref, assuming that the input resistance of the comparator is effectivel$ infinite! +$picall$, therefore, this sum is made 6uite large! <ne problem with the circuit given in 3igure ?!.- is that it does not limit the current through the motor in d$namic bra#ing or slow deca$ modes! :ven if the current through the sense resistor vastl$ e5ceeds the desired current, switches B and 7 will remain closed in d$namic bra#ing mode, and if the reference voltage is variable, rapid drops in the reference voltage will not be enforced b$ this control s$stem! +he designers of the =llegro >,D1 chip faced this problem, and passed the solution bac# to the user, providing a M<7: input to determine whether the chopper alternated between running and fast deca$ mode or running and slow deca$ mode! ;ote that this chip uses a fi5ed off*time set b$ a one* shot, and therefore, switching between the two deca$ modes will change the precision of the current regulator! Biven that such a change in precision is acceptable, we can modif$ the circuit from 3igure ?!.- to automaticall$ thrown the s$stem into fast*deca$ mode if the running or d$namic bra#ing current e5ceeds the set*point of the comparator b$ too great a margin! 3igure ?!.. illustrates how this can be done using a second comparatorC

Figure 4.11

=s shown in 3igure ?!.., the lower comparator directl$ senses the voltage across R., while the upper comparator senses a higher voltage, determined b$ a resistor networ#! +his networ# should hold the negative inputs of the two comparators 4ust far enough apart to guarantee that, as the voltage across R. rises, the top comparator will alwa$s open the top switches before the bottom comparator opens the bottom switches, and as the voltage across R. falls, the bottom comparator will alwa$s close the bottom switches before the top comparator closes the top switches! =s a result, this s$stem has two basic stead$*state running modes! If the motor winding is drawing power, one of the bottom switches will remain closed while the opposite switch on the top is used to chop the power to the motor winding, alternating the state of the s$stem between running and slow* deca$ mode! If the motor winding is generating power, the top switches will remain open and the bottom switches will do the chopping, alternating between fast*deca$ and slow*deca$ modes as needed to #eep the current within limits!

If the two comparators have accuracies on the order of a millivolt with h$steresis on the order of D millivolts, it is reasonable to use a D millivolt difference between the top and bottom comparator! If we use the D volt logic suppl$ as the pull*up suppl$ for the resistor networ#, and we assume a nominal operating threshold of around -!D volts, the resistor networ# should have a ratio of .C,--E for e5ample, a ,-# resistor from FD and a .-- ohm resistor between the two comparator inputs!

"ractical $%a&ples
+he basic idea described in this section is also applicable to unipolar stepping motor controllers, although in this conte5t, it is somewhat easier to appl$ if the reference voltage is measured with respect to the unregulated motor power suppl$! 3igure ?!.1 illustrates a practical e5ample, using the forward voltage drop across an ordinar$ silicon diode as the reference voltage!

Figure 4.12

+he circuit shown in 3igure ?!.1 uses a 1!?P resistor to provide a bias current of .-ma to the reference diode! = small capacitor should be added across the reference diode if the motor power suppl$ is minimall$ regulated! +he -!@ ohm value used for the current sensing resistor sets the regulator to . amp, assuming that the reference voltage is -!@ volts! +he .--- to . ratio on the feedbac# networ# around the comparator sets the allowed ripple in the regulated current to around / ma! +he comparator shown in 3igure ?!.1 can be powered from the minimall$ regulated motor power suppl$, but onl$ if it is able to operate with the inputs ver$ close to its positive suppl$ voltage! =lthough I have not tried it, the Mitsubishi MD1?," comparator appears to be ideall$ suited to this 4obE it can wor# from a positive suppl$ of up to ?- volts, and the input voltages are allowed to slightl$ e5ceed the positive suppl$ voltageG +he output of this comparator is open collector, so the h$steresis networ# shown in the figure also acts as a pull*up networ#, providing a pull*up current of a few milliamps! +he diode to FD shown in the figure clamps the comparator output to the logic suppl$ voltage, protecting the and gate inputs from overvoltage!

$ther Current Sensing Technologies


+he feedbac# loops of all of the current limiters given above use the voltage drop across a small resistor to measure the current! +his is an e5cellent choice for small motors, but it poses difficulties for large high*current motorsG +here are other current sensing technologies appropriate for such

settings, most notabl$ those that deliver onl$ a fraction of the motor current to the sensing resistor, and those that measure the current b$ sensing the magnetic field around the conductor! ;ational Semiconductor had incorporated a ver$ clever current sensor into a number of their 9* bridges! +his delivers a current to the sense resistor that is proportional to the current through the motor winding, but far lower! 3or e5ample, on the "M7./1-- 9*bridge, the sense resistor receives e5actl$ >00 microamps per ampere flowing through the motor winding! +he #e$ to the current sensing technolog$ used in the ;ational Semiconductor line of 9*bridges is found in the internal structure of the 7M<S power switching transistors the$ use! +hese transistors are composed of thousands of small M<S3:+ transistor cells wired in parallel! = small but representative fraction of these cells, t$picall$ . in ?---, is used to e5tract the sense current while the remainder of the cells control the motor current! +he data sheet for the ;ational "M7./1?D 9* bridge contains an e5cellent writeup on how this is done! 2hen ver$ high currents are involved, precluding use of an integrated 9*bridge, an appealing and well established current sensing technolog$ involves the use of a split ferrite core and a hall effect sensor, as illustrated in 3igure ?!.>C

Figure 4.13

Simple linear 9all effect sensors re6uire a small regulated bias current between two of their terminals, and the$ generate a 7) voltage proportional to the magnetic field on a third terminal! +he magnetic field across the gap sawed in the ferrite core is proportional to the current through the wire, and therefore, the voltage reported b$ the 9all effect sensor will be proportional to the current! =llegro Micros$stems and others ma#e a full lines of 9all effect sensors, but pre*calibrated hall effect current sensors are availableE these include the split core, the hall effect sensor, and au5iliar$ components, all mounted on a small %) board or potted as a unit! ;ewar# :lectronics lists a few sources of these, including 9one$well, 3! 2! Bell and ":M Instruments! =n intriguing new current sensor is 4ust becoming available, as of .,,/, based on a thin*film magnetoresistive sensorE the sensitivit$ of this technolog$ eliminates the need for the ferrite core and the result is a ver$ compact current sensor! +he ;+ series sensors made b$ 3! 2! Bell use this technolog$!

3. Microstepping of Stepping Motors


%art of Stepping Motors b$ 7ouglas 2! 8ones

+9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science Under %e+elop(ent Introduction Sine*)osine Microstepping "imits of Microstepping * 7etent :ffects * Ruanti'ation +$pical )ontrol )ircuits * %ractical :5amples

Introduction
Microstepping serves two purposes! 3irst, it allows a stepping motor to stop and hold a position between the full or half*step positions, second, it largel$ eliminates the 4er#$ character of low speed stepping motor operation and the noise at intermediate speeds, and third, it reduces problems with resonance! =lthough some microstepping controllers offer hundreds of intermediate positions between steps, it is worth noting that microstepping does not generall$ offer great precision, both because of linearit$ problems and because of the effects of static friction!

Sine Cosine Microstepping


Recall, from the discussion in %art 1 of this tutorial, on Stepping Motor %h$sics, that for an ideal two*winding variable reluctance or permanent magnet motor the tor6ue versus shaft angle curve is determined b$ the following formulasC h K ( a1 F b1 -!D x K ( S I ( I1 arctan( b I a 2hereC a ** tor6ue applied b$ winding with e6uilibrium at angle -! b ** tor6ue applied b$ winding with e6uilibrium at angle S! h ** holding tor6ue of composite! x ** e6uilibrium position! S ** step angle! +his formula is 6uite general, but it offers little in the wa$ of guidance for how to select appropriate values of the current through the two windings of the motor! = common solution is to arrange the tor6ues applied b$ the two windings so that their sum h has a constant magnitude e6ual to the single*winding holding tor6ue! +his is referred to as sine*cosine microsteppingC a K h. sin((( I1 IS b K h. cos((( I1 IS 2hereC h. ** single*winding holding tor6ue (( I1 IS ** the electrical shaft angle Biven that none of the magnetic circuits are saturated, the tor6ue and the current are linearl$ related! =s a result, to hold the motor rotor to angle , we set the currents through the two windings asC

Ia K Ima5 sin((( I1 IS Ib K Ima5 cos((( I1 IS 2hereC Ia ** current through winding with e6uilibrium at angle -! Ib ** current through winding with e6uilibrium at angle S! Ima5 ** ma5imum allowed current through an$ motor winding! Peep in mind that these formulas appl$ to two*winding permanent magnet or h$brid stepping motors! +hree pole or five pole motors have more comple5 behavior, and the magnetic fields in variable reluctance motors don't add following the simple rules that appl$ to the other motor t$pes!

'i(its of Microstepping
+he utilit$ of microstepping is limited b$ at least three consideraitons! 3irst, if there is an$ static friction in the s$stem, the angular precision achievable with microstepping will be limited! +his effect was discussed in more detail in the discussion in %art 1 of this tutorial, on Stepping Motor %h$sics, in the discussion of friction and the dead 'one!

Detent $ffects
+he second problem involves the non*sinusoidal character of the tor6ue versus shaft*angle curves on real motors! Sometimes, this is attributed to the detent tor6ue on permanent magnet and h$brid motors, but in fact, both detent tor6ue and the shape of the tor6ue versus angle curves are products of poorl$ understood aspects of motor geometr$, specificall$, the shapes of the teeth on the rotor and stator! +hese teeth are almost alwa$s rectangular, and I am aware of no detailed stud$ of the impact of different tooth profiles on the shapes of these curves! Most commerciall$ available microstepping controllers provide a fair appro5imation of the sine* cosine drive current that would drive an ideal stepping motor to uniforml$ spaced steps! Ideal motors are rare, and when such a controller is used with a real motor, a plot of the actual motor position as a function of the e5pected position will generall$ loo# something li#e the plot shown in 3igure D!.!

Figure 5.1

;ote that the motor is at its e5pected position at ever$ full step and at ever$ half step, but that there is significant positioning error in the intermediate positions! +he curve shown is the curve that would result from a perfect sin*cosine microstepping controller used with a motor that had a tor6ue

versus position curve that included a significant ?th harmonic component, usuall$ attributed to the detent tor6ue!

'uanti(ation
+he third problem arises because most applications of microstepping involve digital control s$stems, and thus, the current through each motor winding is 6uanti'ed, controlled b$ a digital to analog converter! 3urthermore, if t$pical %2M current limiting circuitr$ is used, the current through each motor winding is not held perfectl$ constant, but rather, oscillates around the current control circuit's set point! =s a result, the best a t$pical microstepping controller can do is appro5imate the desired currents through each motor winding! +he effect of this 6uanti'ation is easil$ seen if the available current through one motor winding is plotted on the A a5is and the available current through the other motor winding is plotted on the ( a5is! 3igure D!1 shows such a plot for a motor controller offering onl$ ? uniforml$ spaced current settings for each motor windingC

Figure 5.2

<f the .@ available combinations of currents through the motor windings, @ combinations lead to roughl$ e6uall$ spaced microsteps! +here is a clear tradeoff between minimi'ing the variation in tor6ue and minimi'ing the error in motor position, and the best available motor positions are hardl$ uniforml$ spacedG Use of higher precision digital to analog conversion in the current control s$stem reduces the severit$ of this problem, but it cannot eliminate itG %lotting the actual rotor position of a motor using the microstep plan outlined in 3igure D!1 versus the e5pected position gives the curve shown in 3igure D!>C

Figure 5.3

It is ver$ common for the initial microsteps ta#en awa$ from an$ full step position to be larger than the intended microstep si'e, and this tends to give the curve a staircase shape, with the downward steps aligned with the full step positions where onl$ one motor winding carries current! +he sign of the error at intermediate positions tends to fluctuate, but generall$, the position errors are smallest between the full step positions, when both motor windings carr$ significant current! =nother wa$ of loo#ing at the available microsteps is to plot the e6uilibrium position on the hori'ontal a5is, in fractions of a full*step, while plotting the tor6ue at each available e6uilibrium position on the vertical a5is! If we assume a ?*bit digital*to*analog converter, giving .@ current levels for each each motor winding, there are 1D@ e6uilibrium positions! <f these, D1 offer holding tor6ues within .-L of the desired value, and onl$ >> are within DLE these >> points are shown in bold in 3igure D!?C

Figure 5.4

If tor6ue variations are to be held within .-L, it is fairl$ eas$ to select / almost*uniforml$ spaced microsteps from among those shown in 3igure D!?E these are bo5ed in the figure! +he ma5imum errors occur at the .I? step pointsE the ma5imum error is !--/ full step or !-@ microsteps! +his error will be irrelevant if the dead*'one is wider than this! If .- microsteps are desired, the situation is worse! +he best choices, still holding the ma5imum tor6ue variation to .-L, gives a ma5imum position error of !-1@ full steps or !1@ microsteps! 7oubling the allowable variation in tor6ue appro5imatel$ halves the positioning error for the .microstep e5ample, but does nothing to improve the / microstep e5ample! <ne option which some motor control s$stem designers have e5plored involves the use of nonlinear digital to analog converters! +his is an e5cellent solution for small numbers of microsteps, but building converters with essentiall$ sinusoidal transfer functions is difficult if high precision is desired!

Typical Control Circuits


=s t$picall$ used, a microstepping controller for one motor winding involves a current limited 9* bridge or unipolar drive circuit, where the current is set b$ a reference voltage! +he reference voltage is then determined b$ an analog*to*digital converter, as shown in 3igure D!DC

Figure 5.5

3igure D!D assumes a current limited motor controller such as is shown in 3igures ?!0, ?!/, ?!.- or ?!..! 3or all of these drivers, the state of the A and ( inputs determines the whether the motor winding is on or off and if on, the direction of the current through the winding! +he V- through Vn inputs determine the reference voltage and this the current through the motor winding!

"ractical $%a&ples
+here are a fair number of nicel$ designed integrated circuits combining a current limited 9*bridge with a small 7=) to allow microstepping control of motors drawing under 1 amps per winding! +he U7;1,.@B from =llegro Micros$stems is a dual 0D-m= 9*bridge, with a 1*bit 7=) to control the current through each! bridge! =nother e5cellent e5ample is the U)>00- from Unitrode! Unitrode! +his chip integrate a 1*bit 7=) with a %2M controlled 9*bridge, pac#aged in either .@ pin power*dip format or in surface mountable form! +he >0.0 a slightl$ cleaner design, good for .!1 =, while the >00- is good for up to between .!/ = or 1 =, depending on how the chip is cooled! +he >,DD from =llegro Micros$stems incorporates a >*bit non*linear 7=) and handles up to .!D =E this is available in .@*pin power 7I% or S<I) formats! +he nonlinear 7=) in this chip is specificall$ designed to minimi'e step*angle errors and tor6ue variations using / microsteps per full*step! +he "M7./1?D from ;ational Semiconductor is a good choice for microstepped control of motors drawing up to > amps! +his chip incorporates a ?*bit linear 7=), and an e5ternal 7=) can be used if higher precision is re6uired! =s indicated b$ the data shown in 3igure D!?, a ?*bit linear 7=) can produce / reasonabl$ uniforml$ spaced microsteps, so this chip is a good choice for applications that e5ceed the power levels supported b$ the =llegro >,DD!

4. Midle+el Control of Stepping Motors


%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science 5"R&I& 6 +his material is new but fairl$ stable

Introduction 9ardware Solutions * %ractical :5amples Software Solutions * Simple %ractical :5amples * =n <b4ect <riented 7esign * 2hen <b4ects 2on't 7o

Introduction
=ll of the low*level motor control interfaces described in the previous sections are 6uite similar, at an abstract level! :ach interface has some number of logic inputs! Some of these inputs ma$ be used to directl$ control which switches are open or closed, others ma$ be encoded, while others ma$ control subs$stems such as the analog to digital converter in a microstepping interface! +he states of each of these logic inputs is referred to as the control vector for the motor, and a se6uence of states used to rotate the motor is referred to as a control tra'ectory for the motor! 3or e5ample, the control vector for controlling a permanent magnet or h$brid stepping motor using an$ of the control circuits shown in 3igures >!?, >!D, >!.>, >!.?, >!.D, ?!0, ?!/, ?!.-, ?!.. or ?!.1 will contain ? bits, 1 bits to control each motor winding! In each case, the control vector can be e5pressed as UA.(.A1(1O, where A. and (. control the current through motor winding . and A1 and (1 control the current through motor winding 1! 3or an$ interface with this control vector, the following tra4ector$ will step the motor through one full electrical c$cle, using full steppingC .-..--. -.-. -...-.Similarl$, the following tra4ector$ will half*step motor through the same electrical c$cleC .-..--.--. ---. -.-. -.--..--..-.<ther controllers have different control vectors! 3or e5ample, the control vector for a permanent magnet or h$brid motor controlled b$ a pair of =llegro >,D1 chips (see 3igure ?!, will be UB.:.%.M.B1:1%1M1O, where B, :, % and M are the SBR=P:, S:;=B":, %9=S: and M<7: control inputs for each chip! In this case, the following control tra4ector$ will full*step the motor through . electrical c$cleC .---.---

.---.-..-.-.-..-.-.--.---.--+he following control tra4ector$ will half*step the same motor through one electrical c$cle, using d$namic bra#ing to control resonance whenever a motor winding is turned offC .---.--.------.---.-.----.-..-.-.-..-.----.-.-.------.--.---.--It is worth noting that, while d$namic bra#ing on disconnected motor windings is an e5cellent wa$ to control resonance during low speed operation, this will reduce the available tor6ue at higher motor speeds! +he control vectors re6uired for microstepped motors are more comple5, but the basic idea remains the same! +he problem we face here is to develop higher level control s$stems that will generate appropriate control tra4ectories, moving the motor one step, half*step or microstep each time the higher level control s$stem re6uires a move!

.ard)are Solutions
:arl$ solutions to the problem of generating appropriate control tra4ectories for stepping motors were almost alwa$s based on direct s$nthesis of the control tra4ector$ in hardware! Such solutions are still appropriate for some applications, but these da$s, when programmable interface controller chips are commonl$ used to replace random low*speed logic and when most stepping motor applications are ultimatel$ controlled b$ computer s$stems of one #ind or another, it is common to use software to generate the control tra4ector$! =ll hardware solutions to generating the control tra4ector$ are subsumed b$ the general model illustrated in 3igure @!.C

Figure 6.1

+he next-state and create-vector bloc#s in 3igure @!. are combinational logic functions, while the state bloc# is a register! 7epending on how the state is encoded, the create-vector function ma$ be trivialE for certain applications, the next-state function is also trivial, but in the general case, nextstate becomes an up*down counter while create-vector becomes a R<M holding the se6uence of state vectors needed to form the control tra4ectories! It is worth noting that some stepping motor control s$stems include addtional inputs to the mid* level control s$stem! )ommon additions include half-step and brake inputs! Bra#ing control is meaningless in full*step mode but it is of some use in half*step mode! In the latter mode, shorting unused motor windings at low speed is an e5cellent wa$ to limit resonance while at higher speeds, unused motor windings should be left open for efficienc$! 3inall$, some motor control s$stems include a disengage input that removes power from all windingsE in this case, if brake is asserted, it t$picall$ shorts all motor windings!

"ractical $%a&ples
=mature astronomers fre6uentl$ need ver$ slow motors to turn their telescopes, and in recent $ears, stepping motors have ta#en the place of s$nchronous motors and gear trains for man$ applications, particularl$ for barn*door or Scotch mounts, a class of e5tremel$ simple camera mounts used in astrophotograph$! 3or this application, circuits as simple as that shown in 3igure @!1 are commonC

Figure 6.2

+he circuit shown in 3igure @!1 onl$ operates in one direction, generating the signals needed to turn a permanent magnet or h$brid motor one full step for each pulse on the ta#e*step input! In terms of the general model in 3igure @!., the ne5t*state and create*vector functions are trivial and re6uire no logic to generate so long as each flipflop in the state register has outputs available in both straight and complemented form! Modif$ing this circuit for bidirectional operation is straightforward, as is illustrated in 3igure @!>C

Figure 6.3

+he circuit shown in 3igure @!> uses two e5clusive or gates to compute two different versions of the ne5t*state function, depending on the value of the direction input! :ach flip*flop presents both inverted and non*inverted outputs to the worldE this allows an e6uivalent circuit to be made b$ substituting a double*pole double*throw switch for the e5clusive*or gates, and another e6uivalent circuit can be derived from this b$ substituting a pair of 1*input .*output multiple5ors for the switch! = number of manufacturers of stepping motor control circuitr$ ma#e integrated circuits that include slightl$ more comple5 logic allowing both full and half stepping modes! 3or e5ample, the Motorola (and others M)>?0, chip includes a .@ volt >D-m= 9*bridge and control logic with step, direction, and mode inputs to control half*stepping! +he SBS*+hompson (and others "1,0 includes 4ust the mid*level control logic for full or half*step control of a pair of 9*bridges used to control a permanent magnet or variable reluctance motor! +his chip is specificall$ designed to control the "1,/ dual 1 =mp 9*bridge, and in addition to the mid* level control logic, it includes the one*shots and comparators re6uired to use this 9*bridge as a current limited chopper!

Soft)are Solutions
If a microprocessor, programmable interface controller or other computer s$stem is used to control a stepping motor, the computer can directl$ generate the control vector in software and present it to the motor interface through a parallel output port, as shown in 3igure @!?C

Figure 6.4

In this software*centered model, the basic problem of mid*level control is reduced to how the step function is implemented! :ach call to step(d causes the control vector to advance along the control tra4ector$ in the direction specified b$ dir! +he call step(F. causes the motor to step forward, while the call step(*. causes it to ta#e one step bac#!

+he control tra4ector$ for an$ motor can be described as a circular arra$ of control vectors! +he simple full*stepped tra4ector$ given in the introduction can be represented asC t, a ? element arra$ where tV-W K .tV.W K , tV1W K D tV>W K @ Similarl$, the corresponding half*stepped tra4ector$ for the same motor interface would beC t, an / element arra$ where tV-W K .tV.W K / tV1W K , tV>W K . tV?W K D tVDW K ? tV@W K @ tV0W K 1 Similar definitions, differing onl$ in the si'e of the tra4ector$ arra$ and the values of each entr$, will suffice to describe one complete c$cle of the control tra4ector$ for an$ stepping motor interfaceG +he step routine itself does not depend in an$ wa$ on the control vector! 3or all of the above e5amples, the step routine isC p, a staticall$ allocated integer variable, initiall$ 'ero! step( d ** a function of one argument d ** where d must be either F. or *. ** no value is returned p K p F d ( mod size( t output( tVpW 9ere, we assume that the output function sends one control vector to the motor! +he details of this function will depend on the computer, the interface used, and the operating s$stem, if an$! +he above pseudocode also assumes a size function that returns the si'e of the arra$ holding a c$cle of the the tra4ector$E how this is done will definitel$ var$ from one programming language to another! ;ote that, when translating the above code into real programming languages, the simple use of the mod operator above can rarel$ be preserved! Mathematicians generall$ agree that y O x ( mod y O but the designers of programming languages fre6uentl$ depart from this definition when x is negative! =s a result, in languages such as ), )FF, 8ava and %ascal, care must be ta#en to avoid negative values on the righthand side of the mod (or % operatorG

Si&ple "ractical $%a&ples


+he following ) code will control a single >*phase variable reluctance motor ta#ing its control vector from the three least significant bits of the parallel port of a Uni5 or "inu5 s$stem, assuming that the parallel port has been opened in the correct mode using the file descriptor ppC

#de ine !TE"! 3 int t#!TE"!$ % & 1' 2' 4 () int p % 0) *oid +tep, int d & c.ar c) p % ,p + !TE"! + d- % !TE"!) /0 o1tp1t t#p$ 1+ing lo2-le*el 3nix 4/5 0/ c % t#p$) 2rite, pp' 6c' 1 -)

Rewriting the first few lines of the above code allows us to convert it for use with a permanent magnet or variable reluctance motor operated in half*step mode from the ? least significant bits of the parallel portC
#de ine !TE"! 7 int t#!TE"!$ % & 10' 7' 8' 1' 5' 4' 9' 2 ()

)n *+,ect *riented Design


+hings are more comple5 if multiple motors are in useG =lthough ad*hoc solutions can are common, a s$stematic approach is appropriate, and even in languages with no support for ob4ect oriented methodolog$, the easiest wa$ to describe such solutions is in ob4ect oriented terms! =fter initiali'ation, which ma$ depend on man$ low level details, the high level software isn't interested in how the motor wor#s! +herefore, for each motor ob4ect, the visible interface needs onl$ the step function! +he class of motor ob4ects is pol$morphic because the details of how step operates for one motor ma$ differ considerabl$ from the details of how it wor#s for another! +he following code is given in 8avaE translation to )FF, Simula @0 or other ob4ect oriented languages should be straightforwardC
ab+tract cla++ !tep:otor & p1blic ab+tract *oid +tep,int d-) // +tep t.e motor in direction d ,+1 or -1(

+his is an abstract classE that is, ob4ects of this class cannot be instantiated because we have $et to specif$ an$ of the details of how the motor or interface wor#s! :ach useful stepping motor interface must be supported b$ an e5tension or subclass of this abstract classG +he class below illustrates this, incorporating the code discussed in the sections aboveC
cla++ 3ni*er+al!tep:otor extend+ !tep:otor & pri*ate int +) // t.e +i;e o t.e tra<ector= pri*ate int#$ t) // t.e tra<ector= or t.i+ motor pri*ate int p) // motor>+ po+ition in tra<ector= pri*ate 51tp1t!tream o)// t.e o1tp1t port to 1+e p1blic *oid +tep,int d// +tep t.e motor in direction d ,+1 or -1& p % ,p + + + d- % +) o?2rite, t#p$ -) ( p1blic 3ni*er+al!tep:otor, int#$ table' 51tp1t!tream o1t // initiali;er

&

+ t p o

% % % %

table?lengt.) table) 0) o1t)

( (

o?2rite, t#p$ -)

+he above code assumes that the interfaces to motors are accessible through output streams of t$pe <a*a?io?51tp1t!tream, and the initiali'er not onl$ builds the data structure but sends an initial control vector to the motor! Biven that :otor"ort is an ob4ect of t$pe <a*a?io?51tp1t!tream, the following 8ava code will create a 3ni*er+al!tep:otor ob4ect m for a >*phase variable reluctance motorC
!tep:otor m % 3ni*er+al!tep:otor, ne2 int#$ &4'2'1(' // +tep table or t.e motor :otor"ort // 51tp1t!tream or t.e motor -) 2ith this declaration and initiali'ation in place, the call m?+tep,1- will

turn the motor one step!

3or man$ applications, the class !tep:otor defined above will need to be e5tended with a re+et procedure, used to reset both the motor ob4ect and the motor interface! +his procedure should probabl$ be incorporated directl$ into the definition of the StepMotor class, as opposed to adding it b$ class e5tension! +his procedure would t$picall$ be called as the first step in recovering from an error detected at higher levels in the control hierarch$!

#hen *+,ects #on-t Do


3or programmers who can't use ob4ect oriented design, for an$ reason, the following e5ample illustrates an appropriate mid*level design that avoids the use of such features! Using %ascal, the following t$pes can be used to describe each motorC
t=pe direction % -1 ?? +1) tra<ector= % arra= #0 ?? :axTra<ector=!i;e$ o int)

!tep:otor % record +@ integer) & +i;e o t.i+ motor>+ tra<ector= ( t@ tra<ector=) p@ integer) & t.i+ motor>+ po+ition in tra<ector= ( o@ port) & t.e o1tp1t port to 1+e or t.i+ motor ( end & record () +he !tep:otor record t$pe given here corresponds e5actl$ to an ob4ect of the class 3ni*er+al!tep:otor defined in 8ava above! +he arra$ t$pe tra4ector$ is e5plicitl$ named

so that a tra4ector$ ma$ be passed, as a formal parameter, to an initiali'er procedure for records of this t$pe! +he subrange t$pe direction allows %ascal's subrange restriction mechanisms to chec# the correctness of parameters to the step function, a desirable feature that is missing in languages descended from )! Biven the above definitions, we can now construct a general purpose step procedureC
proced1re +tep,*ar m@ !tep:otor' d@ direction-) & +tep motor m in direction d ( begin

2it. m do begin p % ,p + + + d- mod +) o1tp1t, o' t#p$ -) ( end & +tep ()

In all of the above, we have assumed that variables of the t$pe port are used to describe output ports to which motors ma$ be attached, and that the procedure o1tp1t outputs one vector to the indicated port! In effect, in abandoning programming languages with direct support for ob4ect orientation, we have had to chang our notation fromC
motor?+tep, dir -)

toC
+tep, motor' dir -)

+his is not a ma4or sacrifice in a s$stem where there is onl$ one t$pe of motor interface, but when there are multiple motor t$pes, support for the ob4ect oriented model will be useful! If this must be done in a language li#e %ascal, the declaration for the t$pe !tep:otor must be modified to allow for all t$pes of motor interfaces, for e5ample, b$ declaring it to be a variant record, and the +tep !procedure must be modified to chec# the motor t$pe and act appropriatel$

7. .igh 'e+el Control of Stepping Motors


%art of Stepping Motors b$ 7ouglas 2! 8ones +9: U;IV:RSI+( <3 I<2= 7epartment of )omputer Science Under %e+elop(ent

Introduction * Model Variables * Models 9ardware Solutions * %ractical :5amples Software Solutions * Simple %ractical :5amples * =n <b4ect <riented 7esign

Introduction
+he #e$ 6uestion to be answered b$ the high*level control s$stem for a stepping motor is, when should the ne5t step be ta#enH 2hile this almost alwa$s depends on the application, the similarities between different applications are sufficient to 4ustif$ the development of fairl$ comple5 general purpose stepping motor controllers! Stepping motor control ma$ be based on open loop or closed loop models! 2e are primaril$ interested in open loop models, because this is where stepping motors e5cel, but we will treat closed loop models briefl$ because the$ are somewhat simpler! 3igure 0!. illustrates an e5treme e5ampleC

Figure 7.1

In 3igure 0!., a 6uadrature shaft encoder is attached to the drive shaft of a permanent magnet or h$brid stepping motor, and the two phase output of this encoder is used to directl$ generate the control vector for the motor driver! Rotar$ shaft encoders are t$picall$ rated in output pulses per channel per revolutionE for this e5ample to be useful, for a motor with n steps per revolution, the shaft encoder output must gives nI1 pulses per channel per revolution! If this is the case, the behavior of this s$stem will depend on how the shaft encoder is rotated around the motor shaft relative to the motor! If the shaft encoder is rotated into a position where the output of the shaft encoder translates to a control vector that holds the motor shaft in its initial position, the motor shaft will not rotate of itself, and if the motor shaft is rotated b$ force, it will sta$ wherever it is left! 2e will refer to this position of the shaft encoder relative to the motor as the neutral position! If the shaft encoder is rotated one step cloc#wise (or countercloc#wise from the neutral position, the control vector output b$ the shaft encoder will pull the rotor cloc#wise (or countercloc#wise ! =s the rotor turns, the shaft encoder will change the control vector so that the rotor is alwa$s tr$ing to maintain a position one step cloc#wise (or countercloc#wise from where it is at the moment! +he tor6ue produced b$ this method will fall off with rotor speed, but this control s$stem will alwa$s produce the ma5imum tor6ue the motor is able to deliver at an$ speed! In effect, with this one*step displacement, we have constructed a brushless 7) motor from a stepping motor and a collection of off*the*shelf parts! In practice, this is rarel$ done, but there are numerous applications of stepping motors in closed*loop control s$stems that are based on this model, usuall$ with a microprocessor included in the feedbac# loop between the shaft encoder and the motor controller! In an open*loop control s$stem, this feedbac# loop is bro#en, but at a high level, the basic principle remains 6uite similar, as illustrated in 3igure 0!1C

Figure 7.2

In 3igure 0!1, we replace the shaft encoder from 3igure 0!. with a simulation model of the response of the motor and load to the control vector! =t an$ instant, the actual position of the rotor is un#nownG ;onetheless, we can use the simulation model to predict, based on an assumed rotor

position and velocit$, how the motor will respond to the control vector, and we can construct this model so that its output is the control vector generated b$ a simulated shaft encoder! So long as the model is sufficientl$ accurate, the behavior of the motor controlled b$ this model will be the same as the behavior of the motor controlled b$ a closed loop s$stemG

Model aria+les
In the e5ample given in 3igure 0!., the onl$ control variable offered is the angle of the shaft encoder relative to the motor! In effect, this controls the e5tent to which the e6uilibrium point of the motor's tor6ue versus shaft angle curve leads or follows the current rotor position! In theor$, an$ desired motor behavior can be elicited b$ ad4usting this angle, but it is far more convenient to spea# in terms of other variablesC ** +he predicted shaft position (radians target ** +he target shaft position determined b$ the application V K d Idt ** +he predicted velocit$ (radians per second Vtarget ** +he target velocit$ determined b$ the application = K dVIdt ** +he predicted acceleration (radians per second s6uared =target ** +he target acceleration, ma$ be determined b$ the application =s in the section on Stepping Motor %h$sics, we will define the basic motor characteristicsC S ** step or microstep angle, in radians N ** moment of inertia of rotor and load h ** the holding tor6ue of the motor ;ote that here, the step angle S is not the ph$sical step angle of the motor, but rather, the step angle offered b$ the mid*level motor interfaceE this ma$ be a full step, a half step, or a microstep of some si'eG

Models
+he simplest model that will do the 4ob is almost alwa$s the best! 3or some applications, this means the model is so simple that it is hard to identif$ it as a modelG 3or e5ample, consider the case where the application demands a constant motor velocit$C =target K Vtarget K )onstant In this case, tstep K S I Vtarget where tstep ** time per step +his barel$ loo#s li#e a modelE in part, this is because we have omitted the statement that, ever$ tstep seconds, we advance the control vector one stepC repeat the following c$cle foreverC wait tstep seconds and then K FS step( . = more interesting model is re6uired if we want to maintain a constant acceleration! <bviousl$, we can't do this forever, but we'll use this model as a component in more comple5 models that re6uire changes of velocit$ or position! In this case, =target K )onstant

where =target U h I N In developing a model, we begin with the observation that, for constant acceleration = and assuming a standing start at time -, K .I1 = t1 More generall$, if the motor starts at position and velocit$ V, after time t the new position ' and velocit$ V' will beC ' K .I1 = t1 F V t V' K = t F V Setting K- and 'KS, we solve first for t, the time ta#en to move one step, as a function of V and =C .I1 = t1 F V t * S K t K ( *V T ( V1 F 1 = S -!D I = 9ere, we have applied the 6uadratic formula, and for our situation, this gives two real rootsG +he additive root is the root we are concerned withE for this, we can use the resulting time to compute the velocit$ at the end of one stepC tstep K ( *V F ( V1 F 1 = S -!D I = V' K ( V1 F 1 = S -!D 2e can combine this model for acceleration with the model for constant speed running to ma#e a motor controller that will see# Vtarget, assuming that an outside agent ma$ change Vtarget at an$ timeC repeat the following c$cle foreverC if V K Vtarget do the followingC wait SIVtarget seconds and then K FS step( . otherwise, if V U Vtarget, accelerate as followsC wait ( *V F (V1 F 1 =accelS -!D I =accel seconds and then K FS V K (V1 F 1 =accelS -!D step( . otherwise, V O Vtarget, decelerate as followsC wait ( *V F (V1 F 1 =decelS -!D I =decel seconds and then K FS V K (V1 F 1 =decelS -!D step( . +his control s$stem is not full$ satisfactor$ for a number of reasonsG 3irst, it onl$ allows the motor to operate in one direction and it fails utterl$ when V reaches 'eroE at that point, if a divide b$ 'ero operation is allowed to produce an infinite result, the program will wait infinitel$ and never again respond to change in the control input! +he second shortcoming of this program is simpler to correctC =s written, there is an infinitesimal probabilit$ of the motor speed reaching the desired speed and sta$ing there with Vtarget e6ual to V! 3ar more li#el$, what will happen is that V will oscillate around Vtarget, ta#ing alternate accelerating and decelerating steps and never settling down at the desired running speed! = 6uic# and dirt$ solution to this latter problem is to add code to recogni'e when V passes Vtarget during acceleration or decelerationE when this occurs, V can be set to Vtarget! 3ormall$, this is incorrect, but if the acceleration and deceleration rates are not too high and if there is sufficient damping in the s$stem, this will wor# 6uite well!

In a frictionless s$stem using sine*cosine microstepping at speeds below the cutoff speed for the motor, the available tor6ue is effectivel$ constant and we can use the full tor6ue to accelerate or decelerate the motor, so the above control algorithm will wor# with =accel K =decel K h I N If there is significant static friction, we can ta#e this into account as followsC =accel K ( h * f I N =decel K ( h F f I N where f ** frictional tor6ue If the motor is run using the ma5imum available acceleration and decleration, an$ une5pected increase in the load will cause the motor rotor to fall behind its predicted position, and the result will be a failure of the control s$stem! =s a result, open*loop stepping motor control s$stems are never run at the accelerations give aboveG In the case of full or half*stepping, where there is no sine* cosine tor6ue compensation, the available tor6ue varies over a range of a factor of 1-!D, so we t$picall$ ad4ust the accelerations given above b$ this amountC =accel K ( ( h I .!?.? * f I N =decel K ( ( h I .!?.? F f I N If we operate consistentl$ near the edge of the performance envelope, and if we never re6uest a velocit$ Vtarget near the resonant speed of the motor, we can safel$ accelerate through resonances without rel$ing on damping! If, on the other hand, we select acceleration values that are significantl$ below the ma5imum that is possible, electrical or mechanical damping ma$ be needed to avoid problems with resonance! ;ote that it is not difficult to e5tend the above control model to account, at least appro5imatel$, for viscous friction and for the dropoff of tor6ue as a function of speed! +o do this, we merel$ modif$ the above formulas for =accel and =decel so that h and f are functions of V! +hus, instead of treating these as constants of the control algorithm, we must recompute the available acceleration at each step! If our goal is to turn the motor smoothl$ from one set postion to another, we must first accelerate it, then perhaps coast at fi5ed speed for a while, then decelerate! +he decision governing when to begin decelerating rests on a #nowledge of the stopping distance from an$ particular velocit$! =ssuming that the available acceleration is constant over the relevant range of speeds, we can compute this fromC V K =decel t K .I1 =decel t1 3irst we solve for the stopping time, t K V I =decel and then we solve for the stopping angle K .I1 =decel ( V I =decel 1 K V1 I ( 1 =decel Biven this, we can outline a procedure for moving the motor from its current estimated position to a step 4ust be$ond some target positionC moveto( target ** a function of one argument ** no value is returned while V U Vtarget and while U target * V1 I ( 1 =decel repeat the following to accelerate step( . wait ( *V F (V1 F 1 =accelS -!D I =accel seconds and then

K FS V K (V1 F 1 =accelS -!D V K Vtarget while U target * V1 I ( 1 =decel repeat the following to coast step( . wait SIVtarget seconds and then K FS while U target repeat the following to decelerate step( . wait ( *V F ( V1 F 1 =decelS -!D I =accel seconds and then K FS V K ( V1 F 1 =accelS -!D VKdone, and target are within a step of each otherG +he control model onl$ moves the motor one direction, it fails to plan in terms of the 6uanti'ation of available stopping positions, and it doesn't account for the c$clic nature of ! ;onetheless, it is a useful illustration! ;ote that we have used Vtarget as a limiting velocit$ in this code, but that this will onl$ be relevant during long movesE for short moves, the motor will never reach this speed! 2ith the above, code, so long as the acceleration and deceleration rates are high enough to avoid dwelling for too long at resonant speeds, and so long as Vtarget is not too close to a resonant speed, a plot of rotor position versus time will show fairl$ clean moves, as illustrated in 3igure 0!>C

Figure 7.3

If the motor is to be accelerated at the ma5imum possible rate, the control model used above is not sufficient! In that case, during acceleration, the e6uilibrium position must be maintained between -!D and .!D steps ahead of the rotor position as the rotor moves, and during deceleration, the e6uilibrium position must be maintained the same distance behind the rotor position! +his re6uires careful logic at the turnaround point, when the change is made from accelerating to decelerating modes! +he above control model omits an$ such considerations, but it is ade6uate at accelerations sufficientl$ below the ma5imum availableG

.ard)are Solutions
+oda$, it is rare to find high*level stepping motor control done purel$ in hardware, and when it is done, it is usuall$ onl$ in the ver$ simplest of applications! 3or e5ample, consider the problem of starting and stopping a stepping motor under load! 7irect generation of the 6uadratic functions necessar$ to achieve smooth acceleration is 6uite difficult in hardware, but it is eas$ to generate e5ponentials that are ade6uate appro5imations of these! +he circuit outlined in 3igure 0!? illustrates how this can be doneC

Figure 7.4

9ere, the resistor R and capacitor ) form a low pass filter on the control input of the voltage controlled oscillator V)<! 2hen the input level is at run, the V)< output oscillates at its ma5imum rate! 2hen the input level is at stop, the V)< output ceases to oscillate! +he R) time constant of the low pass filter determines the rate of acceleration applied to the motor! 2ith such a design, the time constant R) is usuall$ determined empiricall$ b$ setting up the s$stem and then ad4usting R and ) until the s$stem operates properl$!

"ractical $%a&ples
+he ;:DDD timer can be used as a voltage controlled oscillator, but I first saw this done with discrete components on a controller for a paper*tape reader designed around .,0-!

Soft)are Solutions
+he basic control models outlined at the start of this section can be directl$ incorporated into the software for controlling a stepping motor, and this must be done if, for e5ample, the motor is driving a load with a variable moment of inertia or driving a load against variable frictional loadings! Most open*loop stepping motor applications are not that complicated, howeverG So long as the inertia and frictional loadings are constant, the control software can be greatl$ simplified, replacing comple5 model computations with a table of precomputed dela$s! )onsider the problem of accelerating the motor from a standing start! ;o matter where the motor starts, so long as the tor6ue, moment of inertia and frictional loadings remain the same, the time se6uence of steps will be the same! +herefore, we need onl$ pre*compute this time se6uence of steps and save it in an arra$! 2e can use this arra$ as follows to accelerate the motorC arra$ =V, the acceleration vector, holds time intervals i is the inde5 into =V iKrepeat the following c$cle to accelerate foreverC wait =VViW seconds and then step( . iKiF. 2e ma$ use i, the counter in the above code, as a stand*in for the motor velocit$, since stepping the motor ever$ =VViW seconds will move the motor at a speed of SI=VViW! It is a straightforward e5ercise in elementar$ ph$sics to compute the entries in the arra$ =! If the motor is accelerating at =target, K .I1 =target ti1 where i ** the shaft angle at each successive step
i

Solving for time as a function of position, we getC ti K (1 i I =target -!D If we define - K so that i K Si and t- K we can conclude that ti K # i-!D where # K (1SI=target -!D +he acceleration vector entries are thenC =V-W K (1SI=target -!D and =ViW K (i-!D * (i * . -!D =V-W +he following table gives the ratios of the first 1- entries in =ViW to =V-WC . .!-!.D -? . -!? -!.? . . .? 0 1 . -!> -!.? 1 ./ .

. -!1 -!.> > > @/ @ . -!1 -!.> ? ? >@ . D . -!1 -!.1 D .> 0

. -!. -!.1 @ @ ,@ > 0 . -!. -!.1 0 /> . -!. -!.. / 01 @

. -!. -!.. , , @1 >

In general, we aren't interested in indefinite acceleration, but rather, we are interested in accelerating until some speed or position restriction is satisfied, and then the control s$stem should change, for e5ample, from acceleration to deceleration or constant speed operation! So long as friction can be ignored, so the same rates can be used for acceleration and deceleration, we can ma#e a clean move to a target position as followsC arra$ =V is the acceleration vector i is the inde5 into =V iK7 K target * while 7 non'ero do the following if 7 O - ** spin one wa$ step( . 7K7*. else ** spin the other wa$ step( *. 7K7F. endif wait =VViW seconds and then if (i U X7X and (SI=VViW U Vtarget ** accelerate iKiF. else if i O X7X ** decelerate iKi*. endif endloop Biven an appropriate acceleration vector, the above code will cleanl$ accelerate a motor up to a speed near the target velocit$, hold that speed, and then decelerate cleanl$ to a stop at the target position! +he above code does not ta#e advantage of the higher rates of deceleration allowed when there is friction! In general, this should not cause an$ problems, but if the fastest possible moves are desired, a separate deceleration table should be maintained! 9ere is one ideaC arra$ =V holds acceleration intervals arra$ ) holds coasting intervals arra$ + holds transition information arra$ 7 holds deceleration intervals iKrepeat the following until the desired speed is reached wait =ViW seconds and then step( . iKiF. repeat the following to maintain the speed wait )ViW seconds and then step( . repeat the following to maintain the speed i K i * +ViW repeat the following until i K iKi*. step( . In the above, the arra$s = and 7 are constructed identicall$, e5cept that one has intervals used for acceleration, at a rate limited b$ friction, while the other has intervals used for deceleration, at a rate

assisted b$ friction! ;ote that, after accelerating for i steps from a standing start, the motor will reach a velocit$ from which it can decelerate to a halt in i*+ViW steps! +his relationship determines the values pre*computed in the arra$ +!

Si&ple "ractical $%a&ples )n *+,ect *riented Design

Stepping Motor Control Soft)are


(ld art ) of &tepping Motors by *ouglas +, -ones 9ere's the code to ma#e $our motor run as if $ou had one of those fanc$ stepper controllers! I've used %ascal for no particular reason! +his code assumes onl$ one motor, and it assumes it's attached to the least significant bits of one parallel output port! In practice, it's nice to have one parallel output port per motor, although with a bit of care, $ou can use the high bits of a port for another motor or other applications, and $ou can multiple5 one port to handle multiple motors! (+he 8ul$ .,,> issue of Model Railroader has plans for a parallel port multiple5er circuit for IBM %) s$stems in it ! =ssume these declarations and values for a three winding variable reluctance motorC
con+t max+tep % 2) +tep+ % 3) *ar +teptab@ arra= #0??max+tep$ o integer) +tep@ integer) motor@ ile o integer) & t.i+ i+ t.e 4/5 port begin +tep @% 0) +teptab#0$ % 1) & binar= 001 ( +teptab#1$ % 2) & binar= 010 ( +teptab#2$ % 4) & binar= 100 ( 2rite, motor' +teptab#+tep$ -)

or t.e motor (

=ssume these declarations and values for a permanent magnet motor, either unipolar, with center tapped windings, or bipolar, with 9*bridge drive circuitsC
con+t max+tep % 3) +tep+ % 4) *ar +teptab@ arra= #0??max+tep$ o integer) +tep@ integer) motor@ ile o integer) & t.i+ i+ t.e 4/5 port begin +tep @% 0) +teptab#0$ % 1) & binar= 0001 ( +teptab#1$ % 4) & binar= 0100 ( +teptab#2$ % 2) & binar= 0010 ( +teptab#3$ % 7) & binar= 1000 ( 2rite, motor' +teptab#+tep$ -) con+t max+tep % A) +tep+ % 7) *ar +teptab@ arra= #0??max+tep$ o +tep@ integer) motor@ ile o integer) & t.i+ begin +tep @% 0) +teptab#0$ % 1) & binar= 0001 +teptab#1$ % 5) & binar= 0101

or t.e motor (

=ssume these declarations and values for half*step control of a permanent magnet motorC
integer) i+ t.e 4/5 port ( ( or t.e motor (

+teptab#2$ % 4) & binar= 0100 +teptab#3$ % 9) & binar= 0110 +teptab#4$ % 2) & binar= 0010 +teptab#5$ % 10) & binar= 1010 +teptab#9$ % 7) & binar= 1000 +teptab#A$ % 8) & binar= 1001 2rite, motor' +teptab#+tep$ -)

( ( ( ( ( (

=ssume these declarations and values for control of a D*phase motor, with an 9*bridge on each of the D leads to the motorC
con+t max+tep % 8) +tep+ % 10) *ar +teptab@ arra= #0??max+tep$ o integer) +tep@ integer) motor@ ile o integer) & t.i+ i+ t.e 4/5 port begin +tep @% 0) +teptab#0$ % 13) & binar= 01101 ( +teptab#1$ % 8) & binar= 01001 ( +teptab#2$ % 11) & binar= 01011 ( +teptab#3$ % 10) & binar= 01010 ( +teptab#4$ % 29) & binar= 11010 ( +teptab#5$ % 17) & binar= 10010 ( +teptab#9$ % 22) & binar= 10110 ( +teptab#A$ % 20) & binar= 10100 ( +teptab#7$ % 21) & binar= 10101 ( +teptab#8$ % 5) & binar= 00101 ( 2rite, motor' +teptab#+tep$ -)

or t.e motor (

+he remainder of the code is the same and doesn't depend on the motor! +he following procedure will advance the motor one step in either direction, where the direction parameter must be either F. or *. to indicate the direction!
proced1re one+tep, direction@ integer -) begin +tep @% +tep + direction) i +tep > max+tep t.en +tep @% 0 el+e i +tep B 0 t.en +tep @% max+tep) 2rite, motor' +teptab#+tep$ -) end)

Software control of a stepping motor is a real*time tas#, and $ou need at least a bit of feedbac#! <ne bit is enoughE t$picall$, this will be a bit indicating that a cam on the turntable (or whatever the motor is driving is interrupting a light beam or closing a microswitch! +o avoid h$steresis problems in reading the position from this cam, $ou should onl$ read 'ero to one transitions as indicating the home position when the motor is spinning in one direction! :speciall$ with switches or where gear trains are involved between the motor and the turntable, the one to 'ero transition in the other direction won't usuall$ occur at e5actl$ the same position! Biven that $ou can read the sense bit and that $ou have a programmable interval timer interrupt on $our s$stem, it is eas$ to ma#e the timer interrupt service routine operate the motor as followsC
con+t maxpo+ % 11111) & maxpo+ + 1 i+ call+ to one+tep per re* ( *ar po+ition@ integer) & c1rrent po+ition o motor ( de+tination@ integer) & de+ired po+ition o motor ( direction@ integer) & direction motor +.o1ld rotate ( la+t@ integer) & pre*io1+ *al1e rom po+ition +en+or ( +en+or@ ile o integer) & parallel inp1t port ( begin read, +en+or' la+t -) po+ition @% 1) +etde+t, 0' 1 -) & orce t1rntable to +pin on po2er-1p 1ntil it ind+ it>+ .ome po+ition (

proced1re timer) & inter*al timer interr1pt +er*ice ro1tine ( *ar +en+e@ integer) begin read, +en+or' +en+e -) i ,direction % 1- and ,la+t % 0- and ,+en+e % 1t.en po+ition % 0) la+t @% +en+e) i po+ition B> de+tination t.en begin one+tep, direction -) po+ition @% po+ition + direction) i po+ition > maxpo+ t.en po+ition @% 0 el+e i po+ition B 0 t.en po+ition @% maxpo+) end) i end) po+ition B> de+tination t.en +ettimer, inter*alC1ntilCnextC+tep -)

+he following procedure is the onl$ procedure that user code should call! +his procedure sets the destination position of the turntable and sets the direction of rotation, then sets the interval timer to force an immediate interrupt and lets the timer routine finish rotating the turntable while the applications program does whatever else it wants!
proced1re +etde+t, d+t'dir@ integer -) begin de+tination @% d+t) direction @% dir) i po+ition B> de+tination t.en +ettimer, minCinter*al -) & end)

orce a timer interr1pt (

If $ou want to control multiple stepping motors, it is easiest if $ou have one interval timers and one parallel port per motor! If $ou hardware has onl$ one timer, then $ou can use it to simulate multiple interval timers, but this is most of the wa$ to the 4ob of writing a real*time e5ecutive! = final noteC If $ou tr$ to step a motor too fast, it will slip and $our software will lose trac# of the motor position! Motors t$picall$ come with a rating that indicates a ma5imum number of steps per second, but $ou ma$ not be able to accelerate the motor to that number of steps per second from a dead start without running it at a lower speed first! +his is especiall$ true if the inertia of the load is fairl$ large, and in fact, with appropriate acceleration se6uences, $ou can usuall$ e5cede the ma5imum rated speed! In the above code, intervalYuntilYne5tYstep is shown as a constant! If $ou are dealing with high* inertia loads or ver$ short intervals, $ou'll have to ma#e this a variable, using longer intervals during starting and stopping to ta#e care of accelerating and decelerating the motor!

" 5or2ed Stepping Motor E8a(ple


(ld art . of &tepping Motors by *ouglas +, -ones %erhaps some of the most commonl$ available stepping motors, for the e5perimenter, are the head positioning motors from old dis#ette drives! +hese can be found at electronics swap meets, in computer surplus outlets, and even in trash dumpsters! In addition to a stepper, a t$pical full*height D!1D inch dis# drive includes a .1 volt 7) motor with tachometer and motor control circuit board, two microswitches, and a matched ":7*photosensor pair! = common stepper to find in a full*height IBM or +andon D!1D inch dis#ette drive is the t$pe P%?M? made b$ either 8apan Servo Motors or +andonE this is a permanent magnet motor with >!@

degrees per step and .D- ohms per winding, with the center*taps of each winding tied to a common lead! Man$ half*height D!1D inch dis#ette drives use ver$ similar motors, although there is much more variet$ in newer drives, including some that use bipolar steppers! =nother stepper sometimes found in half*height drives is the Zpanca#e format' motor from a .I1 height D!1D inch dis#ette driveE for e5ample, a permanent magnet motor made b$ )opal :lectronics, with .!/ degrees per step and ,@ ohms per winding, with center taps brought out to separate leads! +he leads on these motors are brought out to multipin in*line connectors, laid out as followsC

Figure 6.1

2hen the center*taps of these motors are connected to F.1 and one end of either winding is grounded, the winding will draw from .0- m= to 1D- m=, depending on the motor, so an$ of a number of motor drive circuits can be used! +he original IBM full*height dis#ette drives used a pair of U7;>@.1; or U7;D0.> chipsE these are e6uivalent to chips in the S;0D?0A series (A in .,1,> ! +he U";1--> darlington arra$s from =llegro Micros$stems is probabl$ the most widel$ available of the applicable chips, so it will be used in this e5ample! )onsider the problem of controlling multiple steppers comparable to those described above from an IBM compatible 7B1D*based parallel output port! +he pinout of this connector is given in 3igure @!1, as seen loo#ing at the face of the female connector on the bac# of an IBM %) (or e6uivalentl$, as seen from the bac# of the male connector that mates with this C

Figure 6.2

+he I::: .1/? standard gives the best available definition of the parallel port, but as an after*the* fact standard, nonconformance is common! Some documentation of this standard is available in the net! +here is an e5tensive set of tutorial material available on the web discussing the IBM %) %arallel port! =nother inde5 of parallel port information is available from Ian 9arries! +here is some confusion in the documentation of this connector about the labels on the S")+ and S")+I; lines (pins .> and .0 E this is because these names date bac# to a )entronics printer design of the earl$ .,0-'s, and the name S")+I; refers to an input to the printer, which is to sa$, an output from the computer!

+he names of some of these lines are relics of the original intended purpose of this II< port, as a printer port! 7epending on the level at which $ou wish to use the printer, some ma$ be ignored! If the BI<S printer support routines of the IBM %) or the parallel port driver under various versions of U;IA sare to be used, however, it is important to pa$ attention to some of these signalsC +he BI<S handles reinitiali'ing the printer b$ producing a negative pulse on I;I+ (pin .@ ! 2e can use this as a reset pulse, but otherwise, it should be ignoredG In the reset state, all motor windings should be off! 2hen no output activit$ is going on, the BI<S holds the output signal lines as followsC
!TD5EE (pin . high, data not valid! F3T5GD (pin .? high, do not feed paper! 4H4T (pin .@ high, do not initiali'e! !EIJT4H (pin .0 low, printer selected!

+o print a character, the BI<S waits for BUS( (pin .. to go low, if it is not alread$ low, and then outputs the new data (pins 1 through , ! 3ollowing this (with a dela$ of at least -!D microsecond , S+R<B: (pin . is pulsed low for at least -!D microsecond! +he BI<S returns the inputs =)P, BUS(, %: and S")+ (pins .- to .> to the user program after printing each character! +he computer is entitled to wait for =)P (pin .- to go low for at least D microseconds to ac#nowledge the output strobe, but apparentl$, IBM's BI<S does not do soE instead, it relies on device to set BUS( to prevent additional outputs, and it leaves the output data unmodified until the ne5t print re6uest! 2hile neither MSI7<S nor the BI<S use the interrupt capabilit$ of the parallel port, <SI1 and various versions of U;IA use it! = rising edge on =)P (pin .- will cause an interrupt re6uest if interrupts are enabled! +his interrupt design is onl$ useful if, in normal operation, the trailing edge of the =)P pulse happens when BUS( falls, so that finding BUS( high upon interrupt signals an error condition! ;ote that all input output to the parallel port pins is done b$ writing to various II< registersE so as long as interrupts are disabled and the II< registers are directl$ manipulated b$ application software, all D input pins and all .1 output pins ma$ be used for an$ purpose! +o maintain compatibilit$ with e5isting drivers, however, we will limit our misuse of these pins! If we onl$ wanted to support a single motor, it turns out that the logic on the standard D!1D inch dis#ette drive can, with an appropriate cable, be driven directl$ from the parallel port! 7ocumentation on this approach to rec$cling motors from old dis#ette drives has been put on the web b$ +om$ :ngdahl! Since we are interested in supporting multiple motors, we will use 7=+= lines ? to 0 to select the motor to control, while using the least significant bits to actuall$ control the motor! In addition, because almost all stepping motor applications re6uire limit switches, we will use the %: (.1 bit to provide feedbac# from limit switches! +he I::: .1/? standard defines the %:, S")+ and :RR signals as user defined when in either :nhanced %arallel %ort or )ompatibilit$ mode, so this is not a bad choice! Unfortunatel$, the BI<S occasionall$ chec#s this bit even when it is aware of no printer activit$ (for e5ample, when the #e$board t$pe*ahead buffer fills E thus, it is a good idea to disable the BI<S when the parallel port is used for motor controlG ;ote that fanout is not a problem on the IBM %) parallel port! +he I::: .1/? standard defines the parallel port outputs as being able to source and sin# .? milliamps, and older IBM %) parallel ports could sin# about 1? milliamps! Biven that a standard "SI++" load sources onl$ -!? milliamps and

some devices (comparitors, for e5ample source .!1 milliamps, an I::: .1/? port should be able to handle up to .- of motor interfaces in parallel!

" Mini(al %esign


=s mentioned above, we will use the U";1--> darlington arra$ to drive the stepping motor! Since we want to drive multiple motors, the state of each motor must be stored in a registerE while man$ chips on the mar#et can store ? bits, careful chip selection significantl$ reduces the parts count and allows for a single*sided printed circuit cardG 2ith appropriate connections, both the 0?"S.,? and the 0?"S1,/ can use a positive enable signal to gate a negative cloc# pulseE we will use the 0?"S.,? because it is less e5pensive and somewhat simpler to connect! 3inall$, we will use the 0?"S/D chip to compare the ? bit address field of the output with the address assigned to the motor being driven! 3igure @!> summari'es the resulting designC

Figure 6.3

+he 0?"S.,? was designed as a parallel*in, parallel*out shift*register with inputs to select one of ? modes (do nothing, shift left, shift right, and load ! B$ wiring the two mode inputs in parallel, we eliminate the shift modes, converting the mode input to an enable line! +he unused right and left shift input pins on this chip can remain disconnected or can be grounded, tied to FD, or connected to an$ signal within the loading constraints! 9ere, we show the 0?"S.,? being loaded onl$ when bits ? to 0 of the output data match a ?*bit address coded on a set of address switches! +he comparison is done b$ a 0?"S/D, and the address switches are shown in 3igure @!> as an /*position 7I%*switch! +he cost of a 7I% switch ma$ be avoided in production applications b$ substituting 4umpers! <ne interesting aspect of this design is that the "S*++" outputs driving the U";1--> chip are used as current sources ** the$ pull up on the inputs to the darlington pairs! +his is a borderline design, but careful reading of the "S*++" spec sheets suggests that there is no reason it should not wor#, and the U";1--> is obviousl$ designed to be driven this wa$, with more than enough forward current gain to compensate for the tin$ pull*up capacit$ of an "S*++" outputG +he Jener diode connected between pin , of the U";1--> and the F.1 suppl$ increases the reverse voltage on the motor windings when the$ are turned off! Biven the D- volt ma5imum rating of the

U";1-->, this ma$ drop as much as D-*.1 or >/ volts, but note that power dissipation ma$ actuall$ be an issueG =t high fre6uenc$ with unconventional control software, the power transfer to this diode can be 6uite efficientG 2ith the stepping motors from old dis#ette drives, it ma$ be possible to push a .1 volt 'ener to on the order of . watt! I used a .D volt . watt 'ener, .;>-1?! If this motor is to be driven b$ software that directl$ accesses the low*level parallel port interface registers, directl$ loading data and then directl$ raising and lowering the strobe line, no additional hardware is needed! If it is to be driven through the BI<S or higher level s$stem software, additional logic will be needed to manipulate =)P and BUS(! =lthough the 0?"S/D and the 0?"S.,? are no longer stoc#ed b$ some mass*mar#et chip dealers, the$ are still in production b$ Motorola, +I, +hompson SP and ;+:! If over*the*counter availabilit$ of chips is $our primar$ concern, adding a chipload of inverters or 1*input nand gates will allow 4ust about an$ ?*bit latch to be used for the register, and address decoding can be done b$ a 6uad A<R chip and a ?*input nand gate! If over*the*counter chips are of no concern, $ou can reduce the chip count even furtherG +he Micrel MI)D/-- ?*bit parallel latchIdriver can easil$ handle the loading of small unipolar steppers and combines the function of the U";1--> and the 0?"S.,? used hereG +he resulting design is ver$ clean!

"dding $ne Bit of #eedbac2


Surprisingl$, no additional active components are needed to add one bit of feedbac# to this designG +here are > spare darlington pairs on the U";1--> driver chip, and, with a pull*up resistor for each, these can serve as open*collector inverters to translate one or two switch settings into inputs appropriate for the %)G +he U";1--> includes pull*down resistors on each input, guaranteeing that the corresponding output will be turned off if left disconnected! +hus, connecting a U";1--> input to a positive enable signal (pin D of the 0?"S/D chip for e5ample will turn the output on onl$ if it is both enabled and the switch is closed! It ma$ be necessar$ to add a .P pull*up to the "S*++" output because, in addition to driving the U";1-->, it is also driving two normal "S*++" inputs! =dding this pull*up will do no harm if it isn't needed (an "S*++" output should be able to handle even a >-- ohm pull*up ! Since the U";1--> is an open*collector inverter, the output needs a pull*up! 2e could rel$ on the %: input of the IBM %) parallel port to pull this line up (an open ++" input usuall$ rises of its own accord , but it is better to provide a pull*up resistor somewhere! 9ere, we provide a .-P pull up on each stepping motor drive cardE these pull*ups will be in parallel for all motors attached to a single parallel port, so if fewer than .- motors are in use, proportionall$ smaller resistors ma$ be substituted or the pull*ups ma$ be omitted from some of the controller cards! 3igure @!? summari'es these additions to the designC

Figure 6.4

So(ething 0ou Can Build


3igure @!D shows a single*sided %) board la$out for a 1!D inch s6uare board that incorporates all of the ideas given above! I have etched and tested the 0I/I.,,@ version of this artwor#!

Figure 6.5

(2hat's that about cop$right noticesH 2ell, put simpl$, if $ou're going to sell m$ design, please get in touch with me about it! (ou're free, however, to ma#e a handful of boards from this design to control $our own motors! +his version of the board includes a 4umper to ground the BUS( signal on the parallel port (pin .. and it brings out the S+R<B:, :RR<R, =)P and S:":)+ signals to allow for possible 4umpering! +hese changes ma#e it slightl$ more li#el$ that this board can be hac#ed to wor# with native operating s$stem drivers for the parallel port! =s is, with no special 4umpering other than the grounding of BUS(, it wor#s under "inu5! +o use the artwor# in 3igure @!D for etching a board, reproduce it at .-- pi5els per inch (a slightl$ finer version, using .D- pi5els per inch, is also available ! Both versions are positive images of the foil side of the boardE depending on how $ou transfer the image to the resist for etching, $ou ma$ need to flip it left*to*right andIor invert the blac# and white! Most BI3 viewers allow for such transformations!

3igure @!@ shows the component side of this board, with 4umpers and parts in place!

Figure 6.6

;ote that this la$out does not show mounting holes for the board, but that ? corner pads are provided in appropriate locations! +he la$out also doesn't show a power connector, but the standard ?*pin Mole5 connectors used with D!1D& dis#ettes will fit the pads provided! +he 1@ pin header is wired so that it can be directl$ wired to a 1D pin 7B*1D plug using ribbon cable and insulation displacement connectors! If multiple motors are to be used, a single ribbon cable can be made with multiple 1@ pin connectors on it, one per motor! 3igure @!@ shows ? capacitors, > between FD and ground, and . between F.1 and ground! +he two capacitors farthest from the power input connector can be !-. or !. microfarad capacitorsE it ma$ be better to use larger capacitors at the power input pins, . microfarad or more! +he plug from the stepping motor goes on the the top header shown in 3igure @!@, with the center* tap lead(s topmost! +he board is arranged so that either a D or @ pin header ma$ be used here, compatable with the plugs on the motors shown in 3igure @!.! +he limit switch goes on the bottom header! +he latter is wired so that it can be used with either microswitch salvaged from a full*height +andon D!1D inch dis#ette drive! +he address ma$ be hard*wired using ? 4umpers, or it ma$ be set using a 7I%*switch, as shown in 3igure @!@! :ach bit of the address is set b$ two switches or 4umper positions, the topmost pair of these sets the most significant of the ? bits! +o set a bit to ., close the top switch and open the bottom switch in the corresponding pair (or put the 4umper in the top position of the pair E to set a bit to -, close the bottom switch and open the top one (or put the 4umper in the bottom position of the pair ! If it is at all li#el$ that someone will change the address switches while power is applied to the board, use a ?0 ohm resistor in place of the 4umper directl$ above the switchesG +his will protect $our power suppl$ from the accidental short circuits that can result from improper switch settings!

Testing the Board


Under Linu%
+he standard "inu5 line printer driver attaches the device /de*/lp0 to the standard parallel port found on most %)s, and /de*/lp1 and /de*/lp2 to the optional additional parallel ports! +he line

printer driver has man$ operating modes that ma$ be configured and tested with the t1nelp command! +he default mode wor#s, and the following t1nelp command will restore these defaultsC
t1nelp /de*/lp0 -i 0 -2 0 -a o -o o -c o +his turns off interrupts with -i 0 so that the board need not deal with the ac#nowledge signal, and it uses a ver$ brief strobe pulse with -2 0, sets the parallel port to ignore the error signal with -a o , ignores the status when the port is opened with -o o , and does not chec# the status with each b$te output with -J o ! +he settings of the tunelp options -t and -c should not matter

because this interface is alwa$s read$ and thus polling loop iteration is never re6uired! Biven a correctl$ configured printer port, the ) routines allow output of motor control b$tes to the portC
/0000 0 ppacce++?c 0 0 pacKage or Iin1x acce++ to t.e parallel port 0 0000/ #incl1de B cntl?.> #incl1de B+=+/ioctl?.> #incl1de Berrno?.> #incl1de Blin1x/lp?.> #incl1de B+tdio?.> #de ine paperCempt= 0x20 +tatic int pp) /0 parallel port de*ice de+criptor 0/ *oid pp+et1p,/0 +et1p acce++ to t.e parallel port 0/ & pp % open,L/de*/lp0L'5CWD5HIM' 0-) i ,pp B 0- & print , Lcan>t open' %+NnL' C+=+Cerrli+t#errno$ -) exit, 0 -) ( ( int ppp1t,int b/0 p1t b to t.e parallel port' ret1rn t.e +tat1+ 0/ & c.ar cb1 % ,c.ar- b) int ib1 ) /0 begin critical +ection 0/ i ,2rite, pp' 6cb1 ' 1 - O% 1-& print , L2rite error' %+NnL' C+=+Cerrli+t#errno$ -) exit, 0 -) ( i ,ioctl, pp' I"PET!TFT3!' ,c.ar0-6ib1 - B 0-& print , L/de*/lp0 ioctl error' %+NnL' C+=+Cerrli+t#errno$ -) exit, 0 -) ( /0 end critical +ection 0/ ret1rn ib1 6 paperCempt=) (

+he comments above indicate a critical sectionG +his is onl$ a concern if the parallel port is shared b$ multiple processes, perhaps with one process in charge of each of a number of motors! In that case, a semaphore must be used to guard the critical section (see the U;IA semctl( #ernel call , or

a file loc# using 3Y"<)P and 3*U"<)P fcntl( commands, preferabl$ through the loc#f( function with a ver$ large si'e! +he latter approach (file loc#ing using loc#f( is probabl$ preferable! Biven these routines, the following main program should spin the motor at a few steps per second in a direction that depends on the sense switch settingC
/0000 0 +pin?c 0 Iin1x program to +pin a permanent magnet motor 0 t.e +en+e +2itc. gi*e+ or2ard/re*er+e control 0 0000/ #incl1de B1ni+td?.> #de ine motorCn1mber 15 #de ine micro+ec 1 #de ine milli+ec ,10000micro+ecint +teptab#$ % & 8' 10' 9' 5 () main,& int +tep % 0) pp+et1p,-) or ,))- & i ,ppp1t,+teptab#+tep$QmotorCn1mberBB4-- & +tep % ,+tep + 1-63) ( el+e & +tep % ,+tep - 1-63) ( 1+leep, 100 0 milli+ec -) ( (

Under 'uasic
+o test $our board, use the following little basic program! +his was developed under Microsoft's Rbasic ()C7<SIRB=SI) on a t$pical off*the*shelf %) under bare MSI7<S (no version of windows running ! +his code has been tested with the protot$pe hardware for the design given above! +he first subroutine in this program outputs the data 7 to motor M attached to printer port %, and reads the status into S!
100 53T "' D + ,19 0 :53T " + 2' 6RD 53T " + 2' 6RJ ! % 4H",p + 1DET3DH

+he second subroutine updates 7, the motor control output, to rotate the motor one step, then uses the first subroutine to output 7!
200 4G D % 8 TREH D % 10 EI!E4G D % 5 TREH D % 8 EI!E4G D % 9 TREH D % 5 EI!E4G D % 10 TREH D % 9 EHD 4G P5!3E 100

DET3DH

+he main program connects the second subroutine to the real*time cloc# and uses it to step the motor once per second, then repeatedl$ prints the status reported b$ the motor!
" % 6R3A7 : % 15 D % 10 5H T4:ED,1- P5!3E 200 T4:ED 5H 305 I5JFTE 5' 5 "D4HT L!TFT3!@ L) !) L P5T5 305

Unfortunatel$, RB=SI) doesn't give $ou access to the high resolution of the hardware real*time cloc#, so this protot$pe code is onl$ good for testing the hardware! 2hile this code is running, the status of the microswitch (if connected will be displa$ed on the screen, embedded in the rest of the !II< port status word

You might also like