ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Another life of the LPT port. Part 1. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Computers I did not expect that my first article (azbukavb.narod.ru/teorie/LPT.htm) would arouse such interest among programmers and electronics engineers, because I received a lot of letters with questions and continue to receive them to this day, although it has been almost three years since the article was written. In addition, a number of inaccuracies were made in the first article. All this prompted me to write a more detailed article on this topic, in which I will try to answer most of the questions of dear readers and correct those inaccuracies that were made in the first article. Let the readers of the first article not take offense at me, but we will again consider in detail each contact and bit of our LPT port. In the first part of the article, the theory will be considered, in the second and subsequent (if any) we will consider electronic devices that can be "picked up" to this port. Ø In the text you will meet the generally accepted abbreviation for writing numbers. o For example, 10102 - two in the subscript indicates that the number 5 represented in binary, Ø 12410 - ten in the subscript, indicates that the number 124 decimal. It's like that...just in case As practice has shown, all programs correctly written and supplemented with the appropriate libraries (vbio32.dll, inpout32.dll, dlportio.dll, etc.) work on most computers with operating systems of the Windows family. I tested all my programs (Visual Basic5.0, 6.0) on Win95, 98, Me, 2000, XP HE, XP Prof and even DOS6.22 (QBasic) - everything works fine. In DOS, no libraries are needed at all, everything works there anyway. Immediately make a reservation that vbio32.dll and inpout32.dll WILL NOT WORK UNDER Win2000, but they will work quite calmly under Win95, 98, Me. By the way, you can take any of these libraries at sano2000.narod.ru/index.html. I wanted to try dlportio.dll and am currently working with this library. And finally, before writing programs, you must correctly declare the library you are using. Ø For inpout32.dll Private Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer Private Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer) Ø For dlportio.dll Private Declare Function DlPortReadPortUchar Lib "dlportio.dll" (ByVal Port As Long) As Byte Private Declare Sub DlPortWritePortUchar Lib "dlportio.dll" (ByVal Port As Long, ByVal Value As Byte) What is the difference Private from Public I will not write. The parallel port for communicating with a printer (or other device) has a base address of &H378 (LPT1), &H278 (LPT2), &H3BC (LPT3). In this article, we will consider only LPT1. The address space for this port is in the range &H378-&H37F.
· Address &H378 called basic and serves to write (read, but more on that later) data to the port, on the D0-D7 line.
· Address &H379 (basic+1) designed to read status bits from a device connected to the LPT port (printer, scanner, etc.)
· Address &H37A (basic+2) is used to write the control bits of the device connected to the LPT port (printer, scanner, etc.). In the tables below, the contacts and signals of each of the addresses are "decoded" Contacts 18-25 - "ground" (common, GND,GROUND, etc.) Consider programming each of the addresses.
· Base address &H378(LPT1) allows you to write data to a port on the line D0-D7 in the range from 0 to 255.
· We write the number 69 to the port
*************************************************** *************************************************** *****
· Address &H379 is used to read status bits.
· Read the state of the port at address &H379 Ø When reading address &H379 it must be remembered that the first three bits are not used and always have a log value. "1", and the 7th bit is inverted. As a result, if all pins 15, 13, 12, 10, 11 are grounded, then when reading information, you will get 1 + 2 + 4 on the first three bits (which are not used) and on the 7th bit (pin 11- inverse, which means that when a ground fault occurs, there will be a log. "1") +128 total 135. We should not forget about this. In the second part of the article, we will dwell on this in more detail.
*************************************************** *************************************************** *****
· Address &H37A is used to write control bits.
· Recording the signalSTROBE (control bit 0)
Why 10? Let's look at the table.
signals STROBE, CAR, SELECT IN - inverse, which means that in order to get a logical "1" at the output of connector pins 14, 17, 1, you need to apply a logical "0" to these bits, i.e. Give one thing, get the opposite. Signal INIT direct (not inverse), so the logical "1" on pin 16 will appear when we apply a logical "1" to this bit, i.e. what is given is what is received. Let's try to get on pins 1,17 - a low level of the signal "0", and on pins 14 and 16 a high level of the signal "1", i.e. at the output of contacts 1,14,16,17 there will be 0 1 1 0 (610). On the null bit(-STROBE) we give "1" (on contact 1 there will be "0"), on first bit(-CAR) we give "0" (on contact 14 there will be "1"), on second bit(INIT) we give "1" (on contact 1 there will be "1") and, finally, on third bit(-SELECT IN) we give "1" (on contact 17 there will be "0"), i.e. we wrote down the number 37 at &H1011A2, is 1310. So, in order to get 6 at the output, you need to apply 13. For convenience, I give a table with all possible combinations of numbers from 0 to 15
And finally, the last part of this article. If your computer supports the EPP standard, then the fourth bit at the address &H37A you will be able to enable an interrupt (for LPT1 it is IRQ7) from the printer, just don't ask me what it is, I don't know anything about interrupts anyway. But the fifth bit is 1101012, for example, giving the number 4310, you set the D0-D7 bus to RECEPTION data. In this case, all digits (contacts 2-9) take the value of logical "1". To apply a logical "0" to the desired contact, it is necessary to close it through a resistance of 240 - 360 Ohms to the "ground". Thus, through the LPT port of the computer, we get a standard device with 12 output signals and 5 input signals, and when the port is switched to EPP mode, we get 4 output signals and 13 input signals.
Author: Alexey Klyushnikov, Ivanovo; Publication: cxem.net See other articles Section Computers. Read and write useful comments on this article. Latest news of science and technology, new electronics: Artificial leather for touch emulation
15.04.2024 Petgugu Global cat litter
15.04.2024 The attractiveness of caring men
14.04.2024
Other interesting news: ▪ Aluminum batteries are better than lithium-ion ▪ Digital multimeter with Bluetooth and NFC ▪ New Zealand launches first space rocket News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site Calls and audio simulators. Article selection ▪ article Art and culture. Crosswordist's Handbook ▪ article What is Cerebral Palsy? Detailed answer ▪ article Decrees, letters, orders, instructions on labor protection. Directory ▪ article Powders for washing. Simple recipes and tips
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |