laboratory: introduction to mechatronics. to...5 stepper motor stepper motors are dc motors that...
TRANSCRIPT
Instructor TA: Edgar Martinez Soberanes([email protected])
2019-08-01
Laboratory: Introduction
to Mechatronics
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
5
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 rotates, one step at a time
o Positioning – Steppers move in precise repeatable steps, they excel in applications
requiring precise positioning such as in 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.
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.
6
7
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.
8
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.
Half/Full-Stepping
9
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.
10
The heart of the L297 is a block called translator which generates phase sequences for
half step and full step modes. The circuit (L297) is controlled by three inputs – direction
(CW/ CCW), HALF/ FULL – and a step clock which advances the translator from one step to
the next.
Stepper Motor Controller (L297)
11
Stepper Motor Controller (L297)
HALF STEP MODE: Half step mode is selected by a high level on the HALF/FULL input.
Step Sequence: A B C D
Home or Reset position: A B D C = 0101
12
Stepper Motor Controller (L297)
FULL STEP MODE: is selected by a low level on the HALF/FULL
13
High-Current Darlington Transistor Arrays
(ULN2003A)
The ULN2003A device comprises seven high-voltage, high-current NPN Darlington transistor
pairs.
Each channel consists of Darlington connected NPN transistors. This connection creates the
effect of a single transistor with a very high-current gain (β2).
The very high current (β2) allows for high-output current drive with a very low input
current, essentially equating to operation with low GPIO voltages.
Typically, the ULN2003A device drives a high-voltage or high-current (or both) peripheral
from an MCU or logic device that cannot tolerate these conditions. Driving inductive loads
such as motors, solenoids and relays, is a common application of this IC.
14
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)
The ULN2003A device allow us to drive devices such as inductive loads that require high
currents, with low voltages inputs.
15
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.
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.
16
17
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)
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)
18
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.
19
Experiment:
1. Wire the proposed circuit.
2. Write a program to test both driving modes of the motor (Full/Half Step) and
try different rotation speeds and directions.
3. Using the USB Oscilloscope fully characterize your clock signal (Slide 15).
20
Experiment:
Push Buttons RB0 and RA4
21
Experiment:
Program:
o We require 2 inputs (push buttons)
o 4 outputs to drive the L297 controller (Enable, Direction, Mode, and Clock)
o Clock Signal
22
Formal Report: The formal report must include the following:
1.Summary
2.Introduction
3.Objectives
4.Theory related to the lab (Step motors theory)
5.Apparatus (Brief description, on your own words, of each device used)
6.Procedure
7. Results (Main code of the program, with comments for each line of code, fully characterized clock signal or square wave, and observations of the motor behaviour)
8.Discussion (Elaborate on the differences observed in driving modes and speed. Did you find a minimum and maximum speed? Did you try different clock signals.
9.Conclusion
23
Formal Report:
Thanks
24