Solved

Parallel Port Data Pins (Individually)

Posted on 2002-05-25
16
379 Views
Last Modified: 2010-04-02
How do I send a seperate signal through each parallel port data channel (pin) individually (pins 2-9)? Also, is there another port which allows me to do this with more than 8 data channels?
0
Comment
Question by:axia
  • 8
  • 8
16 Comments
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
each pin serves its own purpose, for e.g. there is the send pin, receive pin etc. practically it is not recommended that you try to send data through by individual pins.
0
 

Author Comment

by:axia
Comment Utility
i understand what you are saying. however i'd like to send through each pin individually. i've seen software that does this, so i know it's possible. I'm creating a device that connects to the computer through an I/O port. it has at minimum 8 connections on it. these connections are either on or off based on if data is being sent through the channel (on the parallel port a channel is a pin) that they are connected to. I was told that i should use the parallel port.

My questions are: how do i control each of these pins individually? Also, i heard that the parallel port only allows me to send data through 8 of the 25 channels. Is there a port that allows me to send data through more than 8?
0
 
LVL 3

Accepted Solution

by:
CoolBreeze earned 200 total points
Comment Utility
firstly, you are right, for parallel port, we only use 8 of the 25 channels to send data, that is to say, only these 8 channels will at times be at high voltage (indicating a 1) while the rest of the 17 channels act as ground, always zero.

what you can do is, if you are programming in dos, get the parallel port address from the bios. usually the address can be found at 0x40:0x08h. the word at this location points the address at which you can 'talk' to the parallel port (for lpt1).

for lpt2, the address can be found at 0x40:0x0ah.
what you can do is to send a byte to this port.
___________________________________________
\  13 12 11 10 9  8  7  6  5  4  3  2  1  /  Pin No.
 \  25 24 23 22 21 20 19 18 17 16 15 14  /
  ---------------------------------------

the above is the layout of the parallel port

notice a byte consist of 8 bits, which is related to those 8 channels (or pins) in the following way:


byte position      7  6  5  4  3  2  1  0
pin no.            9  8  7  6  5  4  3  2

so if i want to send a 1 through pin 5 only, i will output to the parallel port a byte with value 2^3 = 8.

Hopes this helps.

try usb if u need faster or more channels
0
 

Author Comment

by:axia
Comment Utility
I'm programming in Win32/MFC. Is there a way i could use the parallel port communication functions to do the same thing?

Also, if I could do the same thing with USB it would be much much better (more channels). However the USB plug appears to be just one pin. Do you know how i can send data in individual channels to a USB device? Finally, just how many channels can I use with USB and how do address the port (i can use LPT1 for parallel, what about USB)?

[i'm offering more points for this info]
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
oops, my apologies. usb works in another way, it doesn't have like many many pins. so i guess it won't work for u.

if u really want more channels, how about use two printer port?

use OpenPrinter and WritePrinter function for win api to send raw data to the printer port aka parallel port
0
 

Author Comment

by:axia
Comment Utility
what's a two printer port?
0
 

Author Comment

by:axia
Comment Utility
also, is there a way i could send data over USB that is then branched out in to individual channels using some kind of adaptor?
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
there is those serial to usb adaptor

i mean by using two different printer ports like lpt1 and lpt2
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:axia
Comment Utility
do they make models for parallel ports? Also, when using those devices do i program them as a USB port or as a parallel port? This would be ideal because then i could use 2 LPT ports [both using USB ports] (then i wouldn't have to add another DB25 port to my computer).
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
usb port
think if there's one for serial, there will also one for parallel port
0
 

Author Comment

by:axia
Comment Utility
hmm, that's a bit strange. why would they make adaptors for serial/parallel to USB when the devices had to be programmed as USB devices? if i used it on any of my serial devices (like my modem) my dial-up software would not be able to talk to the modem because it's looking for a serial modem. the adaptors are also about $30. that seems pretty expensive.

Finally, i think you missed this question:
I'm programming in Win32/MFC. Is there a way i could use the parallel port communication functions to do the same thing? [referring to the DOS instructions you gave]. What would i do if I wanted to send a 1 over pin5 in Win32/MFC?
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
to do that use CreateFile to open file "LPT1", and attribute set as OPEN_EXISTING, then you can send a byte to the parallel port using TransmitCommChar passing the handle you get from CreateFile and the byte you want to send
0
 

Author Comment

by:axia
Comment Utility
OK thanks. So is this chart accurate?

Pins : Value
2:2^0
3:2^1
4:2^2
5:2^3
6:2^4
7:2^5
8:2^6
9:2^7

And I'm sure this is simple, but what do you mean by send the byte I want to send? Are you saying that to send a 1 over pin 5 I would write this?:
TransmitCommChar(htoLPT1, 8); //htoLPT1 is what is returned by CreateFile
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
yup you got it right man!
similarly if you want to send through pin 5 and 8 you would send the byte :

2^3 + 2^6 = 8 + 64 = 72 decimal
0
 

Author Comment

by:axia
Comment Utility
ok thanks.
So you are saying that i can't use the USB -> Parallel adaptors for this project, because they must be programmed as USB devices and USB will not work for this project. This means that i need another parallel port put in my computer?
0
 
LVL 3

Expert Comment

by:CoolBreeze
Comment Utility
yup yup
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now