Solved

Parallel Port Data Pins (Individually)

Posted on 2002-05-25
16
381 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
ID: 7034864
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
ID: 7034913
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
ID: 7035000
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
ID: 7035002
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
ID: 7035012
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
ID: 7035022
what's a two printer port?
0
 

Author Comment

by:axia
ID: 7035024
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
ID: 7035042
there is those serial to usb adaptor

i mean by using two different printer ports like lpt1 and lpt2
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:axia
ID: 7035045
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
ID: 7035079
usb port
think if there's one for serial, there will also one for parallel port
0
 

Author Comment

by:axia
ID: 7035083
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
ID: 7035128
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
ID: 7035853
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
ID: 7036307
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
ID: 7036364
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
ID: 7036593
yup yup
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
SetCurrentDirectory path limit 7 106
Header Errors LNK2019, LNK1120 - Unresolved Externals 4 97
C++ :Change value from  DisableCMD registry 4 52
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

863 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

26 Experts available now in Live!

Get 1:1 Help Now