Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
to Mechatronics
Instructor TA: Edgar Martinez Soberanes
(eem370@mail.usask.ca)
2017-03-02
Lecture
o Stepper Motor.
o Step motor controller (L297)
o Square wave signal.
o Input/output Ports.
3
Objective
Objectives
o Design a complete system for motion control of a stepper motor using the PIC
and a step motor controller integrated circuit.
4
Stepper Motor
Stepper motors are DC motors that move in discrete steps. They have multiple coils that
are organized in groups called "phases". By energizing each phase in sequence, the
motor will rotate, one step at a time
o Speed Control – Precise increments of movement also allow for excellent control
of rotational speed for process automation and robotics.
o Low Speed Torque - Normal DC motors don't have very much torque at low
speeds. A Stepper motor has maximum torque at low speeds, so they are a good
choice for applications requiring low speed with high precision.
5
Step Count
Resolution is often expressed as degrees per step. A 1.8° motor is the same as a
200 step/revolution motor.
6
How Stepper Motors Work
7
Half/Full-Stepping
In half-stepping mode, instead of switching the next electromagnet in the rotation on
you turn on both electromagnets, causing an equal attraction between, thereby
doubling the resolution.
8
Stepper motor with PIC
The simplest way to operate a stepper motor with a PIC is with the full step pattern shown in
the Table below. Each part of the sequence turns on only one phase at a time, one after the
other. After the sequence is completed, it repeats infinitely until power is removed.
9
Stepper Motor Controller (L297)
The heart of the L297 is a block called the translator which generates suitable phase
sequences for half step, one-phase-on full step and two-phase-on full step operation. This
block is controlled by two mode inputs – direction (CW/ CCW) and HALF/ FULL – and a step
clock which advances the translator from one step to the next.
To control a stepper motor using the controller or driver L297 you only need 4 signals:
1.Enable (ON/OFF)
2.Stepping mode (Half/Full).
3.Direction of rotation (CW/CCW).
4.Speed (Clock)
11
Square Wave Signal (Clock)
The square wave, also called a pulse train, or pulse wave, is a periodic waveform consisting
of instantaneous transitions between two levels.
RBx = 1;
Square Wave __delay_ms(10);
Generation RBx = 0;
program. __delay_ms(10);
12
Input/output Ports
5 ports (A,B,C,D, and E). Each port has different characteristics and
number of pins.
13
Each port has three standard registers for its operation:
o TRISx registers (data direction)
o PORTx registers (reads the levels on the pins)
o LATx registers (output latch)
14
Example Port A
Note: Writes to PORTA are actually written to corresponding LATA register. Reads
from PORTA register is return of actual I/O pin values.
15
16
Single Pins VS Port.
A Port (A,B,C,D, and E) has several pins. Each pin is a physical leg of the Microcontroler,
and they are labeled as R(Portx)(Pin #)
PORT B
17
Programming of ports or pins
TRISA register (PORTA Data Direction Register):
TRISA = 0xF0;
TRIS A REGISTER
TRISA 7 TRISA 6 TRISA 5 TRISA 4 TRISA 3 TRISA 2 TRISA 1 TRISA 0
1 1 1 1 0 0 0 0
LATA puts the content of the output latch on the port A.
PORTA reads the status of all the pins. Reads the whole word in PORT A
X = PORTA; or for reading a single pin: X = RA2
X=00000101 X=1
18
Programing the PIC
19
Thanks
20