13
Outline Motion Control Sensors for Motion Control Position Encoders • Incremental • Absolute Encoder Interfacing • Decoding Control of Electric Motors Control of Electric Motors DC Motors H-bridge Drivers • Relays Stepper Motors Example Example Chapter 11 ME 534 2 Position Sensors Most motion control applications require accurate position and velocity measurements. Position sensors, which can provide velocity estimates, are of major interest in industrial automation: Optical Position Encoders (= Digital Sensors) • Rotary Linear (a.k.a. “Linear Scales”) Resolvers (= Analog Sensors) • Rotary Linear (a.k.a. “Inductosyn™”) Chapter 11 ME 534 3 Rotary Optical Position Encoders Opto-electro-mechanical devices for measuring position: Robust and reliable Robust and reliable, Provide digital outputs, Absolute/incremental and rotary/linear versions are available rotary/linear versions are available, Decoder circuits are needed to process encoder signals, Cost goes up with the increasing resolution. Coutesy of Heidenhain Corp. Chapter 11 ME 534 4 Structure of Incremental Encoders Structure of Incremental Encoders Encoders consist of a stripped disk in between a light source (LED) and a photo-detector. Depending on angular position of Depending on angular position of the disk, the stripes on the disk may either block or let the light pass through pass through. Photo-detector emits a series of electrical pulses as it gets to detect light during the rotation of the disk. Note the spatial relationship between the disks position and the Courtesy of National Instruments between the disk s position and the pulse-stream being generated. Chapter 11 ME 534 5

Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Outline – Motion Control• Sensors for Motion Control

– Position Encoders• Incremental• Absolute

– Encoder Interfacing• Decoding

Control of Electric Motors• Control of Electric Motors– DC Motors

• H-bridge Drivers• Relays

– Stepper Motors• ExampleExample

Chapter 11 ME 534 2

Position Sensors• Most motion control applications require

accurate position and velocity measurements.• Position sensors, which can provide velocity , p y

estimates, are of major interest in industrial automation:– Optical Position Encoders (= Digital Sensors)

• Rotary • Linear (a.k.a. “Linear Scales”)

– Resolvers (= Analog Sensors)• Rotary • Linear (a.k.a. “Inductosyn™”)

Chapter 11 ME 534 3

Rotary Optical Position Encodersy p

• Opto-electro-mechanical devices for measuring position:– Robust and reliableRobust and reliable,– Provide digital outputs,– Absolute/incremental and

rotary/linear versions are availablerotary/linear versions are available,– Decoder circuits are needed to

process encoder signals,– Cost goes up with the increasing

resolution.

Coutesy of Heidenhain Corp.

Chapter 11 ME 534 4

Structure of Incremental EncodersStructure of Incremental Encoders• Encoders consist of a stripped disk

in between a light source (LED) and a photo-detector.

• Depending on angular position ofDepending on angular position of the disk, the stripes on the disk may either block or let the light pass throughpass through.

• Photo-detector emits a series of electrical pulses as it gets to detect light during the rotation of the disk.

• Note the spatial relationship between the disk’s position and the Courtesy of National Instrumentsbetween the disk s position and the pulse-stream being generated.

Chapter 11 ME 534 5

Page 2: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Structure (Cont’d)( )• An encoder producing one set of pulses would not be useful since it

could not indicate the direction of rotation.could not indicate the direction of rotation. • Almost all incremental encoders generate a second set of pulses

that is 90o out of phase with the first one.• Most rotary encoders produce an index pulse per revolution using a• Most rotary encoders produce an index pulse per revolution using a

third detector (C) to indicate a reference position on the disk.

Chapter 11 ME 534 6

Structure (Cont’d)Structure (Cont d)

• Output of the photo-detector is not exactly a squareOutput of the photo detector is not exactly a square wave (more like a sinusoidal pattern) since the intensity of the light varies as a function of disk position.g

• A circuitry shapes up the output (for each channel) to a crisp square voltage-waveform.

Chapter 11 ME 534 7

Decodersecode s

• An interface circuit is necessary to derive• An interface circuit is necessary to derive position from incoming pulses.

1X decoding (or interpolation):– 1X decoding (or interpolation):• (H to L) or (L to H) transitions in one channel are counted.

– 2X decoding:2X decoding:• (H to L) or (L to H) transitions in both channels are counted.• 2 logic transitions per grid (period) are detected.g g ( )

– 4X decoding (the best one!):• (H to L) and (L to H) transitions in both channels are counted.• 4 logic transitions per period are detected.• Highest possible resolution is achieved in this case.

Chapter 11 ME 534 8

4X Decodingg• Counting transitions in both

channels yields the angular +5V

A Leads B (Forward Rotation)y g

position of its shaft: θ = 90on/N.– N is # of gratings on the disk.– n is the count value of transitions

Channel A

Channel B+5V

up to a particular time.• While counting transitions, one

must keep track of the direction:Channel C

+5V

360o/Np– If forward, count up.– If reverse, count down.

• Direction can be detected:

360 /N

+5V

B Leads A (Backward Rotation)Direction can be detected:

– If A leads B ⇒ forward rotation.– If B leads A ⇒ backward rotation.

Channel A

Channel B

+5V

+5V

Channel C+5V

Chapter 11 ME 534 9

360o/N

Page 3: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

4X Decoding (Cont’d)

8n+10

90o/N)on

n+2n+4n+6n+8

Regi

ster

edgu

lar P

ositi

o

Time

nn-2

Ang

Channel A

n n+2 n+4 n+6 n+8 n+10 n+9 n+7 n+5 n+3 n+1 n-1 n-3

Time

Channel B

n+1 n+3 n+5 n+7 n+9 n+8 n+6 n+4 n+2 n n-2

System decelerates to a full-stop. System start to accelerate in reverse direction.

Time

Chapter 11 ME 534 10

Encoder/4X Decoder Model

A A

Channels

A

B

dir

DirectionMonitor

Quadrature Decoder (4X)

Sine Wave

Quantizer

thB

QuadratureEncoder

Bth_cts

QuadratureDecoder (4X)

Position

-K-

Gain

1th_cts

z

1

U i D l

-u

Unary Minus

Switch

z-1

z

Difference

ClkClk CntCntUp

ClkClk CntCntUp

Counter A

2

1A

Unit DelayClkClk CntCntUp

Counter B

2B

1iK

5

Constant

1

DirectionMonitor1

Asin

TrigonometricFunction

Switch

-K-

N

0

1th

er In S/H

In S/H

Sampleand Hold

Monitor

5

Constant2

Constant1

re E

ncod

e

1dir

In S/H

Sampleand Hold1

ANDNAND

LogicalOperator

1

2B

cos

TrigonometricFunction1

Switch1

0

Qua

drat

ur

In S/H

Sampleand Hold2

LogicalOperator2

2B

A

Chapter 11 ME 534 11

Constant3

Q

Sampleand Hold3

B

Resolution of Incremental Encoders

• Resolution is indicated by theResolution is indicated by the number of gratings on the disk.– Number of pulses being

generated in one channel pergenerated in one channel per one revolution.

• Common resolutions are– 200, 500, 1000, 2000, 5000,

10000 pulses/rev.• Cost goes up with the increasing g p g

resolution due to sophisticated manufacturing process:– Etching micro-gratings on a– Etching micro-gratings on a

glass disk covered with chromium.

Courtesy of Heidenhain Corp.

Chapter 11 ME 534 12

y p

Absolute Encoder (Cont’d)( )• Major drawbacks of

i l dincremental encoder are– A decoder circuitry is needed.– In case of a power failure, the p ,

decoder will lose information on the current position.

• Absolute encoders areAbsolute encoders aredesigned to tackle with theseproblems.O ti i i l i i il t• Operating principle is similar to that of the incremental one: – has 8 to 16 photo-detectors– uses a coded disk generating

a unique binary output per segment.

Chapter 11 ME 534 13

g

Page 4: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Absolute Encoder (Cont’d)( )• Since each channel generates a particular digit g p g

of a binary number, it is customary to specify the resolution by bits (N):y ( )– 8-bit, 10-bit, 12-bit, ..., 16-bit– Angular resolution is 360o/ 2N.g

• Absolute encoders are very expensive due to the complexity involved in the manufacturingthe complexity involved in the manufacturing process (photo-lithography). – Price goes exponentially up with the resolutionPrice goes exponentially up with the resolution.

Chapter 11 ME 534 14

Infinite Resolution Encoders

• Incremental encoders generating sinusoidal waveforms (instead of pulses) are referred to as infinite resolution encoders.– Name is a bit misleading!g

• One can interpolate the magnitudes of two orthogonal sinusoidal waveforms (A and B) toorthogonal sinusoidal waveforms (A and B) to find the exact location of shaft within one (grate) period.period.

Chapter 11 ME 534 15

Terminal Signalse a S g a s

• Following signals are available in a generic• Following signals are available in a generic incremental encoder:

• ChA: channel A• ChA: channel A• ~ChA: complement of channel A• ChB: channel BChB: channel B• ~ChB: complement (negation) of channel B• IX: index (sometimes called ChC)de (so e es ca ed C C)• ~IX: complement of index• Vdd: Supply voltage for the encoder (+5V)dd pp y g ( )

– Can be 3 to 24 Volts depending on the app.• Vss: digital ground

Chapter 11 ME 534 16

Types of Encoder Interfacesypes o code te aces

• Two types of encoder interfaces:• Two types of encoder interfaces:– Single-ended

Differential– Differential• Single-ended encoders are quite common:

– Encoder and its interface are located in close proximity (~a few meters or less).

N i ( i k ) i t bi i• Noise (pick-up) is not a big issue.

– Vss is connected to the digital ground. ChA and ChB are directly employed as TTL inputs– ChA and ChB are directly employed as TTL inputs to the interface circuitry.

Chapter 11 ME 534 17

Page 5: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Encoder Interfaces (Cont’d)code te aces (Co t d)• Differential interfaces are used when the encoder

d it i t f t b l t d f t (lik tand its interface must be located far apart (like tens of meters).

– Noise pick-up and degradation of transmitted signal become important issuesbecome important issues.

– “Balanced” digital data transmission is needed.• In such interfaces, the potential difference between

ChX and ChX (X: A or B) yields the desired logicChX and ~ChX (X: A or B) yields the desired logic signal:

– ChX (wrt. to Vss) ∈ {0, 2.5V}ChX ( t T V ) {0 2 5V}– ~ChX (wrt. To Vss) ∈ {0, -2.5V}

• Differential line receivers (such as DS26C32) are commonly used for this purpose:

– Accept differential encoder inputs – Yield corresponding TTL or CMOS logic outputs.

Courtesy of National Semiconductors.

Chapter 11 ME 534 18

Processing Quadrature Signalsocess g Quad atu e S g a s

• Encoder “quadrature” signals must be• Encoder quadrature signals must be processed to obtain position information in most casescases.– Some DSPs and advanced microcontrollers have

built-in quadrature encoder interfacesbuilt in quadrature encoder interfaces.• There are various options to convert quadrature

signals into position “counts”:signals into position counts :– Custom digital circuits

Quadrature decoder ICs– Quadrature decoder ICs – Quadrature decoder / counter interface ICs

Chapter 11 ME 534 19

Custom SolutionsCusto So ut o sChA

CLKt

CLKOUT

XORCLKOUT

tDIR Sign Error

D Q

D-F/F

ChB

DIRChA

t

ChB

System decelerates to a full-stop. System start to accelerate in reverse direction.

t

• A custom interface with 2X decoding can be designed with an XOR gate and a D flip/flop.O t t f th i it b di tl t d t th PIC18F4520• Outputs of the circuit can be directly connected to the PIC18F4520:– CLKOUT to Timer1 (RC1/T1CK1) for counting– DIR to (RB0/INT) for sign detection

Chapter 11 ME 534 20

Encoder-to-Counter Interface ICs*• Produced by US Digital

( f USD i(cost ~ a few USD in quantity)

• Drives standard counters• Drives standard counters– Mostly used as inputs to

“on-board” counters of microcontrollersmicrocontrollers.

• No external clock is required.q

• Features – 1X or 4X interpolation

d

LS7083 • Outputs are UpClk and DnClk• Can be connected to 74193 or 40193 mode

– TTL/CMOS compatible I/O– Low power

Can be connected to 74193 or 40193LS7084• Outputs can Clock and UP/DN (direction)• Can be connected to 74169 or 4516

Chapter 11 ME 534 21

p

[*] Courtesy of US Digital.

Page 6: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Advanced ICs: HCTL-2032*d a ced Cs C 03• Produced by AgilentProduced by Agilent

Technologies (cost ~7 USD)• Interfaces between encoder and

microcontrollermicrocontroller– Needs an external clock signal

• Has programmable interpolation dmodes:

– 1X, 2X, or 4X• Supports dual axisSupports dual axis• Features

– 32-bit binary up/down counter8 bit t i t t i t f– 8-bit tri-state interface

– TTL/CMOS compatible I/O

Chapter 11 ME 534 22[*] Courtesy of Agilent Technologies.

Conventional DC MotorCo e t o a C oto• Stator of a DC motor is composed of two

l ior more permanent magnet pole pieces. • Rotor is composed of windings which are

connected to a mechanical commutator. In this case the rotor has three pole pairs.

• Opposite polarities of the energized winding and the stator magnet attract andwinding and the stator magnet attract and the rotor will rotate until it is aligned with the stator.

• Just as the rotor reaches alignment, the brushes move across the commutator contacts and energize the next winding. g g

• A spark shows when the brushes switch to the next winding. Courtesy of Motorola, Inc.

Chapter 11 ME 534 23

Operating Modes of DC MotorOpe at g odes o C otoForward Motor

Tm

Reverse Generator • In motor mode the

+ia

Forward Motor

_

Reverse Generator • In motor mode, the machine drives the “load” and needs

M

_

VaM

+ia

Va energy from the supply.

m

_+

ia• In generator mode,

the “load-side” drives the machine and itM

+ia

Va M_

Vathe machine and it generates power.

Forward GeneratorReverse Motor

Chapter 11 ME 534 24

“Forward Motor” Controlo a d oto Co t oElectronically controlled

power switch

• Electronically-controlled (unidirectional) switch is

+

power switch

+Va

V

(unidirectional) switch is turned on/off rapidly.– Pulse width modulation

M+

VDC

_

Va

VDC

t

Va

Td • Desired (average) voltage at the terminals of DC motor is obtained viat

Tp motor is obtained via controlling switching times:

S1

TLa

+D1

Ra

ea

+VDC Back

E.M.F.

ia dVTTVV DCp

dDCa ⋅==

where T is PWM period_

DC Motor

where Tp is PWM period(constant) and Td/Tp = d is called duty cycle.

Chapter 11 ME 534 25

is called duty cycle.

Page 7: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Forward Motor Control (Cont’d)o a d oto Co t o (Co t d)• When S1 is turned off, iaLaRS

Mode 1:When S1 is turned off, iaflowing through the motorcannot be cut offimmediately

La

D1 :off

Ra

e

+

V

ia

S1 :on

immediately.– It must flow somewhere!

• “clamp” diode allows

D1 :off ea

_

VDC

clamp diode allows current flow in Mode 2: – La drives a decaying

currentLaRaS1 :off

Mode 2:

current.• If D1 isn’t in place, a very

large voltage will build up D1 :on ea

+

VDC

ia

S1 :off

g g pacross S1 and blow it up.

a

_DC

Chapter 11 ME 534 26

Four-Quadrant Motor Controlou Quad a t oto Co t o• “H” bridge is used to

D D

H bridge is used to operate the motor in four quadrants.

S2

D2 D4

S4

+

M

• Driver is composed of two half-bridges.

S1 S3

VDC

M

• Switches in a half-bridge cannot turned at the

tiD1 D3

Half-Bridge Half-Bridge

same time.– causes short-circuit.– If one of the switches is– If one of the switches is

turned, the other must be off.

Chapter 11 ME 534 27

Forward Motoro a d otoMode 1: Mode 2:

S2 D2 D4S4

ia

S2 D2 D4S4

ia

S1 D1 D3S3

VDC

S1 D1D3S3

VDC

• To go forward

1

To go forward,– S3 is fully turned on;– PWM and ~PWM (inverted PWM) signals are applied to S2 and S1

ti lrespectively.• Unidirectional switch S1 can carry current only in the indicated

direction.

Chapter 11 ME 534 28

Reverse Motore e se otoMode 1: Mode 2:

M M

• To go reverse,– S1 is fully turned on;– PWM and ~PWM signals are applied to S4 and S3

respectively.

Chapter 11 ME 534 29

Page 8: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Building H-bridgeu d g b dge

• Commercial Motor Drivers• Commercial Motor Drivers– Include all bells and whistles!

• Custom Solutions (high-power)Custom Solutions (high power)– Switches: Power MOSFETs, IGBT– Need gate drivers and signal isolation barriers.

• Bridge ICs (up to a few-hundred [W])– LMD 18200 – L298

• For driving small DC motors,L293D– L293D

– ULN 2003A

Chapter 11 ME 534 30

LMD 18200*8 00• Ideal for driving DC andIdeal for driving DC and

stepper motors,• Delivers up to 3A p

continuous output– Peak current of 6A

• Operates at supply voltages up to 55V,

• Accepts TTL and CMOS compatible inputs,

I t l h– Internal charge pump

• Quite expensive: 20 USD.

Chapter 11 ME 534 31[*] Courtesy of National Semiconductors.

L298: Dual H-bridge Driver*98 ua b dge e

• Constitutes two H bridges• Constitutes two H-bridges– Requires clamp diodes

• Supply voltage up to 46V• Maximum current is 4A• Over-temperature protection• Accepts TTL inputs

Chapter 11 ME 534 32

Accepts TTL inputs[*] Courtesy of ST Microelectronics.

L293D: Four Half-bridge Drivers*g

• L293 includes 4 Half-L293 includes 4 Halfbridge drivers.– Can drive two bidirectional

DC motorsDC motors.• L293D has clamp

(freewheeling) diodes.( g)• Wide supply-voltage

range: 4.5 V to 36 V• Output current for L293D

is 0.6A/channel– 1 2A peak

Half-Bridge

– 1.2A peak• Thermal shutdown

Chapter 11 ME 534 33[*] Courtesy of Texas Instruments.

Page 9: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Electromagnetic Relaysect o ag et c e ays• Relays are electromagnets connected

to mechanical switchesto mechanical switches.– When the electromagnets are energized,

the switches are pulled into contact.H th di i it i d– Hence, the corresponding circuit is powered up.

• Relays allow the control of high-power y g pdevices.– Small power is sufficient to energize

electromagnets in relayselectromagnets in relays. – Suitable for on/off control of slow devices:

• Pump (AC/DC) motors, solenoidsH t l t• Heaters, lamps, etc.

– If compared to solid-state switches, relays are more susceptible to malfunction.

Chapter 11 ME 534 34

Simple On/Off ControlS p e O /O Co t o12V 24V12V 24V

R lRelay

ULN2003A

1 16

9

M1N4004RX#1 16

• Most microcontrollers cannot source/sink in sufficient current to trigger relays.

• General purpose BJTs (2N2222, 2N3904, BC337, etc) or ULN2003A (Transistor Array) are utilized for this purpose.

Chapter 11 ME 534 35

Stepper MotorsSteppe oto s• Stepper MotorsStepper Motors

– Variable Reluctance (VR)• Rotor saliencyy

– Permanent Magnet (PM)• Magnets on rotor

– Hybrid Motors• Relies on both rotor saliency and magnets

• Each pulse moves rotor by a discrete angle (i e• Each pulse moves rotor by a discrete angle (i.e. “step angle”).

• Counting pulses tells how far motor has turned• Counting pulses tells how far motor has turned without actually measuring (no feedback!).

Chapter 11 ME 534 36

Advantages / Disadvantagesd a tages / sad a tages

Low costSimple and rugged

Resonance effects are dominantSimple and rugged

Very reliableM i t f

a e do a tRough performance at low speedMaintenance free

No sensors needed

at low speedOpen-loop operationCWidely accepted in

industryConsume power even at no loady

Chapter 11 ME 534 37

Page 10: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

(Simplified) Full-Step Operation( p ) p p• Rotor of a PM stepper

motor consists of at t

Current

N

Coil A Coil A

1 2

permanent magnet:– Stator has a number of

windings. N

S

S

Coil A

Coil BCoil D

S N

Coil BCoil D

• Just as the rotor aligns with one of the stator poles, the second h i i d

S

Coil C Coil C

Current

phase is energized. • The two phases

alternate on and off to Coil ACoil A

34

create motion. • There are four steps. Coil BCoil D

N

S

SN

Coil BCoil D

S

Coil CCurrentCoil C

Current

Chapter 11 ME 534 38

N

(Simplified) Half-Step Operation(S p ed) a Step Ope at oN

1 2N

3 4N

N

Current

S

Coil A

Coil BCoil D

Coil A

Coil BCoil D

N

1 2

S

Coil A

Coil BCoil D

Coil A

Coil BCoil D S3 4

S

Current

S

Coil C

S N

Coil C

Current

NS

Current

Coil C

S N

Coil C

Current

NS

S N

S

Current

Coil ACoil A

78Coil ACoil A

56

N

N

Current

Coil BCoil D

SN

Coil BCoil D

Current

NS

S

Coil BCoil D

NS

SN

Coil BCoil D

Current

NS

S

SN

S

Current

Coil CCoil C

N

Coil CCurrentCoil C

N

Current

Current

Chapter 11 ME 534 39

Half-Step Operation (Cont’d)a Step Ope at o (Co t d)

• Commutation sequence has eight steps instead of four.• Main difference is that the second phase is turned on

b f th fi t i t d ffbefore the first one is turned off. • Sometimes, both phases are energized at the same

timetime. • During the half-steps, the rotor is held in between the

two full-step positionstwo full-step positions.• A half-step motor has twice the resolution of a full-step

motor.motor. – Very popular due to this reason.

Chapter 11 ME 534 40

Winding ConnectionsgBipolar (4-wire):Unipolar (5-wire):

A C

B D

1 2

3 4B D3 4

• Unipolar motor:– Current flows through a coil

5

3Unipolar (6-wire):

Current flows through a coil only in one direction.

• Bipolar motor:A C1 2

– Current flowing through a winding changes direction during the operation.

B D4 5

Chapter 11 ME 534 41

during the operation. 6

Page 11: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Actual Stepper Motor*ctua Steppe oto• Stator of a real motor

constitutes more coilsconstitutes more coils (typically 8).

• Individual coils areIndividual coils are interconnected to form only two windings:– one connects coils A, C, E,

and G:• A and C have S-polarityA and C have S polarity• E and G have N-polarity

– one connects coils B, D, F, d Hand H:

• B and D have S-polarity• F and H have N-polarity

Chapter 11 ME 534 42

p y

[*] Courtesy of Microchip.

Stepper-Motor Animations*Steppe oto at o sFull-step: Half-step:

Chapter 11 ME 534 43[*] Courtesy of Motorola, Inc.

L297: Stepper Motor Controller*9 Steppe oto Co t o e

• Produced by• Produced by STMicroelectronicsTo be used in• To be used in conjunction with L298

f/f• Half/full step modeswith direction control iinput.

• Switch-mode load current regulation

Chapter 11 ME 534 44[*] Courtesy of ST Microelectronics.

Stepper Motor Drive with L293*Steppe oto e t 93• Half-bridge pair of L293 isHalf bridge pair of L293 is

utilized to drive a phase winding of a bipolar stepper motor.– Depending on control input

(Control A or B) current(Control A or B), current flows in one way or another.

• No external (clamp) diodes are needed if L293D i l dL293D is employed.

Chapter 11 ME 534 45[*] Courtesy of ST Microelectronics.

Page 12: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

Example – Unipolar Stepper Motorp p pp470 a

b

LS 5015-20 Vdd = 5V

RD2RB6

• Let us develop a C program for a PICmicro controlling the (unipolar)

bcdef

20 k(pot.) RA2

RD2RB7

RB1

RB2

RB3

RB5

g ( p )stepper motor shown.

• 20kΩ pot. is used to adjust the speed. When the voltage on AN0 is

g K

470

Vcc = 12V

RB5

RB4 – 5V → motor rotates CW direction at its max. speed.

– 2.5V → motor is off.0V motor rotates CCW direction atVcc 12V

ULN2003A

RD7

Unipolar Stepper Motor

1 16

9

– 0V → motor rotates CCW direction at its max. speed.

• LED indicates the direction of motion.• SSD shows speed as a hex number

RD62

3

15

14

• SSD shows speed as a hex. number (0: min; F: max)

• Here, ULN2003A (transistor array) serves as “electrically” controlled

RD5

RD4

3

4

14

13

serves as electrically controlled switch.

– When 5V is applied by PICmicro, it conducts current (up to 1A).

Chapter 11 ME 534 46

Example - Drive Sequences a p e e Seque cesFull-step:

lock

wis

e

nter

-CW

Cl

Cou

n

Half step:

tion

wis

e

Half-step:

wis

e R

otat

er-c

lock

w

Clo

ckw

Cou

nte

Chapter 11 ME 534 47

C Program: Half-stepg p#include <18F4520.h>#device ADC=10#fuses HS NOWDT NOPROTECT NOLVP#fuses HS,NOWDT,NOPROTECT,NOLVP#use delay(clock=20000000)#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)#use fast_io(B)#use fast io(D)#use fast_io(D)#org 0x3F00,0x3FFF {}#opt 9#byte PORTB = 0xF81#byte PORTB 0xF81#byte PORTD = 0xF83#bit LED = PORTD.2void ss disp(int num) { /* Seven segment display routine */void ss_disp(int num) { / Seven segment display routine /byte const SSData[16] = {238,130,220,214,178,118,126,226,

254,246,250,62,28,158,124,120};if(num < 16){if(num < 16){output_b(SSData[num]);

}}

Chapter 11 ME 534 48

C Program (Cont’d)C og a (Co t d)

void main() {// // Full step sequence (Uncomment!)//// byte const step[8] = {192,96,48,144,192,96,48,144};byte const step[8] = {192,64,96,32,48,16,144,128}; /* Half-step sequence */byte temp = 0;long adval;gint i = 0;set_tris_b(0); /* Set up digital I/O pins */set tris d(3);_ _PORTB = 0; PORTD = 0;setup_adc_ports(AN0_TO_AN3); /* Set ADC */setup_adc(ADC_CLOCK_INTERNAL);_ _ _set_adc_channel(2);

Chapter 11 ME 534 49

Page 13: Outline – Motion Control Position Sensorscourses.me.metu.edu.tr/courses/me534/protected/ME... · – 32-bit binary up/down counter – 8-bit t ibit tri-stt it ftate interface –

C Program (Cont’d)C og a (Co t d)while(TRUE) {delay_us(200);adval = read_ADC()>>3;if (adval>60 && adval<68) { /* Motor is off */ss_disp(0); PORTD = 0;

}else if(adval>=68) { /* CW direction */ss_disp((adval>>2)-16);adval = 132 - adval;if (++i>7) i = 0; temp = (PORTD&15)+step[i];PORTD = temp; LED = 1; delay_ms(adval);

}else {ss_disp(16-(adval>>2)); /* CCW Direction */adval += 4;if (--i>7) i = 7; temp = (PORTD&15)+step[i];PORTD = temp; delay_ms(adval);

}}

}

Chapter 11 ME 534 50