This is only a preview of the May 1999 issue of Silicon Chip. You can view 33 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "The Line Dancer Robot":
Items relevant to "An X-Y Table With Stepper Motor Control; Pt.1":
Items relevant to "Three Electric Fence Testers":
Items relevant to "Heart Of LEDs":
Items relevant to "Build A Carbon Monoxide Alarm":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
X‑Y TABLE
WITH
STEPPER
MOTOR
CONTROL
From the number of enquiries we
receive it is obvious that there is a
great amount of interest in machine
control. With this in mind, we have
produced a practical demonstration
X‑Y table project using stepper motor control. It could be expanded to
control a variety of processes and
machines.
First of all, though, perhaps we
should explain what an X-Y table is
because many readers may not have
come across such a device before.
Casting your mind back to school
days, you will recall that a graph has
two axes, the “X” axis, which is the
horizontal direction, and the “Y”
axis – not surprisingly, the vertical
direction.
Within the confines of the graph,
any point can be located from the
origin by giving its coordinates in
terms of plus or minus X units, and
plus or minus Y units. The origin, or
reference point, is normally called
(0,0), meaning X=0 and Y=0.
The same logic – no pun intended
(or was it?) – can be applied to locate
positions away from an origin for just
about anything, as long as you know
the units being used. Map co-ordinates are just one example.
Suppose we want to locate a position on a solid (flat) object? Exactly
the same system applies. And this is
the basis for the X-Y table.
We lock the object – a piece of paper for drawing on, a PC board to be
drilled, a piece of metal to be engraved
– in position, and by either moving the
object with respect to a fixed point, or
moving something else with respect to
the fixed object, we can move a pen, a
drill, an engraving head, you name it,
to an exact spot by giving it the X-Y
coordinates.
In this case, we cheat a little and
place our origin (0,0) in the bottom
Have you been
wondering how
to use the stepper
motor driver cards
we featured in the
latter stages of 1997?
We had this project
in mind then and
though it has taken
a while, it has finally
come to fruition.
This series of articles
will show you how to
assemble the hardware and software
to drive an X‑Y table.
PART 1:
INTRODUCTION
left hand corner, so all points on the
object are positive numbers (it just
makes life easier to do it that way).
X-Y tables are commonly used in
a huge variety of applications from
industry through to medicine and
virtually everything in between.
Our X-Y table is reasonably small
by industry standards but it will be
capable of doing quite large and sophisticated jobs.
In the months to come, it will be
extended so that it can be used to plot
and drill PC boards which have been
laid out using Protel. For the moment
though, let us now describe the basic
X‑Y table with stepper motor drive.
An IBM-style computer is used as
the interface between the operator
and the table. It doesn’t have to be
the latest whizz‑bang Pentium. A 486
or even a 386 will work quite well as
long as it has a VGA graphics card
fitted. While the slower processors
Mechanical Design & Construction by Ken Ferguson
Electronics by Rick Walters
24 Silicon Chip
To be fully described next month,
here is the complete X-Y table with
a blank piece of PC board mounted
in its clamps. Construction should
be well within the capabilities of
most hobbyists with basic
metalworking and welding skills.
will take a little longer to run a task,
the stepping speed of the motors will
be the limiting factor.
Most programs, although written
in GW Basic, are supplied as an EXE
as well as a BAS file. The BAS file
will allow you to readily make any
changes to the software that you may
deem necessary.
The computer controls the dual
stepper motor driver card, featured in
the September 1997 issue of SILICON
CHIP. The +5V and +12V supplies for
this card can be picked up from an
internal disc drive power connector
or from an external power supply.
The stepper motors we have used
are 12V 1.8° types which with the
hardware used, make four steps for
a table movement of one thousandth
of an inch (.001"). In some respects
this is too fine, as it takes a while
to traverse from zero to maximum
but with the limited availability of
threaded rods, this proved to be the
optimum choice.
Although Australia is a metric
country, Imperial measurements were
chosen as most PC board components
are still laid out on an Imperial grid
(ie, 100ths and 10ths of an inch).
The outline of the table measures
750mm x 700mm and the X and Y
axes can each traverse 300mm.
Software details
We shall describe the software first
before we go onto the mechanical
side, as this will be your interface
while operating the table.
The control screen is shown in
Fig.1. This is the only screen for XYTABLE.BAS or XYTABLE.EXE and
shows the current X and Y position
of the table, along with a menu across
the bottom of the screen.
“Arrow keys X‑Y direction” indicates that the four arrow keys on the
keyboard are used to move the table
in the X and Y directions. The right
arrow and up arrow keys increase the
X and Y position, while the left arrow
and down arrow keys reduce it.
The next menu entry is “I or M ‑
units”. These keys select either an Imperial or Metric screen display of the
current X and Y position. The metric
display (Fig.2) is just a mathematical
conversion of the inch value. If the
Metric display is selected, then the X
and/or Y co‑ordinate is changed and
the table will only move to the closest
converted Imperial measurement.
If, for example, we commanded the
table to move to 25mm it would move
to 25.018mm or .985 inches. The next
lower imperial step is .984 inches and
this converts to 24.994mm which is
less than the 25 called up.
“X‑Y to set” indicates that by
pressing, for example, the X key on
the keyboard, you will be asked for
the new X position. This message
is shown in Fig.3. The value can be
entered as a number with a decimal
point (ie, 3.2 or 3.186) or without the
decimal point (ie, 3200 or 3186). On
the metric display, entering 43 will
be interpreted as 43mm.
You are then asked if you wish to
alter the Y position. You may enter a
value or by pressing the ENTER key,
you can bypass this entry. Similarly,
pressing the Y key follows the same
MAY 1999 25
sequence in the reverse order. If values larger than the
preset maximum values are entered, the table will move
to the maximum and then stop.
The menu shows another keyboard function key
as “S‑Stepinc”. Pressing this key allows you to select
Manual or Automatic control of the stepping increment
in units, tens or hundreds of thou (U, T or H). After a
value is selected, the arrow keys will only step in that
increment. Fig.4 shows the screen with the three feed
increments after M (for manual) has been pressed.
If the “X‑Y to set” mode is used, the program will
switch to automatic stepping and leave the feed set to
the last automatic stepping increment. The automatic
mode always steps in the largest possible increment
(hundreds), stepping down to tens and units (if necessary) as it homes to the selected coordinate.
Stepping rate
All the functional keys described so far are shown
in the menu bar at the bottom of the screen. There is
one additional key which is not identified on the menu
and this is the R key. It is used initially to optimise the
stepping Rate.
When the R key is pressed, the current stepping delay
is shown with an invitation to change it; a bigger delay
will slow the rate and vice versa. This value can be tested
while running the program by selecting X or Y values
an inch larger or smaller than the current position then
reducing the value until the motors begin to mis‑step,
then increasing it until they run smoothly again.
The motors can be stopped at any time by hitting the
spacebar (or any key). They will always make one additional step before stopping, as the instruction to look for
a keypress is at the beginning of the stepping subroutine.
There are two other keys which you may find useful.
The HOME key will rapidly move the table to X=0, Y=0
when it is pressed and the END key will move the table
to the maximum limits.
These limits, along with a few other parameters which
will be explained later, are initially written to a disc file
(XYPLOT.FIL) using a separate program (XYSETUP.BAS
or XYSETUP.EXE).
We will not go into the details of the stepper card in
this article. If you need more information, refer to the
September 1997 issue. The card is allocated an address
between 1 and 8 via a jumper on it and this allows the
computer to control several cards connected in parallel
to the one printer port.
The selected address of this card is also written to the
disc file. This file allows you to run XYTABLE.EXE but
alter the values it uses, as the compiled EXE program
runs a great deal faster than the interpreted Basic.
The other parameters saved to the file are the X and
Y positions each time the program is exited, the motor
stepping rate, the selected measurement units and the
printer port used to drive the card.
Figs. 1-4 (left): these X-Y table control screens are fully
described in the text. The difference between the first and
second screens is that the first is imperial and the second
metric – even though Australia uses the metric system,
most engineering specifications are given in imperial
units.
26 Silicon Chip
When using this interface card, it is
important that the program is loaded
and run before the 12V is applied to
the cards. When power is applied to
the card, the outputs of IC2 may be
high or low. This is a random function
but if the Q0 and Q1 outputs were
both high, Q1 and Q4 as well as Q2
and Q3 would be turned on, causing
at least one transistor to self‑destruct.
The others could also be seriously
damaged.
Relay modification
To overcome this problem, we have
produced an add‑on circuit with some
extra logic and a relay to switch the
+12V supply to the output transistors
only after the software has set all IC2's
outputs low.
The circuit for this modification is
shown in Fig.5. At switch‑on, both
flipflops are reset by the 1MΩ resistor
and the 0.1µF capacitor connected to
pins 14 and 15, which means that the
Q outputs are low. Thus D1 and D2
will hold the base of Q1 low and the
transistor will be turned off.
When the software is run, it first
sets all the IC2 outputs low then takes
IC1‑Y6 low and high then IC1‑Y7 low
and high. These outputs are normally
high but again, at power‑up any one
output could be low. This is why we
toggle two outputs (to be sure, to be
sure). As each flipflop is clocked the Q
output will go high. The 1kΩ resistor
will now pull the base of Q1 high,
which will energise RLY1 which feeds
the 12V supply to the output drivers.
If you already have this card you
could build the circuit up on a piece
of perf board and mount it on the PC
board in the vacant area adjacent to
IC2.
Maximum stepping rate
The maximum motor stepping rate
will vary, depending on several factors: the applied motor voltage, the
motors themselves and the computer’s clock speed. We need to step the
motors as fast as possible but there
is a problem.
If the maximum stepping speed was
set to suit a 486, then if the program
was run on a Pentium, it would step
the motors so quickly that they would
not be able to respond and would just
sit there chattering.
We found values around 190
worked well with a 386 using GW‑Ba-
sic and 1950 when using the EXE file.
Use these values as the starting point
for faster computers. Don’t contemplate running the BASIC program for
anything but testing your software
modifications as it is FAR TOO SLOW
to be useful.
While XYTABLE is useful for manoeuvring the table and getting the
feel for the system, it is not much use
if you wish to move it through a sequence of positions over and over. To
this end, we have produced another
program called XYREAD.BAS. This
is capable of reading a sequence of
positions which you have tabulated
and saved as a file. It has not been
converted to an EXE file as you will
obviously wish to modify it to add
your particular requirements to it.
We have made the table move to the
X‑Y position it reads from the file then
the computer will beep, waiting for a
keypress. It will then move to the next
set of co‑ordinates it reads and beep.
The opening screen for this program
is similar to that of Fig.1 except that
instead of a menu across the bottom
of the screen, you will be asked for
the name of your file.
To assist you we have included a
Here is a close-up of one of the two stepper motors and drive mechanisms for
the X-Y table. The stepper motors themselves are commonly available 12V,
1.8° types which with the hardware used, make four steps for a table
movement of one thousandth of an inch. That’s pretty good accuracy by
anyone’s standards!
MAY 1999 27
file named XYTEST.MOV which has
a sequence of X‑Y movements.
The file structure is based on that
used by NC drills but without tooling
information. It consists of an X location followed by a Y location. If either
location stays the same on the next
step only the new value is printed.
A brief extract of a typical file
would look like this:
X04125Y008
X045
X00825Y0065
X00975
Y039
As you can see, it consists of one
X‑Y instruction per line. All dimensions are based on 99.999" being the
maximum allowable value, although
the decimal point is omitted.
Thus X04125Y008 defines X at
4.125" and Y at 0.8". If the X value
was to remain the same the next entry
(on the next line) could be Y00775.
Trailing zeros are omitted.
Once the end of the file is reached
the table is homed to 0,0. This is just
a precaution in case XYPLOT.FIL is
corrupted, as this file stores the last X
and Y co‑ordinates before the program
is exited.
A file like this can easily be created
with a text editor using non‑document
or ASCII mode to save it. We have
used the MOV suffix for our file but
you may choose whatever you find
logical. However, you should always
add a suffix, as it helps to identify or
Fig 5: this add-on circuit for the stepper motor controller will prevent
damage if two outputs are high at the same time. It can be built on a
scrap of perforated board or even blank PC board.
group files (DIR *.MOV), especially
if you don’t create a special subdirectory.
The seven files, XYREAD.BAS, XYTEST.MOV, XYTABLE.BAS, XYTABLE.EXE, XYSETUP.BAS, XYSETUP.
EXE and XYPLOT.FIL are available
free from our web site, or on floppy
disc (price is $7.00 including p&p
from SILICON CHIP).
If you don’t have a subdirectory
called BAS on your hard disc, create
one (from c:\ type MD BAS then press
Enter). Copy the seven files to this
directory, and either add C:\BAS; in
your path statement or change to the
BAS directory (CD \BAS) to run the
programs.
Naturally, if you edit the BAS programs you can change the file location
in line 6030 to suit yourself.
Next month, we will give details
of construction for the X‑Y table. See
SC
you then.
This photo shows three
projects: (right) the power supply for
stepper motor cards
(December 1997), and
left, the controller for
two stepper motors
(September 1997)
mounted in a case,
together with the
single stepper controller
(August 1997) which
will give X, Y and Z
control. Whoops! Have
we let the cat out of the
bag? OK, an X-Y-Z table
is planned for a future
issue!
28 Silicon Chip
|