B&B Electronics PPIO User Manual

Not Recommended for New Installations.
Please contact Technical Support for more information.
Parallel Port Input/Output Converter
Model PPIO
Document No. PPIO2899
B&B Electronics Mfg. Co. Inc.
Phone (815) 433-5100 -- General Fax (815) 433-5105
Home Page: www.bb-elec.com
Sales e-mail: orders@bb-elec.com -- Fax (815) 433-5109
Technical Support e-mail: support@bb.elec.com -- Fax (815) 433-5104
Copyright ? 1991-1999 B&B Electronics -- Revised June 1999
.PPIO2899 Manual Cover Page
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
TABLE OF CONTENTS
INTRODUCTION .............................................................................1
PACKING LIST.................................................................................2
PC PARALLEL PORT DESCRIPTION ...........................................3
PPIO DESCRIPTION & CONNECTION..........................................7
CONTROLLING THE PPIO USING GWBASIC..............................9
CONTROLLING THE PPIO USING PASCAL...............................12
CONTROLLING THE PPIO USING C...........................................18
INTERFACING TO THE PPIO.......................................................27
EXAMPLE USE OF THE PPIO .....................................................29
APPENDIX.....................................................................................33
HEXADECIMAL NUMBERS ..............................................................33
BINARY NUMBERS ........................................................................34
PPIO2899 Manual Table of Contents i
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
INTRODUCTION
The PPIO allows you to connect your IBM PC (or clone) computer to the outside world using the computer’s parallel port. The eight I/O points can be used as either inputs or outputs. As an output they can control voltages as high as 50 Volts DC and can handle currents as high as 500 mA DC. As an input they can handle voltages from 0 to 50 volts with a threshold of 2.5 Volts DC.
CAUTION: Each output of the PPIO can dissipate 1 Watt when used alone, however, all eight outputs together cannot dissipate more than 2.25 Watts.
NOTE: The PPIO connects to the parallel port of your computer and
uses most of the available pins on that port. You MUST use a cable that connects pins 1 through 17 of the DB-25 connector to the PPIO for it to work properly. To be safe you should use a cable that connects all 25 pins from connector to connector.
NOTE: The PPIO can only be used with parallel ports that are in “compatible” or “normal” mode. It will not function properly with parallel ports in ECP or EPP modes. The mode of the parallel port can be changed in the BIOS setup by pressing either the F2 key or DEL key just after the computer begins the boot procedure.
The PPIO comes with sample DOS programs written in GWBASIC, QuickBASIC, Pascal, and C. These sample programs can be used "as is" to test the PPIO and to control and display the status of its I/O pins. Parts of these programs can be used in other programs to make it easier to interface to the PPIO. Also, by studying these programs a programmer can learn how to write code in any language to do a similar job.
PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
1
Packing List
Examine the shipping carton and contents for physical damage. If there is damage, contact B&B Electronics immediately. The following items should be in the shipping carton:
1) PPIO unit
2) This Instruction Manual
3) PPIO Sample/Test Disk If any of the above items is missing contact B&B Electronics
immediately.
2 PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
PC PARALLEL PORT DESCRIPTION
To understand how the PPIO can be controlled you must first understand how the parallel port works inside the computer. The parallel port is designed to connect the computer with the outside world. It can have up to 12 TTL compatible outputs and up to 9 TTL compatible inputs. It cannot have both at the same time since some inputs and outputs share pins. Eight of the outputs and five of the inputs are dedicated. Four of the lines can be either inputs or outputs.
The main use for the parallel port is to send data to a printer. The port uses the eight dedicated outputs for data and the other lines for handshakes. Under normal printer operation, the computer will put an eight-bit byte on the eight lines (pins 2-9) and then use the Strobe output (pin 1) to tell the printer to read the data. Upon receipt of an Acknowledge (pin 10) from the printer the computer knows that the eight bit word was received. It can then send the next word. Other lines are used for busy, off line, etc.
All the control of the parallel port is done through software. If you look at the hardware you find that the parallel port is connected directly to the computer bus. This means that we can address these inputs and outputs in any way we want if we do not use the port to drive a printer.
Each PC has port addresses where the parallel ports, serial ports, hard disk, etc. can be addressed. These are located in the address range from 0000H to 03FFH (the H indicates the use of the hexadecimal numbering system). Each parallel port has one main port address for outputting data. The next two addresses above that address are used for handshaking control. For instance, on a typical computer a parallel port could be located at address 0378H. The handshaking lines will then be located at 0379H and 037AH. Table 1 shows the correspondence between the bits of the port and the pins of the DB-25 female connector.
Referring to Table 1, if you output a 01H (which is 00000001 in binary) to your computer’s port 0378H, then pin 2 of the parallel port’s DB-25 connector will be HIGH and pins 3 through 9 will be LOW. To do this using GWBASIC you would use the command: OUT &H378,&H01. Using this method you can output any pattern you wish on pins 2 through 9 of the parallel port. To turn ON pins 2, 4, 6, and 8 use: OUT &H378,&H55. 55H is the same as 01010101 binary. This port (0378H) can be read as an input, but mostly it is
PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
3
used to read the status of the port. The PPIO does not need to use this port as an input port.
Again, referring to Table 1, if you input the data on port 0379H, then whatever TTL level pins 15, 13, 12, 10, and 11 are will show up as bits 3 through 7. The state of bits 0, 1, and 2 will be unknown since they are not hooked to anything, but they probably will be HIGH (ONE). Note that the data on pin 11 will be inverted, if pin 11 is LOW you will get a HIGH on bit 7. The pins with the “bars” over them are all inverted. This is done by the hardware in the parallel port over which we have no control. A way to read these pins using GWBASIC is: A1=INP(&H379). A1 will then have the results of the input from port address 0379H. Bit 3 of A1 will have the status of pin 15, bit 4 the status of pin 13, etc.
Note that on the third address (037AH) the pins can be either inputs or outputs. If you use the GWBASIC command OUT &H37A,&H01 (00000001 BINARY) then pin 1 will be LOW (because it is inverted), pins 14 and 17 will be HIGH (they also are inverted), and pin 16 will be LOW (it is not inverted).
4 PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
378H 379H 37AH
BIT
Output Input Output Input Output Input
0 1 2
3 4 5
6
7
2 3 4
5 6 7
8
9
2 3 4
5 6 7
8
9
X X X
X X X
X
X
X X X
15 13
Note 2
12
10
_
11
_ 1 _
14 16
_
17
See
X
X
X
_ 1 _
14 16
_
17
See
Note 2
X
X
X
Table 1
Note 1: X means no connection to any DB-25 pin. Note 2: Bit 4 of 37AH as an output is used to control the interrupt IRQ7.
When this bit is HIGH, IRQ7 is enabled and when this bit is LOW, IRQ7 is disabled. As an input, this reads the status of the IRQ7 interrupt to see if it is enabled or not.
Note 3: The “bars” over the top of some pin numbers indicate that those signals are inverted (in hardware) from PC's bus to DB-25 pin.
You can also read pins 1, 14, 16, and 17 using the INP(&H37A) command. For this to work properly, you must first force all the outputs HIGH. The way the parallel port is wired, if you do not force the outputs HIGH they will interfere with the inputs. To do this, use the command OUT &H37A,&H04 (04H is the same as 00000100 binary). Pins 1, 14, and 17 are inverting so a ZERO written to them forces them HIGH. Pin 16 is non-inverting so the ONE written to it forces it HIGH. After issuing the OUT command you can then do a A2=INP(&H37A) that will read the TTL levels on those pins. In this case the four upper bits (bits 4-7) will be unknown, but will probably be HIGH.
PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
5
There are three port addresses that are normally used on a PC for parallel ports: 3BCH, 378H, and 278H. When your PC is reset or turned on these three addresses are scanned by the BIOS in the order shown above. The first one that the BIOS finds with a parallel port installed is assigned the logical name LPT1. The second, LPT2, etc. You can connect the PPIO to a port located at any of these three addresses. During power up the computer will assign that port a logical name but we will ignore it and communicate to the port directly.
If you are using a base address of 0278H the I/O port addresses in Table 1 would change to 0278H, 0279H, and 027AH. With a base address of 03BCH the addresses are 03BCH, 03BDH, and 03BEH. Check your computer manual to find out which address your parallel port has. It is also possible to purchase a special parallel port from B&B Electronics that can be set at any address in the I/O port address space from 0000H to 03FFH.
The above parallel port information is true for the vast majority of the PC compatible ports. However, a few computer manufacturers have chosen to make their parallel ports non-standard. On some battery powered computers pins are disabled to save power. Some ports may also have extra “direction control” bits. If you have problems where one or more bits are always on or off you should check your owner's manual. You may have to enable the port or set the “direction bit” correctly to get the port to work with the PPIO. If a pin is missing you may have to install a different parallel port card to get the PPIO to work properly.
6 PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
PPIO DESCRIPTION & CONNECTION
The PPIO makes use of the eight output pins (pins 2 through 9) at address 378H to drive its eight outputs. It uses the upper four bits of address 379H (pins 13, 12, 10, and 11) for the upper four input bits of the PPIO. It uses the lower four input bits of address 37AH (pins 1, 14, 16, and 17) for the lower four input bits of the PPIO. This assumes you are using the same port addresses as in Table 1. In this way the PPIO can have eight inputs or eight outputs. Refer to Figure 1 for the PPIO schematic.
Each pin of the PPIO is bi-directional. It can be used as either an input or an output. Referring to Figure 1 you will see that PPIO bit 0 can be driven by pin 2 of the parallel port or it can be read by pin 1 of the parallel port. The drivers are open collector Darlington transistors that can sink up to 500 mA and are protected by “kick back” diodes that are connected to the positive power supply. These outputs can handle voltages as high as 50 Volts DC. If bit 0 of port 0378H is HIGH, pin 2 of the parallel port is HIGH and the PPIO output pin will be LOW and can sink 500 ma. If bit 0 goes LOW, pin 2 will go LOW and the PPIO transistor will go OFF.
To use PPIO I/O bit 0 as an input you first set bit 0 of port 378H LOW to turn OFF the driver transistor. From then on, if you force the PPIO bit 0 to ground, a LOW will show up on pin 1 of the DB-25 connector. If you look at Table 1 you will note that pin 1 is inverting in the computer parallel port. This means that a LOW on pin 1 will show up as a HIGH in the computer. This is called negative true logic. The PPIO receivers are set up as inverters or non-inverters to compensate for the inverting and non-inverting inputs of the parallel port.
All you have to remember is that if you force one of the PPIO I/O bits to ground, it will be a ONE when you read it in the computer. If you leave the PPIO I/O pin open or force it HIGH (above 2.5 volts), it will be a ZERO when you read it in the computer.
PPIO I/O bits 0 through 3 are connected to bits 0 through 3 of port 037AH and PPIO I/O bits 4 through 7 are connected to bits 4 through 7 of port 0379H. (This assumes that you are using a parallel port at 0378H in your computer.) A LOW on any PPIO I/O pin will show up as a HIGH on the corresponding bit in the computer.
PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
7
Figure 1
8 PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
CONTROLLING THE PPIO USING GWBASIC
Refer to the fragment of GWBASIC code in Figure 2 to see how to input the bits and make one 8-bit word.
100 OUT &H37A,&H04: REM This disables the 37AH Outputs 120 REM inside of the computer 140 REM so that we can use 160 REM 37AH as an input port. 180 REM It also disables 200 REM the IRQ7 interrupt. . .
300 A1=INP(&H37A) AND &H0F: REM Input the 320 REM lower 4 bits 340 REM and mask OFF 360 REM (force to 0) 380 REM the upper 4 bits.
400 A2=INP(&H379) AND &HF0: REM Input the high 4 bits 420 REM and mask OFF 440 REM the lower 4 bits.
460 IB=A1 OR A2 : REM This combines them 480 REM into one Input Byte. . .
The above assumes that you are using a parallel port located at 0378H. If you are using a different port you will have to replace the hex addresses shown with the proper ones for your port. Refer also to the PPIO.BAS program on the supplied disk for an example of how to use GWBASIC to interface with the PPIO. To output bits from the computer to the PPIO interface (still using GWBASIC and the above 0378H example) use the following line:
500 OUT &H378,OB
Where OB is the byte you want to output. If, for instance, you want to turn ON (force LOW) PPIO bit 0, you must turn ON (force HIGH) bit 1 of the variable OB. This can be done by ORing OB with &H01. If you want to turn OFF (force HIGH or open) the same PPIO pin you must turn OFF (force LOW) bit 1 of OB. Do this by ANDing OB with NOT &H01. Use the data Table 2 to handle all eight PPIO bits.
Figure 2
PPIO2899 Manual
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104
9
Loading...
+ 23 hidden pages