Solved

Parallel Port Data Pins (Individually)

Posted on 2002-05-25
16
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

690 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