Computerized Embroidery

Hi! I'm Robosew.

Robosew overall photo.
Robosew photo closeup.
Wiring circuit sketch.
ROBOSEW QBASIC program
RONOSEW program
TIMING program
STIKTEST program
TUNES program
ROBOSEW2 program 
RONOSEW2 program 
 Thread your way to home page.
   After seeing some computerized home embroidering/sewing machines in
operation, we were intrigued.  But they were priced in the range of a
good multimedia PC system.  We next happened upon a store where a large,
costly embroidery system was in operation making large jacket designs.
This was in the price range of a luxury car.  We decided we'd have to try
to make one much cheaper.   Our system lacks in speed and sophistication,
but it was a challenge and we applied many of our varied skills to develop
it.  It uses a computer-operated stepper-motor controller which is
connected to the printer port of a computer. The QBASIC computer language
(in DOS 5) is used.  Two stepper motors, a game port, a solid-state relay,
a simple photocell eye and any sewing machine are the major parts.  We
chose to use two worm screws to move the embroidery hoop and artwork frame.
Some mechanical and electrical handiwork was required.  All parts except
the precision worm screws and followers are common items.  The
artist/operator takes a photo of the subject and has enlargements made, or
sketches the artwork.
   Next determine the colors to use and the outlines to fill in with each
color, like paint-by-number pictures.  The outlines are traced onto plain
paper using dressmaker's carbon paper, one outline per color.  Then the
outlines are darkened in with a black marker or paint.  There is no limit
to how many thread colors you can use.
Note: There may be many patches of the same thread color in what we
are calling "one outline".  The artwork is put into the frame, under the
photo eye.  The chosen color thread is put into the sewing machine. (White
thread is always in the bobbin.) The foot control is taped down.  Motor
control is done by the computer and a solid-state relay.
  The BASIC program ROBOSEW.BAS is now run. Then the operator jogs manually
to the starting point of each patch by tapping the keyboard arrow keys.
The program sews in the areas.  The photo-eye sees the area's border.
When it reaches the edges, the frame moves to the next line.  When all is
done, it stops.  You then jog to the next patch.  The operator can stop
manually using the keyboard Escape key at any time.  The sewing machine
must have a switch added that tells the computer when the needle is up,
clear of the cloth.
  The needle-up signal is read in as a joystick button input.  We mounted
this switch on a small piece of metal clamped under the screw that secures
the machine lamp.  The needle clamp hits the switch arm when the needle is
up.  The sewing machine is set so that the feed dog, which normally
moves the cloth for each stitch, is down. Only ROBOSEW moves the fabric.
The foot pressure needs to be adjusted to light.  The needle motion is set
for straight stitch, not zig-zag.  So an old straight-stitch-only machine
could be used.  Try to find the type that have a separte plug for the lamp
and motor in the foot control socket. There are two potentiometers that set
the stitch length and embroidering angle, read in as joystick pots.  The
subprogram TIMING helps you set the motor-pulse width so that the motors
run as fast as possible with good torque but do not hum or chatter.  We
added a .68-ohm resistor in series with the stepper-motor current so that
the drive chips aren't overloaded.  Plenty of power is still available.
A wire goes from the Z-axis motor chip, UCN5804B, pin 11 (STEP) to the
(+) control terminal of the solid-state relay for motor on-off control.
Another wire goes from any ground point to the solid-state relay (-)
control terminal.
  Of course, the sewing machine power cord is in series with the solid-
state-relay (AC terminals), which acts like a toggle switch.  Included are
several BASIC subprograms and the ROBOSEW program.  These allow you to test
the joystick inputs, use different tunes for messages, set the timing pulse
width and test all motions without sewing.  You will find that your
parallel port (data and status) is either address 888 & 889 or 956 & 957,
so you may have to modify the program slightly.
   In some BASICs, the appropriate STRIG numbers are 0,2,4 & 6.  And
you must execute a X = STRIG(0) first in order to invoke any other
STRIG read-in.  In QBASIC the numbers are 1, 5, 3 & 7.  We only use 1
(needle) and 5 (eye).  The logical operations AND and XOR are used.  This
is necessary so only the correct bit is changed and others are left
unaffected.  Plus, you cannot change the motor STEP and DIRECTION at the
same time on the H & R controller board. We also found out that an AND
executes a positive turn-off of bits before we attempt a turn-on. XORing a
bit that was already on will turn it off.  Bit 0 on the data port is the X
motor STEP signal.  XORing with 1 turns it on. This means that bit 0 is
high.   ANDing with 30 turns it off.  This means all bits EXCEPT bit 0 are
high.  XORing a 2 on bit 1 makes the Xmotor go clockwise (CW).  ANDing a 29
makes it go CCW.   XOR 4 on bit 2 is on for Y motor STEP.  ANDing 27 turns
off the STEP.  XORing 8 on bit 3 makes Y motor go CW.  ANDing 23 on bit 3
makes it go CCW. XORing 16 on bit 4 turns on the solid-state relay (Z-motor
STEP).  ANDing 15 turns it off. This is the bit that controls the sewing-
machine motor via the solid-state relay.  At line 100 is a time delay.  It
is calculated using the TIMING subprogram. We found that 50 works best for
our system.  You may have to change this for your system.  The delay in
line 220 is just so the menu won't blink or blankout annoyingly.  This
program is in QBASIC.  To start it, go to the DOS directory (DOS 5
or higher).  Type QBASIC and hit ENTER.  When the screen comes up, hit
ESCAPE. Use the mouse to move to FILE on the top line.  Click the left
mouse button. Pull the mouse to place the cursor on OPEN and click.
Assuming your disk is in drive B, use arrow keys to back up to the start of
"*.BAS" and type B: andthen hit ENTER. (or type A: for the A drive)  You
will get a listing of all the BASIC programs.  Mouse down to ROBOSEW.BAS
and click, then down to RUNand click.  When it's in, move to RUN at the top
line and click.
  Now move down to START and click, or hit SHIFT & F5.  The program reads
some settings and gives you some choices.  Just follow instructions.
QBASIC does not need line numbers except where the program is to jump to
aline.  I have included them in all lines so any BASIC could be used.  You
can change anything before going to RUN by moving the cursor anywhere in
the program using the arrow keys and writing over the old values.
An underline cursor comes up first, and it inserts characters.  Use DELETE
to "eat up" characters pushed aside that you want to remove.  Or hit INSERT
and the cursor becomes a box and writes over previous characters.  If you
want to save the changed program, mouse up to FILE, click on SAVE AS.  When
the boxcomes up, use a different name, such as ROBOSEW3.BAS or similar.
This way the original program is still available when, not if, something
goes terribly wrong. Always expect the worst.  When starting up again, go
to the new program.
  You call up the programs TUNES.BAS, TIMING.BAS, STIKTEST.BAS and
RONOSEW.BAS and run them in the same way.  ROBOSEW2 just stitches at the
edges of the area to be embroidered.  RONOSEW2 is the same but with no
stitching, to get a "feel" for using the program.  You can also "stitch"
with no thread in the machine and with a sheet of heavy paper taped to the
embroidery hoop to see the pattern and see if everything is working.  The
light needs to be adjusted using the LED on the photo eye circuit
board and/or the "LIGHT/DARK" screen message.  Be sure window light and the
room lights don't change during embroidering.
  The BASIC command PLAY allows you to use musical tunes for message
alerts.  But like a printer, you can always hear when sewing has stopped.
 The variables used are in the BASIC program are:
B - beep flag so "turn on" reminder only beeps once (0 or 1)
T - timing delay set so motors work best
C - step count (joystick setting), determines stitch length C1,C2,C3,C4
counts per jog on +X, -X, +Y & -Y axes
P  - perpendicular step multiplier (fraction of C)
P1 - direction of perpendicular motion, right (1) or left (2)
P2 - move-perpendicularly-only-once toggle (0 or 1)
L  - light/dark joystick signal (0 = light, -1 = dark)
I$ - character input from the keyboard G loop counter for delays
D  - stitch angle, 0 to 180 degrees (joystick setting)
D1 - angle in radians for SIN and COS functions
N  - needle up/down signal from joystick (0 = down, -1 = up)
S  - stitch or don't-stitch flag (0 or 1)
A  - temporary register for logical operators XOR and AND
R  - up-or-down flag (1 or 2)
R1 - temporary next-direction register (1 or 2)
E  - exit toggle (0 to 6)
   The type of ink used for the artwork area patches is more important
than we realized.  Probably because the photo-transistor is made for
infrared light.  We found that a Sharpie permanent black marker works
well. But a fine-point Sharpie does not.  Neither did a Pilot black pen nor
an Eberhard-Faber Uniball black pen.  So experiment with what you have on
hand.  When you find the right pen and set the light right, a 1/16" black
dot will turn the LED off or display "DARK" on the screen.  The loupe must
be focussed correctly for this degree of resolution.  Do not put the sewing
machine on zig-zag inadvertently or you can bend the needle switch arm. And
check again that the feed dog (under the needle) stays down.  But don't
forget and leave it down when sewing normally.  The angle control can be
mounted flat so the knob pointer points directly toward the stitching
direction.  You'd need a 150K or 180K potentiometer and you'll only use 180
degrees of its rotary motion.
   You can add or modify anything. You could add thread-out, thread-broken,
bobbin-out, bobbin-thread-broken checks, etc. by using unused joy stick
buttons.  We just trust to watching & listening for now.  All thread-
problem switches could be wired in parallel (normally-open) or series
(normally-closed) into one joystick button.  As it is on ours, only two
buttons and two joystick pots are used.  Most every joystick cable has
these wires, but not all do!  The game port supports two more pots and
two more switches.
  On our plywood baseboard we mounted a standard wall outlet for the
sewingmachine power cord and for the 12VDC wall outlet power supply to
the controller board. This means we had to separate the two outlet jacks
by nipping the brass connectors between them on both sides.  The jack for
the sewing machine power cord goes thru the solid-state relay. The outlet
to the stepper-motor-controller board stays on all the time, of course.
The outlet is mounted on the baseboard by being bolted to two corner
braces.  The plain outlet also supplies current for the photo-eye-lamp.
  To use the software that comes with controller board, we had to take
our computer off TURBO.  We have a 486DX2 running at 66 MHz and it would
not run correctly otherwise.  Of course, if you could figure out the
motions for any embroidery pattern, you could use their software with a
large batch file to do all the work. Although the system is very slow,
someone needs to be watching it in case there is any problem such as the
bobbin emptying or the light brightness shifting and the photo-eye missing
the outline edge.
Major Parts:
controller board kit TM94KIT2694  (HR)
two stepper motors and two worm drives TM94KIT2602 200-steps/turn (HR)
worms are 16 TPI, so 200 steps = 1/16"
5VDC power supply for stepper-motor power (see note)
solid-state relay (several options)
gameport, joystick (for pots & cable)
power on-off switch, needle-up micro switch
corner braces, 2' x 3' x 3/8" plywood, wall outlet
no-frills sewing machine

Suppliers: RS = Radio Shack
           HS = hardware store
           PC = CompUSA, etc.
           TV = local TV-repair supplier
           HR = Harbach & Rademan (1-800-848-8001)
Note: You can have the power supply deliver the 5VDC to the steppers and
the 12VDC to the controller board instead of using the supplied wall
transformer.
(TM92PWS1427 $13, TM94PWS2723 $17, TM94PWS2647 $25)
The worm drives come with a follower, end bearing and coupler to connect to
the stepper motors (1/4" shaft).  You need to take the C-clips, graphite
bearing rings and springs off the followers.
WARNING, the springs are STRONG!
You could also use quality threaded rod and coupler nuts for the drives.
If you have to share your parallel port with a printer, you'll need an
extra male-male cable and switcher box.  You will know when you have not
switched over to the controller board because the motors will shiver.

Optoelectric light sensor parts:
 PC board                    276-159A
 phototransistor (black one) 276-142
 4.7K-ohm 1/4 W resistor     271-1330
 mini red LED                276-026
 180-ohm 1/4 W resistor
 74132 Schmitt trigger IC
 .68-ohm, 10W motor series resistor

 8X eye loupe (strong magnifier)                 (stamp/hobby shop) Other
 on-off switch 275-666
 needle switch 275-016
 .47-ohm resistor 271-130 (or 1-ohm 271-131)
 two 100k-ohm linear-taper pots 271-092 (instead of pots on joystick)
 6' parallel cable  26-249 (or 10' 26-291)
 switcher box 26-115
 Optional: heat sinks for motor chips (UCN5804B) 276-1363
 heat-conductor grease 276-1372

 The skirt of our 8X eye loupe is 1 1/8" up from the artwork and the
 photoeye on the PC board is held 2 1/2" above the eye loupe.  There is a
 cardboard tube from the lens to the photo eye.  This assembly is taped
 together using plastic tape.  The eye asssembly is clamped to a strong
 aluminum arm by a hose clamp and it can be focussed by sliding.  Use
 tissue paper to see the focus point and then mount the eye there.  Part of
 the loupe had to be cutoff to fit flat against the aluminum support arm.
 The eye lamp is mounted on the same arm.

 Gameport pins:
 1  +5 volts
                         15  +5 volts
 2  stick A, button 1
                         14  stick B, button 2
 3  stick A, X axis
                         13  stick B, Y axis
 4  ground
                         12  ground
 5  ground
                         11 stick B, X axis
 6  stick A, Y axis
                         10 stick B, button 1
 7  stick A, button 2
                          9 +5V
 8 +5 volts