Printer Carriage Motion Control Laboratory
Printer Carriage Motion Control
Learning Objectives
By the end of this laboratory experiment, the experimenter should be able to:
Use a quad push-pull driver hip for bi-diretional !C motor ontrol "ith an #rduino$
Use refletive photo-s"ithes, opto-interrupter s"ithes, and miro-s"ithes for limit sensing
%xplain ho" and "hy limit s"ithes are used to prevent over-travel of moving omponents$
Components
&ty$ 'tem
( #rduino !uemilanove board ") #*mega+,- miroontroller
( U.B # to B able
( .olderless breadboard
( Printer arriage assembly
( /ptial-interrupter s"ith 01airhild 2,(L*B3
( Photo-refletive opto sensor 01airhild &4B((+53
, 4oller lever momentary s"ith 0/mron ..-67L,3
( .89655(: 0&uad 2alf-2 driver3 or L,;+! 0&uad Push-Pull driver "ith diodes3
( 95L.:5 hex inverter
Overview
*he purpose of this lab is to help you learn ho" onstrut a system "ith multiple sensors and an atuator,
and interfae these "ith the #rduino)#*mega+,-$ 1igure ( sho"s ho" all the omponents ome together to
omplete the printer arriage motion system$ *he proedure belo" "ill guide you in building and testing
piees of the system and then integrating them into a omplete system$
Figure 1. Printer carriage system. *he printer arriage system ontains: t"o sensors: a photo-refletive opto
sensor and photo-interrupter s"ith< a po"er interfae 0the .89655(: and ()= of the 95L.:53< the arriage motor,
and t"o .P.* s"ithes to provide fail-safe end-of-travel limits$ *he onnetions bet"een the modules and #rduino
are made through 6-"ay binding posts on the printer arriage assembly$ *he opto sensors and the .89655(: need
>6 ? to operate, "hereas >9 ? "ill be applied to the ?. pin of the .89655(: to po"er the motor$
Introduction
."ithes are ommon devies that permit or interrupt the flo" of urrent$ 'n addition to simply ontrolling
eletrial po"er to a devie 0suh as a motor or light3, they an be used in motion ontrol to detet "hether
or not a movable element has reahed a predetermined position$
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
A r d u
i n o /
A T m
e g a 3
2 8
IN 1
IN 2
EN 1
.89655(:
74LS04
>6?
(: C
OUT 1
OUT 2
motor
reflective opto
optointerrupter
Limit
SW 1
Limit
SW 2
tact
switch
>6?
/P*/ P/D%4
/P*/ 78!
>9?
>6?
D8
D9
D2
Page ( of 9
Printer Carriage Motion Control Laboratory
Mehanial s"ithes ome in a variety of designs$ *hey are ategoriEed by the number of poles and thro"s
they have$ *he number of poles represents the number of separate iruits that an be ompleted by the
same ation of the atuating lever or button$ *he number of thro"s represents the number of individual
ontats for eah pole$ *he most ommon types are sho"n in 1igure , belo"$
Figure 2. !amples o" di""erent switc# con"igurations. *he number of poles represents the number of separate
iruits that an be ompleted by the same ation of the movable ontat0s3 inside the s"ith$ *he number of
thro"s represents the number of individual ontats for eah pole$
Miro-s"ithes typially refer to mehanial s"ithes of small siEe that have a spring-loaded, momentary
ontat, operated by a push-button diretly or via a pivoted antilever$ Miro-s"ithes find use in many
onsumer produts suh as notebooC omputers, applianes 0to detet if a over is losed3, et$ ."ithes
are omprised of moving or sliding mehanial elements are designed to operate for thousands to hundreds
of thousands of on-off yles$
/ptial s"ithes 0e$g$ opto-interrupters, opto-refletors, et$3 are non-mehanial s"ithes made up of a
light-emitting diode 0L%!3 and a phototransistor$ #s sho"n in 1igure +, light from the L%! shines to"ard
the base of a photransistor aross a gap in the housing of the s"ith$ *he output of the photransistor "ill
indiate "hether or not something is bloCing the light from the L%!$ /pto-interrupters are often used in
mehatroni devies to indiate that a movable element has reahed a speifi position or an end-of-travel
limit$ !evies that use optial s"ithes inlude printers, opiers, and manufaturing automation systems$
/pto-interrupters are attrative to use, beause they are solid-state, reliable, relatively inexpensive, and are
straightfor"ard to interfae "ith logi iruits$ .ine they operate "ithout physial ontat, they have the
advantages of longer lifetime, higher reliability, and faster atuation time ompared to mehanial s"ithes$
Fou are going to use t"o types of optial s"ithes, a refletive 01airhild &4B((+53 and an interrupter-
type 01airhild 2,(L*B3 on a printer mehanism and use them in driving a printer arriage bet"een preset
limits$ Fou "ill also use t"o .P.* miros"ithes to provide a fail-safe limit on the end-of-travel of the
arriage in ase one of the opto-s"ithes fails$
Figure $. Opto switc# sc#ematic. *he opto interrupters used on the printer arriage are solid state devies
onsisting of an infared-L%! and an 8P8 transistor$ Dhen the L%! shines on the phototransistor, this auses a
urrent to flo" from the base to the emitter$ *he base-to-emitter urrent in turn an ontrol urrent from olletor-
to-emitter assuming that there is a iruit onneted to the olletor from a voltage soure$
%ssembling t#e &ystem
#s "e have done in past expermiments, "e "ill again onstrut the system in a modular "ay by building
and testing pieces of the system as "e go$ *his is al"ays a good general approah in any Cind of
engineering, "hether it be eletroni "orC, system design, or omputer programming$ #void the temptation
to "ire everything up first and hope that it "ill all "orC the first time$ .uh an approah is doomed to fail,
and you "ill end up spending more time trying to figure out "hat is not "orCing than if you simply build
and testing eah individual subsystem as you go along$
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
Single-pole/single-throw (SPST) Single-pole/double-throw (SPDT)
Double-pole/double-throw (DPDT)
Double-pole/single-throw (DPST)
Page , of 9
Printer Carriage Motion Control Laboratory
1irst you "ill "orC "ith the sensors and maCe sure that they are "orCing properly$ *hen you "ill onnet
the sensors to the #rduino$ 8ext, you "ill "orC "ith the .89655(: hip, and finally you "ill pull
everything together to omplete the printer system$
7et a printer arriage assembly from your lab instrutor$ *he next three setions "ill guide you through
some tests to ensure that all the sensors on the assembly are "orCing properly$
'e"lective Opto(switc#
1irst, before onneting anything, verify the proper funtioning of the refletive opto-s"ith, "hih is
mounted on a braCet and attahed to the side of the printer losest to the motor$ ?erify that it is operating
properly using the proedure belo"$
($ .et the >=? output terminal on the 2P %+=+:# *riple /utput Po"er .upply to output >6?$ Using
banana-to-banana test leads, onnet the >6? output and the Common output from the po"er supply
to the respetive /P*/ P/D%4 and the /P*/ 78! GaCs on the printer arriage assembly$
,$ Measure the voltage at the binding post that is onneted to the output of the reflective opto-sensor
0the one shaped liCe an Harro" headI3 "hen the aluminum plate on the arriage is in front of its fae
0this is the HbloCedI ondition3$ )#at voltage do you measure* and w#at does t#is voltage
represent* logic #ig# or low+
+$ Move the printer arriage, so that the refletive optosensor is no longer bloCed, and measure its
output voltage$ )#at voltage do you measure* and w#at does t#is voltage represent* logic #ig# or
low+
5$ )#at s#ould t#e voltages be in parts 1 and 2+
'f you are satisfied that the opto-refletor is "orCing orretly, go on$ 'f not, figure out "hat is "rong, and
fix it, or asC you lab instrutor for help$
Opto(interrupter
CheC that the photo-interrupter, the sensor "ith the big slot in it that is mounted on a braCet and attahed
to the side of the printer frame furthest a"ay from the motor, is operating properly$
5$ Measure the voltage at the binding post that is onneted to the output of the opto-interrupter "hen the
aluminum plate on the arriage is in its slot$ )#at voltage do you measure* and w#at does t#is
voltage represent* logic #ig# or low+
6$ Measure the voltage at the output "hen the sensor is unbloCed$ )#at voltage do you measure* and
w#at does t#is voltage represent* logic #ig# or low+
=$ )#at s#ould t#e voltages be in parts , and -+
'f you are satisfied that the photo-interrupter is "orCing orretly, go on$ 'f not, figure out "hat is "rong,
and fix it, or asC you lab instrutor for help$
Limit &witc#es
Move the printer arriage by hand, and maCe sure that eah of the t"o miros"ithes "ith the roller levers
at the far right and left limits of travel "ill be atuated "hen the aluminum JflagK on the arriage passes
beneath them$ Use the !MM to heC for ontinuity bet"een the /U*( and /U*, binding posts, first "ith
the roller levers from both s"ithes unpressed, then "ith eah s"ith, one at a time, "ith its roller lever
pressed$ Continuity should be broCen "hen either of the roller levers is pressed$ *hese s"ithes "ill be
used to ut the po"er to the motor if the arriage travels beyond the opto-s"ithes$ 8ote that it is very
important that any devie you design "ith moving omponents have some means to reliably prevent or deal
"ith over-travel$ /ver-travel protetion is important to avoid damage to the devie and ensure the safety of
others "orCing "ith or near the mahine "hile it is operating$
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
Page + of 9
Printer Carriage Motion Control Laboratory
Connecting t#e Optical &ensors to t#e %rduino
Connet the #rduino to the photo-refletive sensor and the opto-interrupter via the appropriate
6-"ay binding post, and write a short program that reads the state of each sensor and prints
the corresponding logic level to the serial monitor. Fou may use any input port and pins you
"ish 0exept for P!: and P!(, "hih are used for the .erial Monitor3$ ?erify that your program
orretly detets the hange of state of the s"ithes$ .ho" your lab instrutor that your program
funtions properly before going on$ .raw your own sc#ematic* and document w#ic# pins you
used $ Include t#is code and sc#ematics* and label it appropriately in your lab report.
/,L&0, 1e! Inverter
*he 95L.:5 is a logi 'C ontaining six independent inverters 0or NOT gates3$ 1igure 6 sho"s ho" the
hip is laid-out$ *he output of an inverter simply inverts 0reverses3 the logi level that is presented at its
input$ .o, if logi 2'72 is presented at the input, the output of the inverter "ill be logi L/D$
Figure -. /,L&0, pinout. *he 95L.:5 is a logi 'C ontaining six inverters, also alled 8/* gates$ *he
shemati symbol for a 8/* gate is a triangle "ith an open irle at the end$ 8ote that you must apply >6?
and ground for the 95L.:5 hip to funtion$
IMPO'2%32: !/ 8/* #..UM% any logi 'C hip is "orCing "hen you reeive it$ Fou MU.* test the
logi level on the pins you are "orCing from$ 1or example, observing 1igure 6, if you hose to "orC "ith
pin ( and pin , as your designated inverter, test them by applying
>6 ? to pin ( and verify that pin , is :?, then apply :? to pin ( and verify that pin , is >6?$ !onIt forget
that you need to apply >6? and ground to po"er the 95L.:5 for it to funtion$
8/*%: *he hex inverterIs funtion an also be done entirely by soft"are$ By using the bitwise-not
operator 0L3, you an also reverse the logi level presented at an input, and use it to set the state of an
output pin 0i$e$ P/4*B M LP'8#< "ill set all pins on output P/4*B to the inverted state of P/4*#Ns
inputs3$
4uad 1al"(1 .river
*he .89655(: 0or L,;+!3 is an 'C designed for driving moderate-urrent indutive loads, suh as motors
and solenoids, from logic level signals 0: ? or 6 ? in our ase3$ *he hip has four, half 2-bridges 0also
Cno"n as Hpush-pullI hannels, beause eah of the four output an either source 0HpushI3 or sink 0HpullI3
urrent3, and eah pair has an enabling input, and integral lamping 0flybaC3 diodes as sho"n in 1igure =$
%ah hannel an soure or sinC up to =:: m# ontinuous urrent$ # push-pull hannel onsists of t"o
transistors, a P8P and an 8P8, in "hih the olletors of the t"o transistors are onneted and their base
leads are ommon$ Dhen a logi-level signal is applied to the ommon base, one of the transistors "ill be
saturated 0full-on3 and the other utoff 0full-off3$ *his arrangement allo"s the hannel to either soure
0push3 or sinC 0pull3 urrent from the ommon olletor Guntion, hene the name Jpush-pullK$ 'f t"o
hannels are used, a !C motor an be driven bi-diretionally from a po"er supply of single polarity$
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
Page 5 of 9
1
2
3
4
5
6
7
14
13
12
11
10
9
8
74LS04
+5 V
Printer Carriage Motion Control Laboratory
Figure 5. &3/-,,10 6or L27$.8 connections. *he .89655(: is a four-hannel push-pull driver hip "ith integral
lamping diodes$ /nly t"o of the four hannels are sho"n$ *he hip needs >6 ? applied to pin (= to operate$ >?.
is the voltage of the supply used to drive the motor 0use >9 ? for ?s3$ Channels (and , "ill be enabled "hen logi
high 0>6 ?3 is applied to pin ( 0%nable (3$
/,L&0, and &3/-,,10 connection
Pin ( of the .89655(: is the enable input 0abbreviated %8(3 for hannels ( and , 0see 1igure =3$ Dhen
pin ( is taCen to logi high, the pair of push-pull hannels 0'8()/U*( and '8,)/U*,3 is JenabledK,
meaning that hannels ( and , are made operational$ *hus, if a logi high is applied to pin ( 0'n (3, then pin
+ 0/ut (3 "ill go HhighI 0to about ($5 ? lo"er than ?s3$ 'f a logi lo" is applied to pin , 0'n (3, then pin +
0/ut (3 "ill go Hlo"I 0to about ($, ? above ground3$ Dhen pin( 0%8(3 is taCen to logi lo", the t"o
hannels are JdisabledK, "hih means that their outputs are effetively disonneted from the iruit$
Connet the miroontroller to the 95L.:5 and the .89655(: as sho"n in 1igure 9 using #rduino pins of
your hoie$
.et the >,:? output terminal on the 2P po"er supply so that it "ill output 9/ : 0heC the voltage
B%1/4% you maCe the onnetion desribed next3$ Connet the tat s"ith to an input pin of the #rduino
using an appropriate Gumper$ )rite a s#ort program 6label it appropriately8 t#at loo;s "or t#e switc# to
be pressed* enables 31 o" t#e &3/-,,10* and toggles I3 1 and I3 2 continuously. Dith the !MM,
verify that the voltages measured at /U* ( and /U* , on the .89655(: alternate bet"een high 0>9?3
and lo" 0:?3 "hen the state "ritten to '8 ()'8 , toggles$
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
Page 6 of 9
+5 V
+V
S
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
Enable 1
In 1
Out 1
Out 2
In 2
+V
S
+V
S
SN754410
?
.
M>9? is used
to po"er the
motor$
Printer Carriage Motion Control Laboratory
Figure /. Connections to t#e %rduino* t#e /,L&0,* and t#e &3/-,,10 6or L27$8. 8ote that the onnetions for
>6 and ?s are not sho"n on the .89655(:, but need to be onneted$
Motor Connection
#ssuming that you have gotten all the piees to "orC so far, you are no" ready to interfae the printer
arriage motor, and get things movingO Connet the output of the optos"ithes to the #rduino if they are
not already onneted$ *he general layout of your system should looC liCe 1igure - belo"$
Figure <. Printer Carriage Motion Controller &ystem. *he arriage is driven bet"een limits set by the t"o opto-
s"ithes ontinuously after the program detets that the tat s"ith has losed$
Motor Connection
Drite a program that "ill drive the arriage baC and forth bet"een the opto-s"ithes "hen the tat s"ith
is pressed$ =e"ore you jump in and start coding* t#in; about t#e logic o" #ow you are going
accomplis# t#e tas;> )rite a "low c#art and develop t#e logic o" your code be"ore you try to move t#e
carriage. Use your experiene from previous labs to fashion your program, and do so by building and
testing piees of your ode, rather than trying to "rite the "hole program from start to finish in one shot$
I2 I& VERY IMPO'2%32 21%2 21 LIMI2 &)I2C1& F?3C2IO3
P'OP'L@. IF @O? .'I: 21 C%''I%A =@O3. 21 OP2O(&)I2C1&* M%B
&?' 21%2 21 LIMI2 &)I2C1& C?2 PO)' 2O 21 MO2O'. Ot#erwise* t#e motor*
belt* andCor carriage assembly may be damaged i" t#e carriage cras#es at t#e end o" t#e stro;e. )e
donDt want you to #ave to buy us new printer carriage i" your brea; yours>
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
A r d u
i n o /
A T m
e g a 3
2 8
IN 1
IN 2
EN 1
SN754410
1/6 of 74LS04
>6?
(: C
tact sw
OUT 2
OUT 1
A r d u
i n o /
A T m
e g a 3
2 8
IN 1
IN 2
EN 1
.89655(:
74LS04
>6?
(: C
OUT 1
OUT 2
motor
reflective opto
optointerrupter
Limit
SW 1
Limit
SW 2
tact
switch
>6?
/P*/ P/D%4
/P*/ 78!
>9?
>6?
D8
D9
D2
Page = of 9
Printer Carriage Motion Control Laboratory
1or more information on the .89655(:, see http:))fous$ti$om)dos)prod)folders)print)sn9655(:$html$
1or more information on the 95L.:5, looC at the data sheets on the *exas 'nstruments "eb site:
http:))"""$ti$om
@
.an AosB .tate University !epartment of Mehanial and #erospae %ngineering rev ($, (+M#4,:((
Page 9 of 9