0% found this document useful (0 votes)
19 views19 pages

Unipolar Stepper Motor Driver

This application note details the use of a unipolar stepper motor drive utilizing the Z8 Encore!® microcontroller, highlighting its advantages in high torque applications and simple firmware requirements. It covers the operational principles of stepper motors, including full-step and half-step driving methods, along with practical hardware and software implementations. Additionally, it provides schematics and discusses the electrical characteristics and torque-speed relationships relevant to stepper motor performance.

Uploaded by

diwyanvithana09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views19 pages

Unipolar Stepper Motor Driver

This application note details the use of a unipolar stepper motor drive utilizing the Z8 Encore!® microcontroller, highlighting its advantages in high torque applications and simple firmware requirements. It covers the operational principles of stepper motors, including full-step and half-step driving methods, along with practical hardware and software implementations. Additionally, it provides schematics and discusses the electrical characteristics and torque-speed relationships relevant to stepper motor performance.

Uploaded by

diwyanvithana09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Application Note

A Unipolar Stepper Motor Drive Using the


Z8 Encore!® MCU

AN012805-0708

Abstract SRAM, and an extensive array of on-chip peripher-


als. These peripherals make the Z8 Encore!® suit-
Stepper motors that feature unipolar drives are able for a variety of applications including motor
widely used in applications that require high torque control, security systems, home appliances, per-
loads and fast position attainment. The unipolar sonal electronic devices, and sensors.
operation provides stable motor control using a rel-
atively simple firmware, as compared to bipolar
drives.
Discussion
A discussion about stepper motors is presented in
This Application Note discusses the use of a typi- this section.
cal 8-wire or 6-wire stepper motor, in the unipolar
mode of operation, with a Z8 Encore!® microcon- General Overview of Stepper Motors
troller.
Stepper motors are characterized by high torque
Also discussed are the practical aspects of the full- and are capable of handling large loads with pre-
step and half-step methods of driving a stepper cise movements. The advantages of stepper motors
motor, as well as a complete hardware and soft- over stepless AC or DC motors include:
ware implementation using the Z8 Encore!® MCU.
A simple schematic using readily-available compo- • No feedback requirement for position or speed
nents, along with the full source code in C, is used control (open loop operation)
to implement a stepper driver. This basic hardware • Noncumulative positional errors
and software combination can be incorporated into
larger control circuits with suitable modifications. • Precise electronic speed control using digital
technology
Z8 Encore!® Flash MCU • Compact size for driving large loads at low
speeds
Overview
With the advent of microcontrollers, stepper drive
Zilog’s Z8 Encore!® products are based on the new technology has advanced rapidly both in terms of
eZ8 CPU and introduce Flash memory to Zilog’s flexibility and complexity. The new Z8 Encore!®
extensive line of 8-bit microcontrollers. Flash series of Flash microcontrollers enable drive
memory in-circuit programming capability allows designers to implement full functionality while
for faster development time and program changes maintain a low component count.
in the field. The high-performance register-to-reg-
ister based architecture of the eZ8 core maintains
Stepper Motor Construction
backward compatibility with Zilog’s popular Z8
MCU. Figure 1 shows a typical stepper motor with four
salient stator poles (the fixed part) and two rotor
The new Z8 Encore!® microcontrollers combine a poles (the moving part). The stator poles are
20MHz core with Flash memory, linear-register wound with a set of windings featuring two coils
each, connected in series on opposite poles (form-

Copyright ©2008 by Zilog®, Inc. All rights reserved.


www.zilog.com
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

ing two phases), while the rotor poles are perma- Stepper motors feature stator windings that are
nent magnets comprised of soft alloy steel. wound in unipolar or bipolar fashion on any num-
ber of poles; the mechanical step size usually
ranges from 0.9° to 18°. In the unipolar mode of
operation, the current flow in the windings always
remains in the same direction to achieve rotor
movement. A bipolar mode, on the other hand,
involves an alternate reversal of the current flow in
N
the windings to achieve rotation.

S An Electrical Drive for a Stepper Motor


An electrical drive provides the requisite amount of
current to the windings of the stepper motor in a
predefined sequence. A typical scheme for unipo-
Phase 1 ON lar drives is shown in Figure 3.
Phase 2 OFF
Vdd

Figure 1. A Simple Stepper Motor W1 W2 W3 W4

Sequentially energizing the two windings causes


the rotor poles to align with the electric poles and Q1 Q2 Q3 Q4

create the rotor movement (see Figure 2). The


equilibrium states of the rotor are called detent
positions and are fixed according to the mechanical
structure of the motor.

Figure 3. A Unipolar Drive Scheme for a 6-


or 8-Lead Stepper Motor

The four windings are energized in a sequential


manner to rotate the shaft. The number of steps
S N
required to make one revolution equals 360 ÷ (step
size). For a 2-phase wound stepper motor with 1.8°
mechanical step size, the total number of steps is
360 ÷ 1.8 = 200.

Phase 1 OFF The number of steps performed by a stepper (reso-


Phase 2 ON
lution) can be increased by changing its sequence.
To generate 200 steps, the full-step mode (see
Table 1) is employed. To generate 400 steps (i.e., a
resolution of 0.9) half-step mode (see Table 2) is

Figure 2. Sequential Winding Energization

AN012805-0708 Page 2 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

required. The reversal of direction in both cases is methods (as per Table 2) for a four-phase motor,
achieved by reversing the sequence only. and S4–S3–S2–S1 for the counterclockwise rota-
tion. The excitation scheme for the 2-ph On
The excitation method of the unipolar drive can be method requires 2 windings to be energized at the
a single-phase On (1-ph On) or a two-phase On (2- same time in an 8-sequence pattern.
ph On) operation. Table 3 shows the 1-ph On
method and Table 4 shows the 2-ph On method for The advantages of the 2-ph On method over the 1-
a four-phase wound motor. ph On method are higher torque and stable, smooth
rotations, due to the fact that two windings are
The excitation scheme is S1–S2–S3–S4 for the energized at a time. The half-step mode effectively
clockwise rotation in the 1-ph On and 2-ph On combines the 1-ph On and 2-ph On methods.

Table 1. Full-Step Mode Table 2. Half-Step Mode

Wdg 1 Wdg 2 Wdg 3 Wdg 4 Wdg 1 Wdg 2 Wdg 3 Wdg 4


Clockwise

Anti-clockwise

Seq 1 1 0 1 0 Seq 1 1 0 1 0
Seq 2 1 0 0 1 Seq 2 1 0 0 0
Seq 3 0 1 0 1 Seq 3 1 0 0 1
Seq 4 0 1 1 0 Seq 4 0 0 0 1
Seq 5 0 1 0 1
Seq 6 0 1 0 0
Seq 7 0 1 1 0
Seq 8 0 0 1 0

Table 3. 1-Ph On Method Table 4. 2-Ph On Method

1 2 3 4 5 6 7 8 Pulses 1 2 3 4 5 6 7 8
Wdg 1 1 0 0 0 1 0 0 0 Wdg 1 1 1 0 0 1 1 0 0
Wdg 2 0 1 0 0 0 1 0 0 Wdg 2 0 1 1 0 0 1 1 0
Wdg 3 0 0 1 0 0 0 1 0 Wdg 3 0 0 1 1 0 0 1 1
Wdg 4 0 0 0 1 0 0 0 1 Wdg 4 1 0 0 1 1 0 0 1

A better way to achieve higher resolution is by microstepping method is mainly used in applica-
using the microstepping method, in which a tions that require a greater degree of control for
mechanical step is subdivided into many steps. By precise movement, such as in X-Y table applica-
energizing the windings in various combinations, a tions.
required angular rotation can be executed. The

AN012805-0708 Page 3 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

However, the hardware in this Application Note is istics (in Figure 5) show the ability of the motor to
limited to the construction of a unipolar drive, and sustain rotation at a particular torque without los-
the software uses the 2-ph On method in both full- ing step synchronism.
step and half-step modes.

The Electrical and Mechanical


Characteristics of a Stepper Motor
The amount of holding torque, a typical parameter
P1
of a stepper motor, determines the choice of motor
for a particular application. Holding torque is
defined as the maximum amount of torque that can

Torque
Pull-out torque
Pull-in torque
be applied on the shaft of an energized but stopped
motor without causing rotor slippage. The holding
torque and winding current relation is nearly linear, P2 P3
as shown in Figure 4, and the minimum amount of 0
Step Frequency (Hz)
torque on the Y-axis, appearing at zero current, is No start range
the detent torque.
No rotate range
Holding Torque

Figure 5. Torque vs. Speed Characteristics

The main parameter governing the torque-speed


curve is the L/r ratio of the windings. The induc-
tance (L) and the resistance (r) decide the maxi-
mum operating frequency of the motor, where the
equation:

Phase Current r = rwinding + rexternal

determines the total winding resistance.

Figure 4. Holding Torque vs. Current Increasing r by introducing external resistance


rexternal in series with the windings has the effect of
With more current in the windings, the magnetic shifting the pull-out curve towards the right,
force applied on the rotor by the stator increases. thereby enabling the motor to rotate at higher
Electrical drives utilize this curve to minimize the speeds, although at lowered torque values.
winding current when the motor is stopped for a
long time. Heat dissipation in the motor is thereby The motor can lose speed or stall completely
reduced, as well as energy use. between the minimum and maximum pulse rates,
or rotational speeds, applied to a motor. At these
The pull-in torque characteristics of a stepper points, oscillations are created in the winding cur-
motor (see Figure 5) demonstrate the ability of the rents that result in an unstable rotation of the
motor to start with a particular amount of torque motor. Typically, these points are divided into low-
placed on the shaft. The pull-out torque character-

AN012805-0708 Page 4 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

mid- and high-frequency areas, as depicted in Implementing Unipolar Stepper


Figure 6.
Drive
Unipolar Drive Hardware
Description
Low Mid High Frequency Ranges The schematic (see Figure 14 on page 4) consists
of generally-available components and is simple to

build and test. The heart of the circuit is the Z8


Dip Encore!® microcontroller, which operates at
Torque 18.432 MHz. With a VCC of 3.3 V, the power con-
sumption and heat dissipation of the Z8 Encore!®
Island microcontroller is greatly reduced.

Step Rate (pps) The circuit consists of buffer transistors Q1, Q2,
Q3, and Q4 driving the power MOSFETs T1, T2,
T3, and T4, respectively. There are four buffer-
driver power MOSFET units on four GPIO pins
Figure 6. Typical Regions of Resonance that individually energize each of the four wind-
ings of the stepper motor.
These resonance frequencies must be avoided
when a drive is tuned for a particular motor. A Figure 8 presents a schematic diagram of a single
mechanical damper, illustrated in Figure 7, is cou- stage of the power driver.
pled to the motor shaft, and can be used to damp
the resonance points.

Friction Pad Inertial Load

Spring Friction Pad


Lock Nut

Figure 7. Spring-Friction Inertial Damper

AN012805-0708 Page 5 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

VDD D5
1N4001
R17
1k,0.5W
T1 VDD
Q1 IRFZ44N
BC547 R5 ZD1
3k3 5V1

D1 LED1 R13
1N4148 1E,5W
R9
4k7

6
5
3
2
1

MG1
6-lead Stepper Motor

Figure 8. A Power Driver Stage Using N-Channel MOSFET

In Figure 8, note the following: • Resistor R17 limits the gate current.
• Diode D5 removes any surges in the winding
• Diode D1 protects the I/O pin from surges origi- above a voltage level of VDD.
nating on the power circuit side.
• Resistor R9 pulls the Q1 base Low by default
• Resistor R5 drives the LED1 when the winding and prevents it from conducting at spurious sig-
is energized. nals.
• Transistor Q1 acts as a buffer driver for MOS- • Power resistor R13 is used to balance the L/r
FET T1 by switching off when the I/O pin is ratio of the windings and to limit the current
Low and vice-versa, allowing the MOSFET to depending on the resistance of the windings. An
conduct current and energize winding W1. The additional potential divider across this resistor
choice of N-channel MOSFETs depends on the can be used to sense the winding current by uti-
voltage and current rating of the motor. In our lizing other ADC inputs of the Z8 Encore!®
example, IRFZ44N is chosen based on the motor microcontroller, as illustrated in Figure 9.
specifications of 12V and 1.25Amps per wind-
ing. Because the MOSFET carries a high current,
consider using a proper heat sink with a heat sink
compound.
• Zener diode ZD1 ensures that the firing voltage
on the gate of the MOSFET does not exceed 5V.

AN012805-0708 Page 6 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

PD3

Vcc
PA2

U1
PA3
X1
Z8F

X2
PA4

R22
3V3 3k9
PB0/ALG0 PB1/ALG1 PA5

PB2/ALG2

PB3/ALG3

PB4/ALG4
Gnd

R23
10k

From R16

From R15

From R14

From R13

Figure 9. ADC Channel Inputs (Speed Potentiometer and Current Sensing)

• Switch SW1 (see Figure 14 on page 4), when Unipolar Drive Software Description
connected to pin PD3, acts as the directional con-
trol input. Pressing SW1 reverses the direction of The source code of unipolar drive is written in
rotation, while speed remains unchanged. ANSI compatible C and compiled with ZDS II,
Zilog’s Integrated Development Environment
• The half-step mode (selected at compile time) (IDE) for Z8 Encore!® series. The compilation
rotates the motor at exactly half the RPM of full- options are provided in the source code (AN0128-
step mode at the same step frequency. SC02) available from www.zilog.com.
• The step frequency, and consequently the speed
of the stepper motor, can be varied by using The main routine consists of three functions to ini-
potentiometer R23. The voltage at the wiper pin tialize the peripherals:
of the potentiometer is fed to ADC input channel
0. The reference voltage is generated internally • init_timer0() initializes Timer0
in the microcontroller and is used to compare the
• init_adc() initializes the on-chip ADC
voltage on the ADC input.
• init_p3ad() sets up the GPIO pin 3 of
This circuit is designed such that any type of uni-
port D as an external triggered interrupt
polar wound motor, 8- or 6-lead, can be driven by
it. The only component change that may be These peripherals are interrupt-driven and their
required is a MOSFET with appropriate voltage individual Interrupt Service Routines, are:
and current ratings.
• isr_timer0()
• isr_adc()

AN012805-0708 Page 7 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

• isr_p3ad() The ADC control register is configured with One-


shot conversion and with an enabled Internal Volt-
age reference. Furthermore, to set up the ADC, the
After initialization, the while loop is executed infi-
alternate function of Port B must be enabled by set-
nitely, interrupted only by the completion of one of
ting the PDAF. The data direction is input for all,
the following three events:
and the PDDD is set appropriately.
• Timer count roll-over
The priority for ADC is set to the highest by using
• ADC conversion complete IRQ0E0 and IRQ0E1. In this implementation, only
• Pressing of push-button SW1 the ADCDH register is used, but to get more accu-
rate values by making full use of the 10 bits, the
The pulsed switching of voltage in the four wind- register ADCDL can also be used.
ings of the motor is achieved by providing alternate
On and Off periods in the isr_timer0() func- The isr_adc() routine demonstrates how other
tion. These on-off sequences are provided to the ADC inputs can be utilized for current sensing by
I/O pins, according to the sequence table for full using a resistor divider, as discussed in the The
(See Table 1 on page 3) or half-step modes (see Electrical and Mechanical Characteristics of a
Table 2 on page 3). Stepper Motor section on page 4.

The Off period of the pulses is dependent on the A Low on the GPIO pin PA2/PA3/PA4/PA5 ener-
current fall time in a motor winding, and essen- gizes the particular winding, such that the data bit
tially constant; the On period varies according to is inverted before it is sent to the port pin.
the desired speed of the motor. If a higher speed is
required, the On time is reduced to produce nar-
Timer0 is initialized by configuring T0CTL reg-
rower pulses, and vice-versa for lower speeds.
ister with the appropriate Hexadecimal word.
Such variation in speed is achieved by mapping the
position of the potentiometer (voltage available at
wiper pin) with the exact time values to be placed The switch SW1 that is connected to pin PD3 (Pin3
into the T0CPH and T0CPL registers. of PortD), acts to reverse the directionof the motor.
To set PD3 as a source of external interrupts, set
the register PDDD to use pin PD3 as the output
The table.h file in the source code (AN0128-
pin, select the highest priority (same priority as
SC02) available from www.zilog.com contains the
ADC) using IRQ1E0, IRQ1E1, and select the fall-
2-dimensional look-up table, in the format:
ing edge with IRQES. In addition, enable port D
array[10][2], consisting of ten pairs of poten-
for interrupts by setting the PS register appropri-
tiometers:exact time values. Depending on the
ately. To reverse the motor direction, reverse the
ADC calculation (position of the speed potentiom-
sequence as per Table 1 or Table 2 on page 3, in the
eter) an appropriate value is chosen from the table
’switch:case’ statement of the isr_timer0()
and loaded into the timer registers. Varying the
routine.
potentiometer from minimum to maximum posi-
tion results in ten different motor speeds.
To select full or half step mode at compile time,
assign the value of variable step as 0x01 or 0x00,
The look-up table can be expanded to include more
in the main() routine.
number of pairs corresponding to different motor
speeds mapped to potentiometer positions. These
pairs can then be loaded into Timer0, as illus-
trated in the main routine.

AN012805-0708 Page 8 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Testing the Unipolar Stepper


Drive
The test setup to demonstrate the working of uni-
polar stepper motor drive as described in this
Application Note is illustrated in Figure 10.

VCC

ANA0 Stepper Motor HV_IN


1
PA2 3
Prototype 2, 5
Z8 PA3 4
Board
Encore!® 6
PA4 with
Evaluation
Board Power MOS-
PA5 FET Driver 10K
POT Oscilloscope
or
Logic Analyzer

Figure 10. Test Setup for Unipolar Stepper Drive

Equipment Used Test Procedure


The software and hardware were tested using the The procedure to connect and tune-up a stepper
following equipment: motor to the drive circuit (see Figure 14) is dis-
cussed below:
• Z8ENCORE000ZCO—Z8 Encore!® Develop-
ment Kit with the Z8F6403 MCU 1. Check that the voltage supplied to the motor
• Z8F08200100KIT—Z8 Encore!® Evaluation Kit windings (HV_IN) is the same as specified by
with the Z8F0822 MCU the manufacturer, with a maximum tolerance
of ±10%. Here 12V is supplied to the motor.
• ZDSII–IDE, v4.5.0 for the Z8 Encore!® series of The power supply should be able to source at
MCUs least 2 times the winding current requirement
• Tektronix TDA724D Digital Storage Oscillo- of the motor.
scope with PC software 2. As described in the The Electrical and
• HP 1661A Logic Analyzer Mechanical Characteristics of a Stepper Motor
on page 4, avoid frequencies of nonoperation.
• Power circuitry on breadboard These frequencies cause electrical resonance in
• Stepper motor, with the following specifications: the motor at high loads and can result in per-
– Voltage an d Cu rrent Ratin g = 12VDC, manent damage to the motor. The nonoperation
1.25A per phase frequency range is usually specified by the
motor manufacturer; however, these frequen-
– Step angle = 1.8º
cies can be determined by testing at no-load.
– Torque = 3kgf-cm
– Number of leads = 8

AN012805-0708 Page 9 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

3. To map the potentiometer values, code certain Test Results


frequencies (that is, Timer0 ON-time values
that match the set speed) in the LUT provided The Z8 Encore!®-based stepper drive works with
in the if…else statement of the main() rou- the 2-ph On principle and provides stable motor
tine in the source code (AN0128-SC02) avail- control.
able from www.zilog.com.
Using the potentiometer a smooth variation of
4. Proper cooling arrangements must be made speed was obtained, with typical pulse widths
because the motor heats up with continuous ranging from 3.1ms (frequency of 277pps) to
operation. Likewise mount the power compo- 29.3ms (33pps). The Off time between successive
nents (transistors, MOSFETS, and other com- pulses remained constant at 500µs. These values
ponents) with appropriate spacing between can be modified in the source code (AN0128-
them and provide adequate heat-sinking. SC02) available from www.zilog.com.
5. Identify the stepper motor leads for 4 sets of
windings, with a multimeter in continuity The direction control was achieved by using SW1
mode. Tie together one end of each winding and the mode was selected using variable step in
and connect the other end to VDD. For a 6-lead the main() routine. The rotational speed in the
motor, tie together one end of the middle two half-step mode was reduced to half of that of the
wires and connect the other end to VDD. full-step mode at the same pps frequency, leading
6. Connect the prototyping board to the appropri- to a better step resolution.
ate pins on the connectors of the Z8 Encore!®
Development/Evaluation board and power-up Oscilloscope Charts
the motor. Figure 11 is a screen shot of the full-step wave-
7. Download the executable binary onto the forms at the base pins of buffer transistors Q1, Q2,
microcontroller using ZDS II utility. Execute Q3, and Q4, in clockwise motor rotation. This
the code and test the motor direction from the schema matches the timing steps in Table 1 on
shaft end. If it is reversed, interchange any two page 3 for the full-step method discussed earlier.
winding leads and power-up the motor again.
.
8. Observe the variation in speed by changing the
speed potentiometer position from minimum to
maximum. To reverse the direction, press the
switch SW1.
9. The Digital Storage Oscilloscope (DSO) can
also be used to check the speed variation.
Observe any irregularities in speed and check
the frequency (pps) using a DSO, keeping in
mind not to use the nonoperational frequen-
cies. Perform in-circuit debugging using the
On-chip Debug system supplied with the Z8
Encore!® Development/Evaluation Kit.
10. To obtain the results as shown in the Oscillo-
scope Charts on page 10, match the pulses to
that shown in Chart 1 and Chart 2, and the volt-
Figure 11. Full-Step Waveforms - Buffer
age and current waveforms to that shown in
Transistors
Chart 3.

AN012805-0708 Page 10 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Figure 12 is a screen shot of the waveforms in full- inverse of Figure 11 (although not on same time
step mode, available at the gate pins of MOSFETs scale).
T1,T2, T3, and T4. Note that the logic is the

Figure 12. Full-Step Waveforms - MOSFET Gate Pins

Figure 13 is a screen shot showing the typical volt- mode, available at the Gate and Source of MOS-
age (top) and current waveform (below) in full-step FET T1.

Figure 13. Full-Step Waveforms—Gate and Source of MOSFET T1

AN012805-0708 Page 11 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Summary
This Application Note successfully demonstrates
the operations of a unipolar stepper motor drive
based on the Z8 Encore!® series of Flash micro-
controllers. Only one 16-bit timer, one 10-bit ADC
channel, and an external interrupt I/O pin are used,
leaving other resources free for the designer. The
ANSI-C code, including an array table, occupies a
mere 1689 bytes, with a RAM requirement of only
38 bytes.

The powerful peripheral features of the Z8


Encore!® series of microcontrollers make the Z8
Encore!® MCU convenient to use in complex
motor control applications.

AN012805-0708 Page 12 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Appendix A— Reference
Further details about stepper motors, the Z8 Encore!® MCU and the ZDSII–IDE can be found in the refer-
ences listed in Table 5.

Table 5. List of References

Topic Document
Stepper motors Stepping motors and their Microprocessor Controls – Takashi
Kenjo; Oxford Press, 1984.
Zilog Developer Studio (ZDSII–IDE) Zilog Developer Studio II—Z8 Encore!® User Manual (UM0131).
v4.1.0
Z8 Encore!® product specifications Z8 Encore!® Microcontrollers with Flash Memory and 10-Bit A/D
Converter Product Specification (PS0176).

AN012805-0708 Page 13 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Appendix B—Glossary
Definitions for terms and abbreviations used in this Application Note are listed in Table 6. .

Table 6. Abbreviations/Acronyms

Term/Abbreviation Definition
MOSFET Metal-Oxide Semiconductor Field Effect Transistor,
N-channel or P-channel.
BJT Bipolar Junction Transistor, npn or pnp.
ADC Analog-to-Digital Converter.
Flash Read-Only Memory for Code and Constant Data
Storage.
Emulator Equipment used to mimic the functioning of a
microprocessor.
PPS Pulse Per Second, a measure of frequency.

AN012805-0708 Page 14 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Appendix C—Schematic Diagrams


Figure 14 illustrates a schematic for a unipolar stepper motor drive using the Z8 Encore! MCU.

HV_IN D5
1N4001
R17
1k,0.5W
3V3 T1
Q1 IRFZ44N HV_IN
R1 BC547 R5 ZD1
3k3 5V1
C1 R2 4k7
10uF / 10V D1 LED1 R13
4k7 1N4148 1E,5W
R3 R9
4k7
D6
4k7 HV_IN 1N4001
R4

R18
R21 4k7 1k,0.5W
SW1 100k T2
Q2 IRFZ44N
BC547 R6 ZD2
Vcc

PD3 3k3 5V1 R14


C2 1E,5W
PA2

6
0.01uF D2 LED2
1N4148 D7
R10 1N4001 3
4k7 2
C4 1
27 pF U1 HV_IN
PA3
X1 Z8F R19 MG1
X1 1k,0.5W 6-lead Stepper Motor
18.432 MHz T3
Q3 IRFZ44N
X2 BC547 R7 ZD3
C3 PA4 3k3 5V1 R15
27 pF 1E,5W
R22 D3 LED3
3V3 3k9 1N4148
R11
PB0/ALG0 PA5 4k7 D8
1N4001
Gnd

R23 HV_IN
10k
R20
1k,0.5W
T4
Q4 IRFZ44N
BC547 R8 ZD4
3k3 5V1 R16
1E,5W
D4 LED4
1N4148
R12
4k7

HV_IN = 5 - 36 VDC / 0.5 - 5 Amp

Title
Unipolar Stepper Motor Drive with Z8 Encore!

Size Document Number Rev


A 1.0
AN0128
Date Tue, Oct 22, 2002 Sheet 1 / 1

Figure 14. Schematic for A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

AN012805-0708 Page 15 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Appendix D—Flowcharts
This appendix illustrates flowcharts of the various routines developed for a unipolar stepper motor applica-
tion using the Z8 Encore!® MCU.

Figure 15 illustrates the flow of the main routine.

Reset

¥ Initialize timer0
¥ Set vector isr_timer0
¥ Initialize external interrupt pin Y
Load 9th Is set speed
¥ Set vector for external interrupt pin value of On
¥ Initialize ADC value = speed9?
time from table
¥ Set vector for ADC
¥ Enable interrupts
N

Load highest
¥ Enable ADC conversion value of On
¥ Delay until conversion complete time from table

Is set speed Y Load 1st value


value = speed1? of On time
from table

Is set speed Y Load 2nd value


value = speed2? of On time
from table

Is set speed Y Load 3rd value


value = speed3? of On time
from table

Figure 15. The Main Routine

AN012805-0708 Page 16 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Figure 16 illustrates the flow of the external interrupt pin routine.

Routine for external


interrupt pin

N
Is SW1 = 1? Set SW1 = 1

Set SW1 = 0

Return

Figure 16. The External Interrupt Pin Routine

Figure 17 illustrates the flow of the ADC interrupt routine.

ADC Interrupt Routine

Get channel number


Load ADC value

Return

Figure 17. The ADC Interrupt Routine

AN012805-0708 Page 17 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

Figure 18 illustrates the flow of the Timer0 interrupt routine.

Timer0 Interrupt Routine

Reload T0CPH, T0CPL


Disable timer with On time value

Is timer is N Sequence set to N


set to "On time"? full step?

Y Y

Reload T0CPH, T0CPL Select sequence number Select sequence number


with Off time value from full-step table from half-step table
Clear Port A pins Set corresponding pin in Set corresponding pin in
Port A to Low and others Port A to Low and others
to High to High

Reset T0H, T0L


Enable Timer0

End Interrupt

Figure 18. The Timer0 Interrupt Routine

AN012805-0708 Page 18 of 19
A Unipolar Stepper Motor Drive Using the Z8 Encore!® MCU

DO NOT USE IN LIFE SUPPORT


Warning:

LIFE SUPPORT POLICY


ZILOG'S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE
SUPPORT DEVICES OR SYSTEMS WITH OUT THE EXPRESS PRIOR WRITTEN APPROVAL OF
THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION.

As used herein
Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b)
support or sustain life and whose failure to perform when properly used in accordance with instructions for
use provided in the labeling can be reasonably expected to result in a significant injury to the user. A
critical component is any comp onent in a life suppor t device or system whose failure to perform can be
reasonably expected to cause the failure of the life support device or system or to affect its safety or
effectiveness.

Document Disclaimer
©2008 by Zilog, Inc. All rights reserved. Information in this publication concerning the devices,
applications, or technology described is intended to suggest possible uses and may be superseded. ZILOG,
INC. DOES NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY
OF THE INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT.
Z I L O G A L S O D O E S N O T A S S U M E L I A B I L I T Y F O R I N T E L L E C T U A L P R O P E RT Y
INFRINGEMENT RELATED IN ANY MANNER T O USE OF INFO RMATION, DEVICES, OR
TECHNOLOGY DESCRIBED HEREIN OR OTHERWISE. The information contained within this
document has been verified according to the general principles of electrical and mechanical engineering.

Z8, Z8 Encore!, Z8 Encore! XP, Z8 Encore! MC, Crimzon, eZ80, and ZNEO are trademarks or registered
trademarks of Zilog, Inc. All other product or service names are the property of their respective owners.

AN012805-0708 Page 19 of 19
of 19

You might also like