Você está na página 1de 8

Stepper motor IC Controllers

A number of stepper motor IC drivers exist specifically designed to reduce chip count and minimize
driving software requirements.
Unlike the simple stepper motor driver interface that expects the micro to generate the four phase
control signals and also provide the specific sequences for direction and other operational modes,
these devices require only single controlling pins giving a simplified interface solution.
The stepper motor IC used in our experimentation is the MC3479 driver. The IC is designed to drive a
two-phase stepper motor in a bipolar mode. It consists of four input sections, a decoding/sequencing
section, and two back EMF protected driver-stages for the stepper coils. The IC provides for
Clockwise/Anticlockwise and Half step/Full step mode of operation.
A block diagram of the device is as shown in Fig. 18. A brief datasheet for the IC is given in the
Appendix.

Fig.19 Block diagram of the MC3470

Fig. 20 Pin out of the MC3479

For a full data sheet follow this link (online document only)

Functional description
Referring to Fig 19 an explanation on the function of the IC pins is as follows:
CLK: is the step input to device. The outputs change state after each low-to-high transition at the
CLK input.
CW/CCW : Clockwise/Counter-clockwise This input determines the direction of rotation. With the pin
at logic 0 the rotor moves in a clockwise direction, with CW/CCW at logic 1 the rotor steps in an anticlockwise direction.
Set input: A low level at the R input resets the internal counter to zero. If the reset input is not used
it should be pulled-up to the supply voltage.
Full/Half : Is the pin that determines the stepping mode of the motor. When to logic 1 the motor
moves in a Half step mode of operation, when at logic low the motor moves in a full step mode.
OIC: Output Impedance Control only used in half step mode. When Low the two driver outputs of
the non-energised coil is in a high impedance mode when High the same driver is in a low impedance
mode.
Phase A : Is an open collector output goes Low to indicate that the driver outputs are in the Phase A
condition L1=L2 and L2=L4

18

/Bias- Set : Determines the maximum output sink current (resistor selected). A low level on this pin
will set the output to high impedance stopping the stepper.
L1,L2,L3,L4: Outputs Connected to the stepper motor windings.

The stepper motor driver outboard

The picture of Fig. 20 shows the stepper motor driver outboard. It is based on the MC3479 stepper
motor controller IC. All required components are provided on board. Access to inputs and outputs are
provided by means of single sockets. A typical connection schematic is shown in Fig. 21.

Fig.20 Stepper Motor controller Board

Fig.21 Connections schematic

Using the stepper motor controller IC


In the following section will discuss the use of the stepper motor controller in various operational
aspects.

Procedure
Disconnect power from your system and connect the following setup.
The stepper motor controller supply connector socket is connected to +8v (we will use a variable PSU
for this). Please note that we are using a 5v and an 8v power supply. The 5 volt supply provides
power to the micro. The 8 volt power supply provides power to the stepper motor controller and the
stepper motor. In your power supply connections you have to make sure that there is a common zero
reference point by connecting the zero of the two supplies together.
1.
2.
3.
4.
5.

Output
Output
Output
Output

The Clock input is connected to Port D0.


The Full Step/ Half step input of the controller is connected to Port D1 output pin.
The Direction input is connected to Port D2 output pin.
The Set pin is connected to Port D3 output pin.
The outputs from the stepper motor controller are connected to the coil inputs of your
stepper motor in the following order:
1
2
3
4

of
of
of
of

the
the
the
the

controller
controller
controller
controller

is
is
is
is

connected
connected
connected
connected

to
to
to
to

input
input
input
input

4
3
2
1

on the stepper motor board.


of the stepper motor.
of the stepper motor.
of the stepper motor.

19

A detailed view of the connections is shown below in Fig.22:

Fig. 22 Stepper Motor Controller setup


Example 4 (Using the Stepper Motor Controller)
In the example that follows we will be controlling our stepper motor with a controller board. The
source code for our example will be shown in both Assembly and MCC18 C.
Choose the version of your choice to carry out the example and the experimentation that
follows.
The example uses Port D0 as the step input (clock). In order to provide a clock D0 has to toggle
between the two states of Zero and One and by doing so it generates a clock pulse. This is achieved
by using the BTG instruction of the PIC. BTG stands for Bit ToGgle. The argument following the BTG
instruction is PORTD,RD0 (RD0 means bit 0 of Port D). By specifying the single bit RD0 no other port
bits are affected during this operation. Other connections from Port D to the controller are the /F
HS, (Direction) and the Set (stop motor) inputs.
The logic levels selected for the following example are as follows:
/F HS :
/CW-CCW:
SET:

is set to logic 0 ( Motor moves at full step operation).


is set to logic 0 ( Motor moves in a clock-wise direction).
is at logic 1 ( a logic 0 stops the stepper).

Fig 23 Port D settings for


our example.
Bit D0 provides a pulse o/p,
Bit D1 cleared to 0 selects
full step operation, Bit D2
set to 0 selects clock-wise
direction and Bit 4 set to
logic 1 enables the outputs
to the coil windings of the
controller.

20

Assembly Version
*****************************************************************************
;
; Filename:
Stepper Controller.asm
; Date:
DD/MM/YY
; File Version:
1.0
;
; Author:
PDA
; Company:
Coventry University
;
; Program Function: Stepper motor control with controller PIC18F4520 through PORT D
;******************************************************************************
;
; Files Required: P18F4520.INC
;
;******************************************************************************
LIST P=18F4520
#include <P18F4520.INC>

; directive to define processor


; processor specific variable definitions

;******************************************************************************
; CONFIGURATION BITS
; (Microchip has changed the format for defining the configuration bits, please
; see the .inc file for further details on notation). Below are a few examples.
;
; Oscillator Selection and other fuse settings:
CONFIG
CONFIG
CONFIG
CONFIG
CONFIG

OSC
MCLRE
DEBUG
LVP
WDT

=
=
=
=
=

HS
ON
OFF
OFF
OFF

;High Speed clock


;MCLR enabled
;Background debugger disabled, RB6 and RB7 configured as general IO
; Low Voltage Programming OFF
; WDT disabled

;******************************************************************************
; RESET VECTOR
; This code will start executing when a reset occurs.
DELVAL1
EQU
0x007
DELVAL2
EQU
0x008
ORG

Main:

LOOP

0x0000

; ORG Directive

GOTO Main

;go to start of main code

CLRF TRISD
CLRF PORTD
MOVLW B00001000

; Clear Tristate Register D (make Port D o/p)


; Clear Port D
; Binary value at D set stepper controller for Full step
;Forward direction, enable o/p (see Fig.23)
;
; BIT toggle D0 bit only so that to provide a clocking input
; Wait for a while by calling Delay subroutine
; on return from sub repeat process

MOVWF
BTG
CALL
GOTO

PORTD
PORTD,RD0
LONGDEL
LOOP

;
; *** A long delay subroutine follows bellow to allow for the clocking action ****
LONGDEL
MOVLW
0XFF
; Long delay sub, by using a nested delay
MOVWF
DELVAL1
; hex FF in DELVAL1 Register file
REPEAT
MOVLW
0XFF
; also at DELVAL2 Register file
MOVWF
DELVAL2
;
BACK
NOP
; No operation
DECF
DELVAL2,F
; Decrement Register File DELVAL2
BNZ
BACK
; if not zero go back otherwise continue with next instruction
DECF
DELVAL1,F
; Now decrement DELVAL1
BNZ
REPEAT
; If not zero go to REPEAT process again
RETURN
; Return from subroutine
END

21

C Version of Example
/*
/*
/*
/*
/*
/*
/*
/*

Program Title: Stepper Motor Controller C Version


File name:
Stepper Controller C Example
Version: 1.0
Author:
Company: Coventry University
Date:
Program function: Stepper motor controller

*/
*/
*/
*/
*/
*/
*/

/* The following configure operational parameters of the PIC


*/
#pragma config OSC =
HS
//set oscillator mode to HS high speed clock
#pragma config WDT =
OFF // set watchdog timer off
#pragma config LVP =
OFF // Low Voltage Programming Off
#pragma config DEBUG = OFF // Compile without extra Debug compile Code
/* Include Files

*/

#include <p18f4520.h>
#include <delays.h>

// Device used is the PICF4520


// Include the delays routines

void main (void)


{
LATD = 0x00;
TRISD = 0x00;

// Initialise Port D
// Configure Port D as O/P

LATD = 0B00001000;

// Write the binary value 00001000 (hex 08)


// to control various inputs of stepper

while (1)
{
Delay1KTCYx(20);
PORTDbits.RD0 = ~ PORTDbits.RD0;

// Delay for a while


// Compliment Bit D0 of port D (change from
// logic 0 to logic 1 and vice versa

}
}

Exercise 4
Using the software development environment tools of your choice modify the appropriate example
(assembly or C) source file and program your PIC so that the stepper operates in a Counter-ClockWise Half step mode of operation.

22

Using the position sensor and timer module with the controller
Instead of using a port bit in providing a step input to the controller one can use an external TTL
source of the appropriate stepping frequency for the clock so freeing a Port pin and the software
overhead required in your code.
The controller board also provides for a plug-in timer module through the appropriate timer socket. A
setup for this is as shown in the following Figures 24 and 25.

*** When connecting a clock module to the controller board socket please make
sure that there are no other connections to the CLK input.
Also please make sure that you plug in the timer module the correct way. See
Figures 24 and 25:

Fig 24 Controller with Timer module on board

Fig.25 Timer module

Using rotation position sensors


As already mentioned the stepper motor board allows for the use of a plug-in sensor that could be
used for rotational sensing applications. There are two types of plug-in boards available for this.
One is based on a slotted optical sensor as shown in Fig 26 (a,b,c) and the other on a Hall Effect
sensor as shown in Fig.27.

Slotted Optical sensors


(b) Pin-out

(a) Sensor

(b) Sensor Pin-out


(C)
Fig. 26 (c) Optical sensor board

Picture shows the slotted opto- sensor used on the stepper outboard as a single position
reference point. The sensor consists of an optical infrared emitter and an infrared receiver
separated by the slot. As the pointer attached to the rotor passes through the slot, it
interrupts the infrared beam thus producing an output which can be detected by the micro.

23

Hall Effect sensor

A Hall effect sensor is a transducer that responds to changes in a magnetic field. They are commonly
used for position sensing in industrial applications such as rotating/moving components, for the
timing of wheels and shafts to name but a few. Typically we will have a Hall effect sensor mounted
on a fixed part of an assembly that senses a magnet attached to a rotating/moving part in close
proximity. There are many other uses and applications that are beyong the scope of our current
session.

Fig. 27 (a,b)

Figure shows the Hall Effect


sensor and sensor plug-in
module.

(a) Hall effect sensor

(b)

The following two figures (28 and 29) show the slotted optical sensor and the Hall effect
sensor plugged into the stepper motor board.

Fig.28 Stepper motor with opto-sensor

Fig.29 Stepper motor with Hall effect sensor

Exercise 5

In the exercise that follows you will be using the controller board with the on-board timer. The
controller board will be connected to the stepper motor board carrying a position sensor. You could
use either the Opto or the Hall Effect type of sensor here. The sensor output will be connected to an
assigned input pin of our controlling port (PORTD7). The task of our example will be to initially move
the stepper in a clock-wise direction at full step. When the pointer arrives at the sensor point it will
provide a change of state at its output which will be monitored by the PIC through the input port pin
of the Port. The PIC then instructs the controller to change the motor direction in a counterclockwise fashion. The change of stepper motor direction is repeated every time the stepper motor
pointer arrives at the sensor position. Choose the software development tools of your choice for
carrying out this task.

24

The hardware connections required for this experiment are mainly as in the previous example but
with a few changes. The setup is as shown in Fig. 31. Please note that you will need a 5v supply for
your position sensor. All system connections should be carried out with all supply connection
disconnected.
Observe the correct orientation of the plug-in timer and sensor boards. See Figures 24,
25 and 29.
Please REMOVE the previous CLK (Step) connection from the PIC Port D0, as in this particular
exercise the step input is provided by the on-board plug-in clock.

Port D configuration is as shown in Fig. 30


Fig.30 Port configuration
showing Port pins and initial
functions. You will need to
change some of these in
order to control the stepper
for the specific operation of
this exercise.

Scan QR code for more info on web1

Fig.31 System connections for Exercise 5

Stepper Motor v1.21


P Abatis Dec 10
25

Você também pode gostar