Sei sulla pagina 1di 20

Laboratory: Introduction

to Mechatronics
Instructor TA: Edgar Martinez Soberanes
(eem370@mail.usask.ca)
2017-03-02

Lab 4. Stepper Motor (Motion


Control).
Lab Sessions
 Lab 1. Introduction to the equipment and tools to be used in the lab, which
include the development board (PICDEM 2 Plus),the microcontroller (PIC
16F1937), and the USB Oscilloscope (Analog Discovery).

 Lab 2. Experiment 2: Transistor Operation, Experiment 3: Passive filters, and an


Op-Amp circuit experiment.

 Lab 3. Experiment 7: LED Control and Interruptions.

 Lab 4. Experiment 10: Stepper Motor Motion Control.

 Lab 5. Experiment 11: DC Motor Speed Control Using PWM.

 Lab 6. Experiment 12: Closed Loop DC Motor Position Control. 2


Lab 1. Outline
 Objective.

 Lecture
o Stepper Motor.
o Step motor controller (L297)
o Square wave signal.
o Input/output Ports.

 Time for the experiments.

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.

o Design a program to control: magnitude of speed, direction of rotation, and full-


step mode and half-step mode.

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 Positioning – Steppers move in precise repeatable steps, they excel in applications


requiring precise positioning such as 3D printers, CNC, Camera platforms and X,Y
Plotters.

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.

o Unipolar 2-phase, 7.5 degrees/step, 5 VDC stepper motor.

This motor only joins the


common wires of 2 paired
phases. These two wires can be
joined to create a 5-wire
unipolar motor.

6
How Stepper Motors Work

 To move the rotor clockwise


(CW), the upper electromagnet
is deactivated and the right
electromagnet is activated,
causing the rotor to move 90
degrees CW, aligning itself with
the active magnet. This process
is repeated in the same manner
at the south and west
electromagnets until we once
again reach the starting
position.

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.

Half-step mode Full-step mode

Note: The wave drive sequence is A/C/B/D ; twophase-on is


AC/CB/BD/DA and the half step sequence is A/AC/C/BC/B/BD/D/DA.
10
Summary

 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.

 Ports are bidirectional (Input/Output).

 Multi-functional. Some pins are multiplexed with an alternate


function. When a peripheral is enable, that pin may not work as a
general input/output.

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

 TRISA register (PORTA Data Direction Register):


o Bit = 1 (pin on port A = Input)
o Bit = 0 (pin on port A = Output)

 PORTA reads the status of the pins.


o Example: x = PORTA

 LATA puts the content of the output latch on the port A.


o Example: LATA = 0; Make all the pins of port A equal to 0 V.

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.

LATA = 0x05; or RA2 = 1; and RA0 = 1;


LAT A REGISTER
LATA 7 LATA 6 LATA 5 LATA 4 LATA 3 LATA 2 LATA 1 LATA 0
(RA7) (RA6) (RA5) (RA4) (RA3) (RA2) (RA1) (RA0)
0 0 0 0 0 1 (5v) 0 1 (5v)

 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

Potrebbero piacerti anche