[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Parallel Port Data Pins (Individually)

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
axia
Asked:
axia
  • 8
  • 8
1 Solution
 
CoolBreezeCommented:
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
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
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
Industry Leaders: 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!

 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
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
 
axiaAuthor Commented:
what's a two printer port?
0
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
there is those serial to usb adaptor

i mean by using two different printer ports like lpt1 and lpt2
0
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
usb port
think if there's one for serial, there will also one for parallel port
0
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
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
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
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
 
axiaAuthor Commented:
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
 
CoolBreezeCommented:
yup yup
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now