You are on page 1of 11

Copyright© 1998 Robert Woudsma

,

UPPER CANADA TECHN ! "#E$

1

5. ?hen choosing a parallel port or 'ulti-"unction I/O card) ensure that the speci"ication "or the printer port is stated as %eing either E## "or Enhanced #arallel #ort or E7# "or E&tended 7apa%ilities #ort. 2e& or .-%it input port and the /-%it output control port. In project #$ we added digital input and output capa%ility to the printer port. !ote: *o'e o" the in"or'ation presented %elow is a repeat o" project #$.Reading & Writing through the Enhanced Parallel Port (EPP) Part A: Building and Testing the Interface This project has two parts.. The Parallel Printer Port "ard#are The original speci"ication "or the L#T port allows "or only data "low in one direction) "ro' the co'puter to the printer. The $i%directional Printer Port (lthough the original printer port speci"ication <called *## "or *tandard #arallel #ort= did not allow "or reading . ec. UPPER CANADA TECHN ! "#E$ % .. • +eside the data output port there is a "ive %it *T(T3* input port through which the co'puter could get status in"or'ation "ro' the printer such as paper out) or %usy or printer online etc. the . These %its can %e controlled %y writing to the least signi"icant / %its o" the L#T1 %ase I/O address 4$) usually 0.-%it data through the data port) this capa%ility %egan appearing with I+>!s #*-$ line o" co'puter syste's. 'ost signi"icant %its "ro' the L#T1 %ase I/O address 41) usually 015 he& or . • 6inally there is a "our %it 7O8T9OL port that is used to control various "unctions o" the printer such as initiali:ing) line"eed) etc. (ttached is a circuit diagra' o" a si'ple L#T port inter"ace that provides "or eight %its o" digital input) eight %its o" digital output) an eight %it digital to analog converter and an eight %it analog to digital converter. It is repeated here "or those who have skipped project #$. Either o" these two speci"ications allow "or Copyright© 1998 Robert Woudsma. he& or . On the other hand) 'any 'ulti"unction I/O cards that you can %uy today to plug into your co'puters 'other%oard 'ay still only contain the *## parallel port speci"ication.-%it output data port) the . • The (T( port contains eight %its o" data that are accessi%le %y writing to the L#T 1 port %ase I/O address) usually 01..5 ec.. constructing the Input/Output circuit and writing the test routine. +ut the printer port is actually 'ade up o" three sections. These %its are read %y reading the . In this circuit we will e&pand the inter"ace capa%ility to include %oth writing to and reading "ro' analog devices. >ost co'puter syste's today that are sold with the serial and printer ports integrated into the 'other%oard contain %i-directional parallel ports. ec. The Simple PT Interface In project #1 we looked at directly driving eight LE !s with the eight digital outputs o" the L#T port.

I" it is a *## though) it will not work with this circuit.igure /: Printer Port Properties Page • I" the description suggests the printer port is an E## or E7# type then it will work with the circuit we will %e %uilding here.%i-directional data "low.escription The *i'ple #rinter #ort Inter"ace 7ircuit The circuit "or a si'ple L#T inter"ace is shown on an attached page. The listing 'ay already state that the L#T port is an *##) E## or E7# type. In order to know i" your co'puter has an E## or E7# parallel port installed on it "ollow the procedure outlined %elow. . • • • • 6ro' the @&' (omputerA icon or "ro' the ?indows 5. It contains the "ollowing sectionsD Copyright© 1998 Robert Woudsma.e-ice &anager ta% is selected. UPPER CANADA TECHN ! "#E$ & . Bou then have two options. The list should contain at least one L#T port and one or 'ore 7O> ports. *econdly you can download the Interface (ircuit . or less. ( @#rinter #ort #ropertiesA screen will %e displayed as shown %elow. 6irstly) you can purchase a E## or E7# printer port %oard and add it to your co'puter at a cost o" C0. ou%le-click on this ite' to e&pand the listing. @StartA %utton and Settings selection) select ()!TR) PA!E * 6ro' the 7ontrol #anel select S+STE&* 6ro' the syste' properties dialog %o& 'ake sure that the . ('ong the devices that are listed under evice >anager there should %e an ite' called P)RTS (()& & PT). I" not) dou%le-click on the L#T ite' in the list.

-%it corresponding output to the printer port. #roto-%oards are arranged to accept integrated circuit chips and electronic co'ponents and allows the interconnection o" the co'ponents to "or' co'plete circuits. Initially) the analog input will %e connected to a 1. volts.-%it digital input port which will %e connected to .1/ octal Latch to provide an .F to ..igure 01: . switches or any devices that you wish to read digital in"or'ation "ro'. to ..-%it digital output port which will %e used to light . volts and provide an . The . These control %its will %e 'anipulated %y Gisual +asic to latch data to %e written out o" the inter"ace or to read data "ro' the digital or analog inputs to the co'puter. . ( 1/L*$/. data lines o" the L#T port now "or' a data %us) which at ti'es will contain data to %e read %y the co'puter and at other ti'es will carry the data to %e delivered "ro' the co'puter to the digital or analog output. (n (nalog evices ( . is uniEue in that it has an on-%oard . ( 8ational *e'iconductor ( 7..../ ..-%it analog to digital converter that will read an analog input "ro' .F potentio'eter that is connected %etween 4. #roto-%oards can %e interlocked together to "or' as large a proto-typing area as you wish ( diagra' o" a typical proto%oard section is shown in "igure #$) %elow. .. octal %i-directional latch to provide an ....• • • • ( 1/(L*. (onstructing the Interface The initial construction o" the inter"ace should %e done on electronic proto-typing %oards or @proto-%oardsA..iagram of a single proto%$oard section Copyright© 1998 Robert Woudsma. LE s or any device that you wish to send digital signals to. Each I7 will %e controlled %y one o" the %its o" the 7O8T9OL section o" the L#T port. The ( .-%it latch that we will use to hold the data that is delivered to it "ro' the printer port.volts and ground to provide an analog input signal. UPPER CANADA TECHN ! "#E$ ' .-%it digital to analog converter to provide an analog output ranging "ro' . to $.

v "or this circuit.. 3se the circuit shown to %uild the co'plete printer port inter"ace. I" it does not) then touching this connection to ground 'o'entarily will trigger the circuit./ pins #0 and #. (n alternate arrange'ent is to use a 1v 7 or higher wall adapter and connect it into the circuit as you would the %attery. voltage regulator.. Copyright© 1998 Robert Woudsma. Take the ti'e to lay out a neat circuit... The layout o" the parts should occupy 0 proto-%oards) one "or the I#-$/ connector "ro' the L#T port ca%le) one to hold all "our I7!s in a row as illustrated in the circuit diagra' and a "inal one to contain the . The 1... to ground is usually le"t open. The circuit is powered %y a single .. regulator can regulate any supply voltage "ro' 1 to $.-%it I# switch) the . 3se a digital or analog volt'eter to check the output voltage "ro' the ( .. LE s and the potentio'eter. volt supply which can %e constructed using a 5volt %attery and the 1.v 7 down to the reEuired . This will always 'ake trou%le-shooting easier i" it is necessary later. UPPER CANADA TECHN ! "#E$ ( .. Po#er Suppl' This second project needs an e&ternal power supply to operate. 8or'ally this circuit will trigger and %egin per"or'ing "ree-running (/ conversions at power-up.The reEuired I7s and various other parts "or the inter"ace are shown n the sche'atic diagra' o" "igure0 %elow. 8oteD The ju'per wire "ro' the ( 7. Test the Interface ("ter the circuit is constructed test it!s operation %y running the Gisual +asic progra'D read2#rite2test*e3e* This test progra' will veri"y the operation o" the digital output port on the LE s) the digital input port through the I# switches) the analog input through the use o" the potentio'eter and the analog output port.

. UPPER CANADA TECHN ! "#E$ ) .igure 04: Simple Printer Port Interface (ircuit Copyright© 1998 Robert Woudsma.

The operation o" these progra's uses so'e new capa%ilities that you can use to create your own progra's to operate the inter"ace..ispla' Trend/ .igure 07: Trendfile .igure 05: Test .igure 06: . UPPER CANADA TECHN ! "#E$ * . .ispla' Copyright© 1998 Robert Woudsma..ispla' . to allow you to test your inter"ace circuit. The e&e) "or' and project "iles "or read2#rite2test) trend/ and trendfile have %een included so that you can study the' to see how these new capa%ilities have %een i'ple'ented.Part B: Programming the Interface Programming for the PT Interface Three progra's have %een included in the project "ile in Gisual +asic .

Copyright© 1998 Robert Woudsma. UPPER CANADA TECHN ! "#E$ 8 .

• 7ontrol o" the data %us One and only one device 'ay place data on the data %us at a ti'e.. It %eco'es the jo% o" the progra' to 'ake sure that only one o" the inter"ace sections will have access to the data %us at a ti'e in order to read data "ro' or to place data onto the %us./ does not react to the digital value that is placed on the data %us. I" we wish to send digital or analog signals out o" the co'puter) the co'puter will have control o" the data %us. UPPER CANADA TECHN ! "#E$ 9 .. Trend/ only reads data "ro' the analog input section and displays the analog value as a @B verses ti'eA graph on a trend display. Trendfile o""ers a nu'%er o" desira%le enhance'ents to the trend1 progra' including user selecta%le %ackground and graph pen colour) saving a trend graph to a "ile as (*7II data) redisplaying a previously saved trend graph "ile and selecta%le trend speeds.Read2#rite2test is a si'ple progra' that allows each "unction o" the circuit to %e tested.) 71) 7$ and 70 which are connected to L#T pins 1) 1/) 1H and 11 respectively. reading and writing %oth digital and analog data. In this project we need to control "our %its o" the control register. • *electing Input or Output devices *uppose we wish to output a digital value to the LE s and so we there"ore cause the co'puter to place a digital value onto the data %us. ?e want the digital output latch) the 1/. Copyright© 1998 Robert Woudsma. In short) we need to have control in our hardware and our so"tware to %e a%le to deter'ine what each section o" the inter"ace will do and when it is allowed to do it. <dec= or 01. I" we wish to read digital or analog in"or'ation into the co'puter) the digital input I7 or the analog to digital converter will have control o" the data %us.. (ontrolling the (ontrol Register In project #1 we took direct control o" the L#T port data lines %y writing values to the L#T port I/O address.. This will allow the device to either latch the data on the data %us i" it is an output device or to place data onto the data %us i" it is an input device. (ontrolling the Interface Sections 3sing 'ultiple devices all connected to a co''on data %us raises so'e design and progra''ing issues. ?e 'ust ensure that the digital to analog converter) the ( 7. 6or 'ost syste's with a single printer port) designated as L#T-1 this would %e at address . The hardware control is achieved through the use o" "our control lines "ro' the L#T port. In project #$ we use the single 7.1/ to then react to the data on the %us and deliver it to the LE s. These lines are 7. Each ti'e we wish to cause a value to %e read or written to a device in our inter"ace we 'ust change the state o" it!s control line. control register %it which in turn controlled the logic level o" the printer port pin #1.

UPPER CANADA TECHN ! "#E$ 1+ . This 'eans that when a @1A is written to that %it %y the progra') the logic level at the respective pin at the L#T port is @. Look at the code "or the Option %uttons in the read2#rite2test progra' "or ideas on how this is done.. I" there was a second printer port. Only 7$) the third %it at pin #1H) which controls the ( . In this way you will %e a%le to set the value o" the @+aseA varia%le to .. (s we have seen %e"ore) each L#T port has at least 0 sections.<he&=. Each section has it!s own register) or I/O address. • • • The data register is at the %ase address o" the L#T port The *tatus register is at the %ase address 41 o" the L#T port The 7ontrol register is at the %ase address4$ o" the L#T port The ta%le %elow illustrates this arrange'entD PT%/ Base address 8 .9h Base < / 8 Status register 8 99=d:4. 8otice that control lines 7.=h Base < 1 8 (ontrol register 8 745d:1...Ah PT%1 Base address 8 .A. +ut your progra' 'ay %e used on a co'puter that has the inter"ace connected to either L#T-1 or L#T-$. <he&=. Allo#ing for PT%/ or PT%1 I" there is only one L#T port on a co'puter then we could speci"y it!s data and control register directly %y using the appropriate address value.. to read the data %us and deliver a corresponding analog output.=h Base < 1 8 (ontrol register 8 9=>d:4.Ah In order to control the %its o" the control register we 'ust write to the %ase address 4 $ o" the L#T port we are connected through. digital to analog converter is positive logic. "or L#T-1 or set it to H$0 "or L#T-$. L#T-$ it!s address would %e H0$ <dec= or $1.) 71 and 70 are inverted logic.ata register 8 999d:4. Copyright© 1998 Robert Woudsma.9h Base < / 8 Status register 8 744d:1. (ode E3ample The code listing "or the read2#rite2test) on the "ollowing page shows how the so"tware 'anipulates the control lines o" the inter"ace %y writing various data values to the control register "or each read or write operation. Instead o" speci"ying the data and control registers using their address) use a varia%le such as @+aseA. It 'ust %e kept high 'ost o" the ti'e until it is %rought low to trigger the ( ..ata register 8 741d:1. Bour progra' 'ust have a si'ple way o" %eing a%le to de"ine which L#T port the inter"ace is connected to.

%it 0 high "or analog output #ort.5156 #rivate *u% c'dreadI7lick<= Jplace si&th %it o" control port to 1 to allow 9E( 'ode Jkeep 0rd %it at a high to prevent analog output to respond Jand "irst %it to high to cause 7.(ddress K %ase 4 $ #ort.Te&t= N $.(ddress K %ase 4 $ #ort.Galue K / Jnow send the t&toutvalue to the data port #ort. Then >sg+o& OIllegal value entered PPO) v%E&cla'ation) O 9eally +ig E99O9O t&toutvalue.(ddress K %ase 4 $ #ort. to a low to allow a write L%ut keep 7$.Galue K 0H J show the value that was read in the te&t %o& t&tinvalue K inval End *u% Read an analog -alue through the A.(ddress K %ase inval K #ort.Galue K H #ort. Jnow send the t&toutvalue to the data port #ort.56.(ddress K %ase 4 $ #ort. to a low to allow a write L %ut keep 7$.Galue K ./ to read.5 #rivate *u% t&toutvalueIFey#ress<Fey(scii (s Integer= Jonly respond i" the E8TE9 has %een pressed I" Fey(scii K 10 Then J"irst check "or a valid value enteredD I" Gal<t&toutvalue. to read. #ort.Galue K / #ort.Galue Jnow disa%le the read o" the 1/$/.Te&t K OO Else Jset control port %it . %it 0 high "or analog output #ort. to low and causing pin #1 to go high L %ut keep 7$. %y setting the control Jport "irst %it) 7. %it 0 to a low to allow a write "ro' the analog output #ort. Then >sg+o& OIllegal value entered PPO) v%E&cla'ation) O 9eally +ig E99O9O t&toutvalue.Galue K 0H J show the value that was read in the analog in te&t %o& t&tain K inval End *u% Write a digital -alue through the ...Galue K Gal<t&toutvalue= Jnow %ring control port %it $ to high and low to %ring pin #1/ Jlow then high to latch the data to itJs output.Te&t= N $..(ddress K %ase inval K #ort.Galue K / End I" End I" End *u% Write an analog -alue through the A. End I" End I" End *u% Copyright© 1998 Robert Woudsma. #ort.Te&t= M .Galue K Gal<t&taout= Jnow %ring control port %it 0 to high and low to %ring pin #1H Jlow then high to latch the data to itJs output.. %it 0 high to prevent Janalog output "ro' writing #ort.Galue K // Jnow read the data at the L#T port ata pins #ort.(ddress K %ase 4 $ #ort. UPPER CANADA TECHN ! "#E$ 11 ...Galue Jnow disa%le the read o" the ( 7.(ddress K %ase 4 $ #ort.(ddress K %ase #ort.Galue K 01 Jnow read the data at the L#T port ata pins #ort.Te&t K OO Else Jset control port %it . #ort.669 #rivate *u% t&taoutIFey#ress<Fey(scii (s Integer= Jonly respond i" the E8TE9 has %een pressed I" Fey(scii K 10 Then J"irst check "or a valid value enteredD I" Gal<t&toutvalue. #ort.Te&t= M .(ddress K %ase 4 $ #ort. at pin 1 to go low J<inverted logic= to 7ontrol the 1/$/.(ddress K %ase #ort./ %y setting the control Jport "ourth 70 to low and causing pin #11 to go high J%ut keep 7$. Or Gal<t&toutvalue. Or Gal<t&toutvalue.(>9>5 #rivate *u% c'dreadanalogI7lick<= Jplace si&th %it o" control port to 1 to allow 9E( 'ode Jkeep third %it high to prevent analog output "ro' responding Jand "ourth %it to high to cause 70 at pin 11 to go low J<inverted logic= to 7ontrol the ( 7.(ddress K %ase 4 $ #ort.7ode listings "or igital and (nalog read and write Read a digital -alue from the .Galue K .