Michael
DiRamio
Leigh
Pauls
Sir
Winston
Churchill
Secondary
District
School
Board
of
Niagara
Michael
Grieve
Pierre
Ellio:
Trudeau
High
School
York
Region
District
School
Board
Interfacing
System
Wires
Wires
Connected
(Horizontally)
Breadboard
Connected
(VerIcally)
Connected
Divider
(Horizontally)
Hardware
• 12V
DC
Power
Supply
(1)
• NPN
Transistors
(4)
• DB25
Connector
(1)
• Male
Pins
(12)
• 12V
Stepper
Motor
(1)
• Wire
(about
3
feet
with
crimps,
some
loose
wire)
• Diodes
(4)
• Resistors:
330
Ohm
(4),
1K
Ohm
(4),
220
Ohm
(4)
• Red
LEDs
(4)
Interface
Wire
Crimp
vs
Solder
Types
• Crimp
style:
– Pins
are
crimped
on
to
the
wires
and
then
inserted
into
the
connector.
– Works
best
with
a
crimping
tool,
but
needle
nose
pliers
will
work.
• Solder
style:
– Pins
are
already
in
the
connector.
– Wires
are
soldered
onto
lugs
at
the
back
on
the
connector.
SoWware
‐
Turing
• parallelput
• parallelget
• if
• for
• loop
• Provincially
Licensed
and
now
free
from
Holt
SoWware
Associates
Inc.
(www.holtsoW.com)
Parallel
Port
• How
we
connect
to
the
computer.
• Pins
are
numbered
1
‐
25
• Turing
uses
– 8
outputs:
D0
–
D7
– 5
inputs:
S3
–
S7
• We
will
also
use
a
ground.
There
are
many,
but
we
only
really
need
one
of
them.
S4
S5
S7
S6
D7
D6
D5
D4
D3
D2
D1
D0
Output
13
12
11
10
9
8
7
6
5
4
3
2
1
Input
25
24
23
22
21
20
19
18
17
16
15
14
Grounds
S3
Input
Interfacing
with
Turing
(output)
• The
command
parallelput
takes
a
number
from
0
–
255
as
a
parameter.
• Based
on
this
number,
specific
outputs
will
turn
on
and
off
(based
on
this
number
in
binary)
• A
one
means
that
output
is
high,
a
zero
means
it
is
low.
D7
D6
D5
D4
D3
D2
D1
D0
parallelput
(128)
(64)
(32)
(16)
(8)
(4)
(2)
(1)
14
0
0
0
0
1
1
1
0
45
0
0
1
0
1
1
0
1
2
0
0
0
0
0
0
1
0
255
1
1
1
1
1
1
1
1
Interfacing
with
Turing
(input)
• Similar
to
parallelput
in
that
it
interprets
pins
from
the
parallel
port
as
binary
digits.
• The
method,
parallelget,
returns
a
value
based
on
the
inputs
of
S3
–
S7
being
high
or
low.
• This
project
will
only
be
using
output
to
the
parallel
port,
not
input.
Stepper
Motor
1
2 4
3
Stepper
Motors
• Meant
for
accurate
posiIoning,
not
conInuous
rotaIon
(but
it
can
do
that!).
• Uses
electromagnets
to
step
along
the
different
posiIons
around
the
circle.
• Two
types:
– Unipolar:
more
common
for
our
interfacing
projects,
less
complicated
interface.
– Bipolar:
need
to
reverse
the
direcIon
of
current
through
the
motor.
More
complicated
to
interface.
Stepper
Motor
Control
• To
spin
the
motor
conInuously,
use
a
loop
to
go
through
each
step
in
sequence,
then
returning
back
to
step
one.
– Step
Sequence:
1,
2,
3,
4,
1,
2,
…
• To
refine
the
accuracy
of
the
steps,
turning
two
magnets
on
at
the
same
Ime
can
make
it
go
in
between
them.
This
provides
smaller
steps,
but
uses
more
power.
– Step
Sequence:
1,
1
&
2,
2,
2
&
3,
3,
…
STEPPER
MOTOR
PROJECT
Purpose:
Create
a
visual
representaIon
of
a
student’s
mark
as
a
meter
from
0
to
100.
The
needle
will
point
to
the
proper
place
for
an
entered
mark.
In
creaIng
the
meter
we
will
be
learning
concepts
that
can
be
applied
to
many
different
stepper
motor
based
projects.
50
0
100
Connect
Power
Supply
• PosiIon
breadboard
with
negaIve
(blue)
rail
at
the
top.
• Insert
the
power
supply
wires
into
the
two
rails
across
the
top
(any
hole,
but
make
sure
they
don’t
touch).
• Link
the
top
and
boiom
negaIve
rails
together.
At
other
end
link
the
two
ground
rails
Dashed
together
Wire
is
PosiIve
Note:
Transistor
• Think
of
it
as
an
“electronic
switch”.
• Power
flows
from
the
collector
to
the
emiier.
• The
base
acts
as
the
“switch”.
If
power
is
applied
to
the
base,
the
transistor
allows
current
to
flow
through
the
collector‐emiier
path.
Emiier
Collector
Base
Place
Transistors
• Place
the
four
transistors
in
the
breadboard
all
facing
in
the
direcIon
shown.
• Leave
at
least
two
holes
Metal
at
back
of
transistor
behind
each
transistor.
Connect
Emiier
Pins
to
Ground
Emiier
is
the
pin
In
ground
on
the
right
(blue)
rail
Use
the
spare
wire
provided
in
your
kit
(not
the
one
with
crimps
on
it)
Note:
Resistor
Colour
Chart
• Resistors
are
labeled
by
coloured
stripes.
Colour
Band
1
Band
2
Band
3
Black
0
0
(100)
=
1
Brown
1
1
(101)
=
10
Red
2
2
(102)
=
100
Orange
3
3
(103)
=
1
000
Yellow
4
4
10
000
Green
5
5
100
000
Blue
6
6
1
000
000
Violet
7
7
10
000
000
Gray
8
8
100
000
000
White
9
9
1
000
000
000
Note:
IdenIfying
the
Resistors
• We
will
be
using
two
resistors:
330
Ohm
and
1K
Ohm
(1K
=
1000).
NegaIve
End
(Marked)
Connect
Resistors
and
Diodes
• Insert
the
330
Ohm
Resistors.
• Make
sure
the
diodes
are
in
the
correct
direcIon.
(NegaIve
end
into
transistor)
Diode
negaIveend
in
Collector
Resistor
in
(middle
pin)
Emiier
(right
pin)
Same
Column
to
Connect
Resistors
to
Transistor
Base
• Insert
the
1K
Ohm
resistors.
• This
will
be
connected
to
the
interface
from
the
parallel
port.
Resistor
in
Base
(leW
pin)
In
Empty
Column
Aiach
Wires
to
Dsub
Connector
• The
chart
below
outlines
where
each
wire
is
to
be
connected,
and
its
use.
• Use
the
crimped
end
of
the
3‐foot
cable.
Pin
Number
Wire
Colour
Use
2
(D0)
Blue
Stepper
A
3
(D1)
Green
Stepper
A*
4
(D2)
Orange
Stepper
B
5
(D3)
Brown
Stepper
B*
25
(Ground)
White‐Green
Ground
Pins will click into place when fully inserted.
Aiach
a
spare
piece
of
wire
to
the
Dsub
(easier
to
pull
out
of
computer)
DSub
wires
to
Breadboard
• Expose
about
8cm
of
the
other
end
of
the
wire.
• Strip
about
0.5cm
from
the
end
of
each
of
the
wires
used
from
the
Dsub
to
the
breadboard.
• Connect
each
wire
to
the
1K
resistors
on
the
breadboard.
White‐green
Blue
Green
Orange
Brown
in
ground
rail
Resistor
for
LED
• Add
the
220
ohm
resistors
in
the
same
column
as
the
1K
ohm
resistors
and
wires
from
the
Dsub
connector.
Other
end
in
empty
column
All
three
in
same
column
Note:
LEDs
• Light
Emiqng
Diodes
• Share
the
same
property
as
a
normal
diode,
energy
can
only
flow
in
one
direcIon.
Add
LED
• Connect
posiIve
to
empty
end
of
220
ohm
resistor
and
negaIve
to
the
ground
rail.
Connect
posiIve
end
to
resistor
NegaIve
end
in
ground
Aiach
Needle
• Use
hot
glue
to
aiach
the
pipe
cleaner
“needle”
to
the
motor.
• Put
glue
on
the
pipe
cleaner,
then
aiach
this
to
the
motor
to
avoid
geqng
glue
in
the
motor.
Aiach
Stepper
Wires
to
Breadboard
Black
(in
posiIve
rail)
Green
Wire
Use
Colour
White
Red
Black
Common
Brown
12V
White
A
Green
A*
Red
B
Brown
B*
Motor
wires
go
in
collector
(middle
pin)
of
transistor.
Programming:
Steps
Full
Steps
‐
2
possibiliIes
Half
Steps
(200
steps,
1.8°
per
step)
(100
steps,
3.6°
per
step)
Step
A
B
A*
B*
Out
Step
A
B
A*
B*
Out (1)
(4)
(2)
(8)
put
(1)
(4)
(2)
(8)
put
1
On
1
1
On
On
5
2
On
On
5
2
On
On
6
3
On
4
3
On
On
10
4
On
On
6
4
On
On
9
5
On
2
Step
A
B
A*
B*
Out
6
On
On
10
(1)
(4)
(2)
(8)
put
1
On
1
7
On
8
3
On
2
4
On
8
Programming:
Basics
• It
is
important
to
put
a
pause
between
the
steps.
– 15
ms
works
well
Sample
Program:
parallelput(5) % step 1
delay(15) % pause
parallelput(6) % step 2
delay(15) % pause
parallelput(10) % step 3
delay(15) % pause
parallelput(9) % step 4
delay(15) % pause
Programming:
Procedure
for
Steps
procedure step(stepNum : int)
if stepNum = 1 then
parallelput(5)
elsif stepNum = 2 then
parallelput(6)
elsif stepNum = 3 then
parallelput(10)
else
parallelput(9)
end if
end step
Programming:
Looping
Through
Steps
var currStep : int
currStep := 1
var moves : int
put “Enter the number of steps”
get moves
for i : 1 .. moves
step(currStep)
delay(15)
currStep := currStep + 1
if currStep > 4 then
currStep := 1
end if
end for
Programming:
PosiIoning
• The
stepper
motors
we
are
using
have
100
steps.
This
means
that
each
step
is
3.6°
(half
steps
are
1.8°).
• We
will
be
using
half
of
this
range
with
a
mark
of
0
being
0°
and
a
mark
of
100
being
180°.
Programming:
Mark
Meter
var mark : int
put “Please enter the mark”
get mark
www.digikey.ca
www.abra‐electronics.com
Salvaging
Stepper
Motors
• As
a
cheaper
alternaIve
to
the
purchasing
stepper
motors,
they
can
be
salvaged
from
devices
such
as
printers.
• This
websites
will
help
idenIfy
what
each
wire
does
in
a
salvaged
stepper
motor:
– hip://ssecganesh.blogspot.com/2008/05/idenIfying‐
leads‐of‐unipolar‐stepper.html
– hip://www.me.umn.edu/courses/me2011/robot/
technotes/stepper/
• AddiIonal
Stepper
Motor
Resource:
– hip://www.cs.uiowa.edu/~jones/step/types.html
Contact
Us
• Michael.Diramio@dsbn.edu.on.ca
• www.mr‐d.ca