|
|
|
|
|
|
|
|
The parallel printer port of a PC can be used to control stepper motors and other digital devices such as relays and solenoids. The parallel port is the D25 female connector at the back of the PC. Output bits can be switched on and off with simple commands and time delays between pulses can be adjusted to control speed.
This method of control is very economical as there are many old 386, 486 and Pentium 1 computers available on the second hand market. There are however some limitations to this method of control compared to a dedicated microprocessor based controller. However, it is often useful in applications such as telescope positioning, satellite tracking, slow machining and testing operations where high speed is not important.
Speed limitation
Because the step and direction pulses are generated by the computer's
internal clock and software, motor speed may be limited by the
clock frequency and software execution time.With a 486-SX running
MS Quick Basic we were able to generate about 12kHz maximum speed.
Computer ruggedness
Computers as controllers are not good at withstanding dirt found
in a factory environment, especially mice and keyboards. If the
computer is controlling a critical process, protect it in a cabinet.
Software
Writing the software to generate motor moves can be time consuming,
especially where acceleration ramping is required.
I/O limitation
The printer port of a computer is designed to run printers, not
stepper motors. There are only about 8 digital data outputs and
5 digital inputs available. This may not be sufficient for multiaxis
applications.
Software transportability
Because motor speed and acceleration are dependant on computer
clock speed, software may require recalibration when installed
on different computers.
Isolation
There is no electrical isolation in a printer port so an electrical
fault in a stepper drive could damage your computer. It is recommended
to use opto isolators to protect your computer.
Processing
time
A motor can only be running while the program is running so the
computer is not free to do other tasks such as calculations or
data collection.
Voltage
levels
A computer printer port uses 5V TTL levels which are more susceptible
to electrical noise than 12 or 24V levels.
CONNECTIONS
A printer port has the following pin connections. Outputs are 5V sourcing with maximum of 2.6mA current drain. It is possible to connect a high intensity, low current LED directly between a ground pin and one of the output pins 2 to 9. Take care that current does not exceed 2.6mA or the output port may be damaged. Inputs are switching low for logic low. They are internally pulled high to 5V via a resistor. Some of the inputs are inverted.
When using a computer port to control external devices, opto isolation is highly recommended to protect the computer from damage that may be caused by wiring errors or equipment faults. Some computers have the parallel output port on the main motherboard so damaging the port may destroy the whole computer.
|
OUTPUTS |
INPUTS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INTERFACE FOR RTA DRIVES
A stepper
drive requires a minimum of 2 inputs which are clock pulses
and a direction bit.
There
may also be a energise or de-energise input which is used
to switch motor current off or on.
The RTA stepper drives are available with two different types of inputs. The GMD, GMH, GAC and BCW drives use NPN current sink control inputs. The input pin is pulled high to 12V by a resistor and must be grounded to make something happen. The HGD, SDC, SAC and MIND drives use voltage sourcing signal which is optoisolated from the drive power supply.
Note that because stepper drives usually run on high voltages (from24 to 240VDC) electrical isolation between stepper drive and computer is important to prevent damage to computer in event of drive failure. However, isolation is not so critical with HGD, SAC, SDC and MIND drives as these already have built in isolation for input control signals. Note also that some optocouplers are limited in switching frequency (sometimes as low as 7kHz) and this will limit motor speed and resolution.
The following circuit examples will control both types of drives although motor speed limitations may occur due to optocoupler switching speeds. Although they show connection to only step input of the drive, similar circuits will also be required for direction and energise signals.
![]() Interface for GMD, GMH, GAC & BCW02 drives (not isolated) |
Interface for HGD, SAC, SDC & MIND drives (not isolated) |
Interface for GMD, GMH, GAC & BCW02 drives (isolated) |
Interface for SDC, SAC, HGD & MIND drives (isolated) |
|
|
Disclaimer
PC parallel
ports can be damaged by incorrect connections or components. Reasonable
care has been taken in producing this information, however, Automated
Motion Systems cannot accept responsibilty for any damage caused
to computers from the use of this information.
SOFTWARE FOR STEPPER
DRIVES
Port Addresses
The printer port contains both inputs and output signals. The
address for output signal byte is 378h for LPT1 and 278h for LPT2.
The address for the input status byte is 379h for LPT1 and 279h
for LPT2.
Switching Outputs
Bits can be switched on and off by sending an output byte to the
output address.
When a bit is switched on it will remain on until another command
is sent to switch it off.
The outputs operate in true logic, ie. logic 0 = 0V output and
logic 1 = 5V output.
In BASIC the command to send a byte to the output address is:
OUT &H378,
N
Where N is the number you want to send to the output address.
It must be an integer and between 0 and 255.
In ASSEMBLER the commands are:
MOV DX, 0378H
MOV AL,n
OUT DX, AL
For example, to
switch both bits 0 and 2 ON the command is OUT &H378, 5.
To switch all bits off the command is OUT &H378, 0
Reading Inputs
Bits can be read by checking the input status byte.
Inputs are true logic, ie. logic 0 = 0V and logic 1 = +5V.
Inputs are useful for datum, limit and emergency stop switches.
In BASIC the command is :
N = INP(&H379)
Where N is the integer value returned.
In ASSEMBLER the commands are:
MOV DX, 0379H
IN AL, DX
Stepper drives
When controlling a stepper drive, the direction bit must be switched
on before the clock pulse train is sent to the drive. It should
remain on until after the last clock pulse has been sent. Speed
of the stepper motor can be adjusted by introducing a variable
time delay between pulses sent to the drive. Time delays can be
generated by giving the computer a simple mathematical task to
do and put it in a repetitive loop. Note that this will vary between
different computers with different clock speeds.
It is recommended that programs are run in a DOS operating system in preference to Windows. Running BASIC in DOS is faster and pulse trains from the printer port are not delayed or interrupted by the Windows software.
Here is an example of a simple stepper motor program without ramping. If required ramping can be generated by running the motor through a series of different speeds, gradually increasing with respect to time.
CLS
REM bit 1 = step, bit 2 = direction
PRINT Type in DISTANCE (steps), SPEED (Hz), DIRECTION (0
or 1)
INPUT distance, speed, direction
delay = INT( 800 / speed * 9 ) ;work out number of loops required
to generate delay for one step
FOR J=1 TO distance
OUT &H378, 1+direction ;output pulse ON and direction bit
as defined
FOR K=1 TO delay ;time delay loop for ON time
X=10^2
NEXT K
OUT &H378, direction ;output pulse OFF and direction bit as
defined
FOR K=1 TO delay ;time delay loop for OFF time
X=10^2
NEXT K
NEXT J
END
Pulse width
Stepper
drives have some filtering on the step input terminal. This is
necessary to prevent electrical noise and spikes being interpreted
as clock pulses. For this reason, a clock pulse must have a minimum
duration. This must be taken into account when writing software.
The GMD, GAC and BCW drives require a minimum pulse duration of
about 9 microseconds. The GMH, HGD, SDC, SAC and MIND drives require
about 5 microseconds.