background image

16 

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 

 
 

As with the function, In_Byte, the mask value is calculated by 

shifting 00000001b right the same number of times as the desired 
line number. Once the mask value is calculated, it is bitwise ANDed 
with Output_Byte. If the resulting value is non-zero, the line is ON 
and a boolean TRUE is returned, otherwise a boolean FALSE is 
returned. Notice that this function gets its value from Output_Byte 
that is set when we use the function, Set_Output_Bit. The value is 
not read from the port. 
 
For example: 
Line_Number = 3 
Output_Byte = 10101010b 
 
00000001b 
shift-right 3 (Line_Number) = 

 

00001000b 

 

 

 

 

 

 

  

AND  

10101010b (Output_Byte) 

 

 

 

 

 

 

 

 

  

00001000b 

 

 

 

The function, Set_Output_Bit, sets the selected output line ON of 

OFF. The function is defined as: 
 

PROCEDURE Set_Output_Bit ( Bit_Number,Output:BYTE ) ; 
BEGIN 
 

Output_Byte := ( (Output_Byte AND ( ( 1 SHL Bit_Number) 

 

 

XOR $FF) ) OR  (Output SHL Bit_Number) ) ; 

 

Port [Base_Address] : = Output_Byte; 

END; {Set_Output_Bit} 

 

 

 

The variable, Output_Byte, stores the status of the output lines. 

When a bit in Output_Byte is set to a one, its corresponding output 
line is ON, when it is set to a zero, the line is OFF. To set a bit to the 
specified status, the bit must first be cleared. To do this, 00000001b 
is shifted right for the desired line number and bitwise exclusive 
ORed with FFh (255 decimal, 11111111 binary) to produce a mask 
value. This mask value has all bits set to one except for the desired 
line. It is bitwise ANDed with Output_Byte to clear the desired bit. 
Now, having cleared the bit, it can be set to the specified state. 
Since the state is either a zero or one, we can shift it right for the 
desired line number to get another mask value. This value is then 
bitwise ORed with the cleared value to obtain the new value of 
Output_Byte. The final step is to write Output_Byte to the parallel 
port. 

Summary of Contents for Parallel Port Input/Output Converter PPIO

Page 1: ...B Electronics Mfg Co Inc 707 Dayton Road P O Box 1040 Ottawa IL 61350 USA 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 Technic...

Page 2: ...33 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 CONTROLLI...

Page 3: ...able 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...

Page 4: ...4 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 Th...

Page 5: ...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 w...

Page 6: ...t 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 ha...

Page 7: ...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...

Page 8: ...H 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 spe...

Page 9: ...t 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...

Page 10: ...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 Figure 1...

Page 11: ...REM This combines them 480 REM into one Input Byte Figure 2 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 ad...

Page 12: ...OFF without disturbing any of the other PPIO Bits You may also use the PPIO with some pins as inputs and some pins as outputs There can be any number of each and in any order Remember that before you...

Page 13: ...ome back the same when you input A good way to test for shorts is by outputting a HAA 10101010 binary and checking to see that the input is the same Then output a H55 01010101 binary and check the inp...

Page 14: ...Register Address Control_Address WORD Control Register Address No function outside the Unit can directly access these variables Functions outside the Unit call functions within the Unit to modify and...

Page 15: ...l port The function Read_Input_Bit reads the port The function Out_Byte returns the value of the variable Output_Byte It is defined as FUNCTION Out_Byte Byte BEGIN Out_Byte Output_Byte End Out_Byte No...

Page 16: ...twise AND it with 0Fh 15 decimal 00001111 binary This sets the upper nibble of the byte to zero Now combine both bytes into one value by bitwise ORing them together This value is stored in the variabl...

Page 17: ...twise ANDed with Input_Byte If the resulting value is non zero the line is ON and a boolean TRUE is returned otherwise a boolean FALSE is returned For example Line_Number 3 Status Register Value 01010...

Page 18: ..._Output_Bit Bit_Number Output BYTE BEGIN Output_Byte Output_Byte AND 1 SHL Bit_Number XOR FF OR Output SHL Bit_Number Port Base_Address Output_Byte END Set_Output_Bit The variable Output_Byte stores t...

Page 19: ...te 01010101b Line_Number 3 Status 1 00000001b 1 decimal shift right 3 Line_Number 00001000b XOR 11111111b 11110111b mask 1 AND 01010101b Output_Byte 00000001b Status 01010101b shift right 3 Line_Numbe...

Page 20: ...Base_Address 1 define Control_Address Base_Address 2 typedef enum false 0 true 1 boolean The module PPIOFUNC C handles communication with the parallel port It defines three variables that all functio...

Page 21: ...int In_Byte void return Input_Byte Notice that this does not read the value of the parallel port The function Read_Input_Bit reads the port The function Out_Byte returns the value of the variable Outp...

Page 22: ...twise AND it with 0Fh 15 decimal 00001111 binary This sets the upper nibble of the byte to zero Now combine both bytes into one value by bitwise ORing them together This value is stored in the variabl...

Page 23: ...gister Value 10101010b 01010101b Status Register AND 11110000b F0h mask 01010000b 10101010b Control Register AND 00001111b 0Fh mask 00001010b OR 00001010b 01011010b 00000001b 1 decimal shift right 3 L...

Page 24: ...is set to a one its corresponding output line is ON when it is set to a zero the line is OFF To set a bit to the specified status the bit must first be cleared To do this 00000001b is shifted right f...

Page 25: ...ggle the status of an output line If the specified line is ON it will be turned OFF If it is OFF it will be turned ON The function is defined as void Toggle unsigned char Line_Number Output_Byte Outpu...

Page 26: ...status 0x00 Store the state of the digital outputs old_value inp Base_Address Check upper four digital outputs Output_Byte 0xA0 outp Base_Address Output_Byte Input_Byte inp Status_Address 0xF0 if Inp...

Page 27: ...four digital outputs and verifies that the digital outputs are in set properly The lower four digital outputs are checked in a similar manner with the values 0Ah and 05h NOTE If the PPIO is connected...

Page 28: ...se if you use a 24 volt relay you will need a 24 volt power supply The PPIO will control devices up to a maximum of 50 volts DC Figure 3 Each input of the PPIO works with voltages up to 50 volts DC wi...

Page 29: ...28 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 Figure 4...

Page 30: ...ill have the dissipation of that PPIO I O pin For example if you measure 1 65 volts and your relay draws 100 mA then 1 65 0 1 equals 0 165 watts If you add up all of the PPIO loads THAT CAN ALL BE ON...

Page 31: ...Heat and the Air See line 230 If IB is equal to two then the 72 degree thermostat is on and the 78 degree one is off At this time we want both the Heat and the Air off See line 260 If IB is equal to 3...

Page 32: ...ITS HIGH OFF 150 REM TO TURN EVERYTHING ELSE OFF 160 A1 INP H37A AND HF 170 A2 INP H379 AND HF0 180 IB A1 OR A2 190 IB IB AND H3 REM ONLY LEAVE THE TWO 200 REM THERMOSTAT CONTACTS 210 IF IB 0 THEN OB...

Page 33: ...end of it to indicate that it is a hexadecimal number Table 4 can be used to convert a number between 0 and 255 into its hexadecimal representation Let us use 90 as an example Find 90 in the middle o...

Page 34: ...igit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 2 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 3 48 49 50 51 52...

Reviews: