Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (3.59 MB, 594 trang )
page 131
A stepper motor is unlike other motors. When a voltage is applied the motor does not turn
continuously, it only moves a small increment. There are normally a set of four or
more inputs. When these are turned on-off in a set pattern the motor shaft will
rotate forward or backwards. A typical stepper motor might have 200 steps per
revolution, or steps of 1.8 degrees. These motors often require somewhat sophisticated controllers. One type of controller is called an indexer. It can be given commands to move the motor, and then it takes care of pulsing the motor outputs to
drive the motion.
The stepper motor controllers to be used in this laboratory are integrated into the turntables in the material handling system. The controller is integrated into the turntable
stations so that it can rotate the turntable up to 360 degrees with a stepped motor,
eject a cart using two outputs to solenoid valves, and detect a cart present with a
diffuse photoelectric sensor. The controller has an RS-422 port that can be used to
communicate, and load programs. This will be connected to an RS-232C port
using a special interface cable that converts the current loop to voltage values. The
communication settings for the turntables are 9600 baud, 8 data bits, no parity, 1
stop bits, no flow control.
The programming commands for the controller are summarized below.
DCB-241 Commands
@ soft stop
+ move in positive direction
- move in negative direction
[ read nonvolatile memory
] read hardware limits
\ write to nonvolatile memory
^ read moving status
A port read/write
B jog speed
C restore
D divide step rates
E enable auto power off
F find home
G go from address
I initial velocity
K ramp slope
L loop on port
M move at constant speed
O set origin
P program mode
Q query program
R index to target position
S store parameters
T set trip point
V slew velocity
W wait
X examine parameters
Z display position
Figure X.14 - Stepper Motor Control Board Commands (DCB-241)
When writing programs command lines can be up to 15 characters long, including spaces.
Spaces are used to separate commands and arguments. Characters used in programs can be either upper or lower case. A sample program is given below.
page 132
Pre-Lab:
1. Go to the web site www.stepcontrol.com and look at the product documents for the
DCB-241 stepper driver.
In-Lab:
1. Use a terminal program to communicate with the stepper motor controller. You will
need a special communication cable, and the boxes can be opened with a flat
bladed screwdriver. Plug the communication cable into the lower connector. (Note:
if the unit already has power don’t touch the exposed 120Vac power on the power
supply.) Connect an air supply and power to the unit. (Note: don’t forget to turn on
the power on the front of the cabinet.)
2. Use the following commands (in sequence) to verify that the turntable is operating
properly, and to explore basic commands. (Note: comments are provided for
understanding, but should not be entered into the controller.)
Z -- read the current position
O -- set the current position as the origin
Z -- print the current position
R1000 -- this should rotate the turntable
Z -- should now be 1000
R-1000 -- this should rotate the turntable the other way
Z -- should be zero again
A8 - kicks the cart one way (notice the lights on the solenoids)
A16 - kicks the cart the other way
A0 - turns off all solenoids
] -- this will check the input ports, bits 7 and 8 are for the cart present detectors
3. Enter the following program so that the turntable operates automatically. The list below
also includes the commands to download and enter the program. Again comments
should not be entered, and line numbers are automatically generated. When the
program has been entered it can be run with the command ’G0’.
P0 -- put the controller in programming mode and start the program at location ’0’
0 O0 -- set the current position to the origin with a value of 0
4 R10000 -- more the controller 10000 steps in the positive direction
8 W0 -- wait until ’0’ ms after the motion is complete
11 R-10000 -- move 10000 steps in the opposite direction
15 W100 -- wait until ’100’ ms after the motion is complete
18 J 4 3 -- jump to address ’4’ four (3+1) times, a basic for loop (you may need to
change ’4’ if your line numbers don’t match)
22 A8 -- eject the cart
24 W1000 - wait for 1 second
27 A0 - shut off the solenoid valve
29 P0 -- the end of the program
4. Write a C++ program to communicate with the stepper motor controller over RS-232. It
page 133
should allow the user to enter a motor position from the keyboard, and the controller should automatically move.
Submit (individually):
1. The source code listings for the motor control program.
page 134
7. PROGRAMMABLE LOGIC CONTROLLERS (PLCs)
• CONTROL - Using artificial means to manipulate the world with a particular goal.
• System types,
• Continuous - The values to be controlled change smoothly.
e.g. the speed of a car as the gas pedal is pushed
• Logical - The values to be controlled are easily described as on-off.
e.g. The car motor is on-off (like basic pneumatics).
Note: All systems are continuous but they can be treated as logical for
simplicity.
• Logical control types,
• Conditional - A control decision is made by looking at current conditions
only.
e.g. A car engine may turn on only when the key is in the ignition and
the transmission is in park.
• Sequential - The controller must keep track of things that change and/or
know the time and/or how long since something happened.
e.g. A car with a diesel engine must wait 30 seconds after the glow
plug has been active before the engine may start.
Note: We can often turn a sequential problem into a conditional by
adding more sensors.
page 135
CONTROL
CONTINUOUS
LINEAR
LOGICAL
NON_LINEAR
CONDITIONAL
e.g. MRAC
e.g. PID
BOOLEAN
SEQUENTIAL
EVENT BASED
TEMPORAL
e.g. COUNTERS
e.g. FUZZY LOGIC
EXPERT SYSTEMS e.g. TIMERS
Examples:
continuous:
logical:
conditional:
sequential:
mixed (continuous and logical) systems:
• A Programmable Logic Controller (PLC) is an input/output processing computer.
page 136
• Advantages of PLCs are:
- cost effective for complex systems
- flexible (easy to add new timers/counters, etc)
- computational abilities
- trouble shooting aids
- reliable
- easy to add new components
• Ladder logic was originally introduced to mimic relay logic.
7.1 BASIC LADDER LOGIC
• The PLC can be programmed like other computers using specialized “languages.”
- Ladder Logic - a programming technique using a ladder-like structure. It
was originally adopted because of its similarity to relay logic diagrams
to ease its acceptance in manufacturing facilities. The ladder approach
is somewhat limited by the lack of loops, etc. (although this is changing).
page 137
OUTPUTS
HOT
NEUTRAL
INPUTS
POWER NEEDS TO FLOW THROUGH
THE INPUTS TO THE OUTPUTS
- Mnemonic - instructions and opcodes, similar to assembly language. It is
more involved to program, but also more flexible than ladder logic.
This will be used with the hand held programmers.
page 138
e.g. for an Omron PLC
00000
00001
00002
00003
00004
00005
00006
LDI
AND
LD
AND
ORB
OUT
END
A
B
C
D
the mnemonic code is equivalent to
the ladder logic below
E
A
B
C
E
D
END
• There are other methods that are not as common,
- sequential function charts/petri nets
- state space diagrams
- etc.
7.2 WHAT DOES LADDER LOGIC DO?
page 139
7.2.1 Connecting A PLC To A Process
PROCESS
Connections to
Actuators
Feedback from
sensors/switches
PLC
• The PLC continuously scans the inputs and changes the outputs.
• The process can be anything - a large press, a car, a security door, a blast furnace, etc.
• As inputs change (e.g. a start button), the outputs will be changed. This will cause the process to change and new inputs to the PLC will be received.
PLC program changes outputs
by examining inputs
Set new outputs
THE
CONTROL
LOOP
read inputs
process changes and PLC pauses
while it checks its own operation
7.2.2 PLC Operation
• Remember: The PLC is a computer. Computers have basic components, as shown below:
page 140
Keyboard
Input
SVGA Screen
Output
80586
CPU
Serial
Mouse
Input
133/200 MHz
Light output
2.1GB Disk
Storage
32MB Memory
Storage
• In fact the computer above looks more like the one below:
inputs
Keyboard
input memory
output memory
computer
Input Chip
CPU ‘586
Mouse
outputs
Screen memory
chips
monitor
Serial Input Chip
digital output chip
LED display
Flow of Information
Disk Controller
Memory Chips
Disk
storage
• Notice that in this computer, outputs aren’t connected to the CPU directly.
• A PLC will scan a copy of all inputs into memory. After this, the ladder logic program is run
once and it creates a temporary table of all outputs in memory. This table is then written to the
page 141
outputs after the ladder logic program is done. This continues indefinitely while the PLC is running.
• PLC operation can be shown with a time-line -
Self input logic output
test scan solve scan
0
Self input logic output
test scan solve scan
Self input logic
test scan solve
ranges from 1 to 100 ms
time
PLC turns on
SELF TEST - Checks to see if all cards error free, resets watch-dog timer,
etc. (A watchdog timer will cause an error, and shut down the PLC if
not reset within a short period of time - this would indicate that the ladder logic is not being scanned normally).
INPUT SCAN - Reads input values from the chips in the input cards and copies their values to memory. This makes the PLC operation faster and
avoids cases where an input changes from the start to the end of the
program (e.g., an emergency stop). There are special PLC functions
that read the inputs directly and avoid the input tables.
LOGIC SOLVE/SCAN - Based on the input table in memory, the program is
executed one step at a time, and outputs are updated. This is the focus
of the later sections.
OUTPUT SCAN - The output table is copied from memory to the output
chips. These chips then drive the output devices.
7.3 LADDER LOGIC
• Ladder logic has been developed to mimic relay logic - to make the computer more acceptable to companies and employees.
• Original efforts resisted the use of computers because they required new skills and
approaches, but the use of ladder logic allowed a much smaller paradigm shift.