User Manual

AND8399/D
http://onsemi.com
21
Examples
Below some examples are given on how to use the
SLApin. The flowchart given in these examples represent
the microcontroller firmware (see Figure 20). All examples
and flowcharts given in this document are solely intended to
simplify the explanation and to help you better understand
how to use the SLApin.
Drive Motor
Figure 22 displays a simple way of driving a stepper
motor. In this example the SLApin is not used yet. The
moment the application is powered, the microcontroller will
be initialized. When this is done, the coil current and
stepping mode will be set. The motor driver will be enabled
and NXT pulses will be send to rotate the motor. The timer
will determine the time between NXT pulses and by this
determine the rotation speed. In theory the stepper motor
should be accelerated to the maximum speed but this is out
of the scope of this document. We assume the speed is low
enough to start without acceleration. The rotation speed
must also be lower than the maximum operating speed (see
Section Maximum operating Speed).
Timer Overflow ?
Power Up
Initialize microcontroller
Set Coil Current
Set Stepping Mode
Control Register 0
Enable Motor Control Register 2
Send NXT Pulse
Start Timer
Y
N
Figure 22. Simple Motor Control Example
Above flowchart is a very simple example of driving a
stepper motor. No diagnostics is done, no verification if
stepper motor is rotating, ... The only intention of this
example is to rotate the motor with a minimum of overhead.
Driving a stepper motor in real life applications will be more
complex but is out of the scope of this document.
Sample SLA
The flowchart in Figure 23 gives the moment when to
sample the SLA voltage when working in 1/8
microstepping.
Every time a NXT pulse is send the microcontroller will
check if the coil current zero crossing phase is left. If so, the
microcontroller knows the SLA voltage will be updated and
will sample the SLApin. An additional delay is added
before sampling the SLApin (internal update delay of
motor driver, see Transparency Mode).