LPT PRINTER PARALLEL PORT part-2


5. CHANGE OLD LPT CARD
 
As our discussion before, old LPT card can not support bi-directional data transfer. Why this option can not support? Because, in the beginning the LPT port only design for printing purpose (only for sending data, it is not necessary to read the data back). How if we want to connect device that want to transfer data to computer? It is the problem. Notice that this is not implied to the new card design. Because many new card can be reprogramming (have chip set) to work in SPP, ECP or EPP mode. Any who knows about this specification? please inform me. Besides that many LPT's card can work to operated as bi-directional port.
In the old card, data lines (DP) passed a tri-state buffer (LS245 IC) and latch by LS374 IC. This latch IC has output enable pin grounded (see Figure-6).

click the image for zooming 




That means that data which is sending to it allways keep (latch by the 74LS374 IC). So any other data input from the outside allways read wired-OR with this kept data by the computer or wrong data (in fact that some people used this trick(by sending FF Hex to the output and ORed the data) for many-many years and it works!). We must make this data line to be tri-state in other word, we must make the output enable pin of LS374 IC can be high. Figure-7. show the necessary modification that we must do. Notice that the selection of pin 25 is by your choise only. To make it easy set to pin 25. You can choose from any other pins that not in used in the range18~25. Resistor 4.7 kOhm is used to keep the function of LPT so the normally operation still be working. But now we can disable the latch output if we make pin 25 high, data can be read to computer. Any extra care must be taken to free the output enable pin of LS374 IC. Don't damage it!




After everythings was done, LPT adapter now can be used as input data port. Remember to set pin 25 connector high went you sent data to computer and vice versa. Note that, this option could be done from external device.
Another way to make the card to be bi-directional port is like this (this way could be controlled from software/inside, like the standard bi-directional card), cut off pin 1 of the 74LS374 IC or the track layout from the ground and connect to the only one of the output of the 74LS174 spare (maybe pin 15th/6Q) by some wire. This spare latch is connected to the related bit PC-5 (direction bit). So, if this bit low, after the reset period, the direction also low, the DP port act as output port.

6. CHECKING LPT ADAPTER
 

How do we check an LPT adapter was installed in a computer? It is a quiet simple matter. In a new card (bidirectional card), simple send a byte to DP port and then read back again. If the result was not an FF Hex or if the result exactly the same to the byte wrote, then the card is installed at that port. This happend because, if the card not installed, the accessing port is a tri-state all, there is no connection to the hardware logic. Tri-state logic interpreted as logic 1. For the old card and also the new one, accessing the PC port is quiet the same thing to the above matter. But if a device was connected to this port, a read back byte may not be the same as to the write byte, because the upper 3 bits are not used interpreted as logic 1 all. Here is the examples to access this port in several languages :
 
In PASCAL routine : 
CONST
     LPT_Port = $3BC;
     Byte_R_W = $44;
     There_is : BOOLEAN = FALSE;

PROCEDURE Check_LPT;
BEGIN
     PORT[LPT_Port] := Byte_R_W;                               { Dummy Data }
     IF (PORT[LPT_Port] = Byte_R_W) THEN There_is := TRUE;     { this statement checking LPT Port }
     IF (PORT[LPT_Port] <> $FF) THEN There_is := TRUE;         { or this statement }
END;
In ASSEMBLY routine : 
LPT_Port EQU 3BC H
Byte_R_W EQU 44 H
True     EQU 1  H
False    EQU -1 H
There_is DB  ?

Check_LPT PROC NEAR
          MOV  AX,LPT_Port
          MOV  DX,AX
          MOV  AL,Byte_R_W              ;Dummy Data
          OUT  DX,AL
          IN   AL,DX
          CMP  AL,Byte_R_W
          JE   It_is                    ;This statement checking LPT Port
          CMP  AL,0FFH
          JNE  It_Is                    ;or this statement
It_is_not:MOV  There_Is,False
          RET
It_Is:    MOV  There_is,True
          RET
Check_LPT ENDP
In BASIC routine : 
PROC Check_LPT
     LPT_Port = &H3BC:Byte_R_W = &H44:There_is = FALSE
     OUT LPT_Port,Byte_R_W
     IF (INP(LPT_Port) = Byte_R_W) THEN There_is = TRUE          :REM ----- This statement checking LPT Port
     ELSE IF (INP(LPT_Port) <> &HFF) THEN There_is = TRUE        :REM ----- or this statement
END PROC
In C routine : 
#define 0 false
#define 1 true
#define There_Is false

void Check_LPT()
{
     int LPT_Port = 0x3BC;
     unsigned Byte_R_W = 0x44;

     outp(LPT_Port) = Byte_R_W;
     if (inp(LPT_Port) == Byte_R_W)
     {
           There_is = true           /* This statement checking LPT Port */
     }
     else if (inp(LPT_Port) <> 0xFF)
     {
           There_is = true;          /* or this statement */
     }
}
Another technique to detect a presence of the card is to access BIOS RAM data segment. This address locate at 0000:0408 hex or the interleave location like 0040:0008 hex (I prefered the last one). the location saved LPT port addresses in 1 word length each. Because the way of Intel system to store of data, these LPT port were wrote as a pair of Hi-Byte and then Lo-Byte like below :
 


0040:0008

0040:0009

0040:0000A

0040:000B

0040:000C

0040:000D

78

03

78

02

00

00

First LPT

Second LPT

Third LPT
If the content is zero, it sign that there is no more LPT. If all locations are zero then there are no LPTs installed at that computer. So it is more easy to detect a computer if it has LPTs or not. Several programming are listed below :
 
In PASCAL routine : 
CONST
     Seg_LPT = $40;
     Ofs_LPT = $8;
     There_is : BOOLEAN = FALSE;
     LPT_Is : ARRAY[1..3] of STRING = ('First','Second','Third');

VAR
   No_LPT : BYTE;

PROCEDURE Check_LPT;
BEGIN
     FOR No_LPT := 0 TO 2 DO
     BEGIN
          IF (MEMW[Seg_LPT,(Ofs_LPT+No_LPT*2)] <> 0) THEN     { this statement checking LPT Port}
          BEGIN
               There_is := TRUE;
               WRITE(LPT_Is[No_LPT],' LPT port found !');WRITELN;
          END;
     END;
     IF NOT There_Is THEN WRITELN('There is no LPT adapter installed !');
END;
In ASSEMBLY routine : 
Seg_LPT   EQU  40 H
Ofs_LPT   EQU  08 H
True      EQU  1  H
False     EQU  -1 H
There_is  DB   False
LPT_Is    LABEL BYTE
          DB   'First$ '
Len_Str   EQU  $-LPT_Is
          DB   'Second$'
          DB   'Third$ '
Lpt_Found DB   ' LPT port found !',13,10,'$'
No_LPT    DB   'There is no LPT adapter installed !',13,10,'$'

Check_LPT PROC NEAR
          MOV  CX,3
          MOV  AX,Seg_LPT
          MOV  ES,AX
          MOV  BX,Ofs_LPT
Lop_LPT:  MOV  AX,WORD PTR ES:[BX]
          CMP  AX,0                     ;This statement checking LPT Port
          JZ   Next_LPT
          MOV  There_Is,True
          MOV  AX,Len_Str
          MUL  CL
          MOV  DX,AX
          ADD  DX,OFFSET Lpt_Is
          MOV  AH,09H
          INT  21H
          LEA  DX,LPT_Found
          MOV  AH,09H
          INT  21H
Next_LPT: INC  BX
          INC  BX
          LOOP Lop_LPT
          CMP  There_Is,False
          JNE  End_Check_LPT
          LEA  DX,No_LPT
          MOV  AH,09H
          INT  21H
End_Check_LPT:
          RET
Check_LPT ENDP
In BASIC routine : 
PROC Check_LPT
     Seg_LPT = &H0040:Ofs_LPT = &H0008:There_is = FALSE
     DIM LPT_Is$(2):FOR I=0 TO 2:READ LPT_Is$(I)
     DATA "First","Second","Third"
     FOR Count = 0 TO 2
         DEFSEG = Seg_LPT                       :REM ----- This statement checking LPT Port
         IF (PEEK(Ofs_LPT+Count) <> 0) THEN
            There_is = TRUE:DEFSEG=:PRINT LPT_Is(Count);" LPT port found !":PRINT
         END IF
     IF (There_Is = FALSE) THEN "There is no LPT adapter installed !":PRINT
     END IF
END PROC
In C routine : 
#include 
#include 

#define 0 false
#define 1 true
#define There_Is false

void Check_LPT()
{
     int No_LPT;
     unsigned LPT_Addr[3];
     char *LPT_Is[3] [6] = {"First","Second","Third"};

     for (No_LPT=1;No_LPT<4;No_LPT++)
     {
          LPT_Addr[No_LPT]=*(unsigned far *)(MK_FP(0x40, 0x008+(No_LPT*2)));
          if (LPT_Addr[No_LPT])             /* This statement checking LPT Port */
          {
               There_is = true;
               printf("%s LPT port found !\n",LPT_Is[No_LPT][6]);
          }
          if (! There_Is)
          {
               printf("There is no LPT adapter installed !\n");
          }
     }
}

7. CHECKING BI-DIRECTIONAL PORT
 
How to convince that my own LPT adapter card is bi-directional or not ?
The bi-directional card used bit PC-5 to control the direction of data in DP port. If the PC-5 bit is low, the DP port act as output port and if it is high, the DP port is used for input port.
What's going on of these bits of DP port ?
When the DP port act as output port, the data is latch at the output, so if we read this data back from the DP port, the data must always the same as that we send. But if DP port act as input port, the read data must be FF Hex, because the latch of DP port is in tri-state.
By this situation, we can check the LPT port rather it's a bi-directional port or not, by sending a byte (output a byte, not an FF Hex) to DP port, activating PC-5 direction control, and read the DP port back again and compare the result with the byte sender. If the data match (read data = a byte sender), the LPT port is not a bi-directional, and if the data is not match (read data = FF Hex), the LPT port is a bi-directional port. Okay... try your LPT port now !
I had compiled the checker in pascal program and in assembly program.

No comments:

Post a Comment

Labels

PROJECTS 8086 PIN CONFIGURATION 80X86 PROCESSORS TRANSDUCERS 8086 – ARCHITECTURE Hall-Effect Transducers INTEL 8085 OPTICAL MATERIALS BIPOLAR TRANSISTORS INTEL 8255 Optoelectronic Devices Thermistors thevenin's theorem MAXIMUM MODE CONFIGURATION OF 8086 SYSTEM ASSEMBLY LANGUAGE PROGRAMME OF 80X86 PROCESSORS POWER PLANT ENGINEERING PRIME MOVERS 8279 with 8085 MINIMUM MODE CONFIGURATION OF 8086 SYSTEM MISCELLANEOUS DEVICES MODERN ENGINEERING MATERIALS 8085 Processor- Q and A-1 BASIC CONCEPTS OF FLUID MECHANICS OSCILLATORS 8085 Processor- Q and A-2 Features of 8086 PUMPS AND TURBINES 8031/8051 MICROCONTROLLER Chemfet Transducers DIODES FIRST LAW OF THERMODYNAMICS METHOD OF STATEMENTS 8279 with 8086 HIGH VOLTAGE ENGINEERING OVERVOLATGES AND INSULATION COORDINATION Thermocouples 8251A to 8086 ARCHITECTURE OF 8031/8051 Angle-Beam Transducers DATA TRANSFER INSTRUCTIONS IN 8051/8031 INSTRUCTION SET FOR 8051/8031 INTEL 8279 KEYBOARD AND DISPLAY INTERFACES USING 8279 LOGICAL INSTRUCTIONS FOR 8051/8031 Photonic Transducers TECHNOLOGICAL TIPS THREE POINT STARTER 8257 with 8085 ARITHMETIC INSTRUCTIONS IN 8051/8031 LIGHTNING PHENOMENA Photoelectric Detectors Physical Strain Gage Transducers 8259 PROCESSOR APPLICATIONS OF HALL EFFECT BRANCHING INSTRUCTIONS FOR 8051/8031 CPU OF 8031/8051 Capacitive Transducers DECODER Electromagnetic Transducer Hall voltage INTEL 8051 MICROCONTROLLER INTEL 8251A Insulation Resistance Test PINS AND SIGNALS OF 8031/8051 Physical Transducers Resistive Transducer STARTERS Thermocouple Vacuum Gages USART-INTEL 8251A APPLICATIONs OF 8085 MICROPROCESSOR CAPACITANCE Data Transfer Instructions In 8086 Processors EARTH FAULT RELAY ELECTRIC MOTORS ELECTRICAL AND ELECTRONIC INSTRUMENTS ELECTRICAL BREAKDOWN IN GASES FIELD EFFECT TRANSISTOR (FET) INTEL 8257 IONIZATION AND DECAY PROCESSES Inductive Transducers Microprocessor and Microcontroller OVER CURRENT RELAY OVER CURRENT RELAY TESTING METHODS PhotoConductive Detectors PhotoVoltaic Detectors Registers Of 8051/8031 Microcontroller Testing Methods ADC INTERFACE AMPLIFIERS APPLICATIONS OF 8259 EARTH ELECTRODE RESISTANCE MEASUREMENT TESTING METHODS EARTH FAULT RELAY TESTING METHODS Electricity Ferrodynamic Wattmeter Fiber-Optic Transducers IC TESTER IC TESTER part-2 INTERRUPTS Intravascular imaging transducer LIGHTNING ARRESTERS MEASUREMENT SYSTEM Mechanical imaging transducers Mesh Current-2 Millman's Theorem NEGATIVE FEEDBACK Norton's Polarity Test Potentiometric transducers Ratio Test SERIAL DATA COMMUNICATION SFR OF 8051/8031 SOLIDS AND LIQUIDS Speed Control System 8085 Stepper Motor Control System Winding Resistance Test 20 MVA 6-digits 6-digits 7-segment LEDs 7-segment A-to-D A/D ADC ADVANTAGES OF CORONA ALTERNATOR BY POTIER & ASA METHOD ANALOG TO DIGITAL CONVERTER AUXILIARY TRANSFORMER AUXILIARY TRANSFORMER TESTING AUXILIARY TRANSFORMER TESTING METHODS Analog Devices A–D BERNOULLI’S PRINCIPLE BUS BAR BUS BAR TESTING Basic measuring circuits Bernoulli's Equation Bit Manipulation Instruction Buchholz relay test CORONA POWER LOSS CURRENT TRANSFORMER CURRENT TRANSFORMER TESTING Contact resistance test Current to voltage converter DAC INTERFACE DESCRIBE MULTIPLY-EXCITED Digital Storage Oscilloscope Display Driver Circuit E PROMER ELPLUS NT-111 EPROM AND STATIC RAM EXCITED MAGNETIC FIELD Electrical Machines II- Exp NO.1 Energy Meters FACTORS AFFECTING CORONA FLIP FLOPS Fluid Dynamics and Bernoulli's Equation Fluorescence Chemical Transducers Foil Strain Gages HALL EFFECT HIGH VOLTAGE ENGG HV test HYSTERESIS MOTOR Hall co-efficient Hall voltage and Hall Co-efficient High Voltage Insulator Coating Hot-wire anemometer How to Read a Capacitor? IC TESTER part-1 INSTRUMENT TRANSFORMERS Importance of Hall Effect Insulation resistance check Insulator Coating Knee point Test LEDs LEDs Display Driver LEDs Display Driver Circuit LM35 LOGIC CONTROLLER LPT LPT PORT LPT PORT EXPANDER LPT PORT LPT PORT EXTENDER Life Gone? MAGNETIC FIELD MAGNETIC FIELD SYSTEMS METHOD OF STATEMENT FOR TRANSFORMER STABILITY TEST METHODS OF REDUCING CORONA EFFECT MULTIPLY-EXCITED MULTIPLY-EXCITED MAGNETIC FIELD SYSTEMS Mesh Current Mesh Current-1 Moving Iron Instruments Multiplexing Network Theorems Node Voltage Method On-No Load And On Load Condition PLC PORT EXTENDER POTIER & ASA METHOD POWER TRANSFORMER POWER TRANSFORMER TESTING POWER TRANSFORMER TESTING METHODS PROGRAMMABLE LOGIC PROGRAMMABLE LOGIC CONTROLLER Parallel Port EXPANDER Paschen's law Piezoelectric Wave-Propagation Transducers Potential Transformer RADIO INTERFERENCE RECTIFIERS REGULATION OF ALTERNATOR REGULATION OF THREE PHASE ALTERNATOR Read a Capacitor SINGLY-EXCITED SOLIDS AND LIQUIDS Classical gas laws Secondary effects Semiconductor strain gages Speaker Driver Strain Gages Streamer theory Superposition Superposition theorem Swinburne’s Test TMOD TRANSFORMER TESTING METHODS Tape Recorder Three-Phase Wattmeter Transformer Tap Changer Transformer Testing Vector group test Virus Activity Voltage Insulator Coating Voltage To Frequency Converter Voltage to current converter What is analog-to-digital conversion Windows work for Nokia capacitor labels excitation current test magnetic balance voltage to frequency converter wiki electronic frequency converter testing voltage with a multimeter 50 hz voltages voltmeter

Search More Posts

Followers