Simple input example for parallel port

This forum is all about circuits and components.

Simple input example for parallel port

Postby Just testing on Sun Sep 21, 2008 11:48 am

I am using inpout32.dll.

I want to know when an external event occurs. I want to use parallel port to find out when it happens. I've gotten info that I should apply 5v to pin (10-12 to set it "on" or 1. If I apply 0v it should be "off" or zero.

Great. Simple enough. I take a transformer outputtin 4.5V and connect the + wire to pin 12 and the - wire to pin 20. Then I use this code (inpout32.dll example) to check the pins:
for (i= 0x378; (i<(PPORT_BASE+8)); i++) {
x = Inp32(i);
printf("Port read (%04X)= %04X\n",i,x);
}

I get:
Port read (0378)= 0001
Port read (0379)= 007F
Port read (037A)= 00C0
Port read (037B)= 00FF
Port read (037C)= 00FF
Port read (037D)= 00FF
Port read (037E)= 00FF
Port read (037F)= 00FF

If I take the transformer off the value remain the same. Shouldn't 0379 change to something?
If the write to 0378 I see the first line change to whatever I want.
Just testing
 

Re: Simple input example for parallel port

Postby Tomi Engdahl on Mon Sep 22, 2008 7:57 am

You can find information on using parallel port input pins here:
http://www.epanorama.net/circuits/paral ... html#input

Basically for parallel port interfacing you would need to have a pull-down circuit
when you want the input pin to be zero. If there is no pull-down, the input
pin is normally at logic 1 when there is no input signal connected.
But to be sure it is best to use pull-up resistors in real-life circuits to
guarantee that the pin is really at logic 1 when you want it to be.

TTL inputs in the parallel port tend somewhat to float high, so you might
get by without the pullup resistors, but you are pushing it (might not work reliably).

Code: Select all
        Input  ------+
                     |
                   switch
           |
        Ground ------+


A better approach for interfacing with pull-up resistors:

Image
Tomi Engdahl
Site Admin
 
Posts: 1839
Joined: Mon Oct 20, 2003 6:15 pm
Location: Espoo, Finland

What if I just short ground and pin 10 and gnd pin?

Postby Just testing on Fri Oct 03, 2008 11:10 am

What if I just short ground and pin 10 and gnd pin? When it's not shorted I notice and change in value using inpout32.dll function.

I'd supply a 5V to small relay to switch on, well, short pins 10 and ground.

Seems to work. Could there be a problem?
Just testing
 

Re: Simple input example for parallel port

Postby Tomi Engdahl on Fri Oct 03, 2008 7:34 pm

If it works in your system I don't see any problem in your system.
Most PCs the justg shorting to ground works for input pins because
there is anough pull-up built into the parallel port pulling the pin
to +5V when it is not shorted to ground. But I can't guarantee
that all ports have enough pull-up built into them, so if you
want an universal solution that is guaranteed to work on any
PC parallel port it is best to add this pull-up resistor.
But if your system works without it, then I see no need to add that
extra pull-up resistor...
Tomi Engdahl
Site Admin
 
Posts: 1839
Joined: Mon Oct 20, 2003 6:15 pm
Location: Espoo, Finland

Thanks for the reply

Postby Just testing on Fri Oct 03, 2008 7:58 pm

It seems to work on two computer OK. I check out the your suggestion later.

Another question regarding this matter. I've got two computer and I was thinking of using the same switch. In this set up there is a direct connection bother gnd pins of two computers and input pins of two computer. Now I'm just a hobbyist but I would reckon there will be a problem. What do you think?
Just testing
 

Re: Simple input example for parallel port

Postby Tomi Engdahl on Sat Oct 04, 2008 12:19 pm

If both computers are on then I quess the circuit woudl work then well.

If one of the computers is turned off, then things can fail...
Depening on the computers and maybe some luck the computer where
the power is tuned of could present a quite close to short circuit
from the input pin to ground causing the powered PC to
think the switch is closed. This might happens with your setup
or might not happen...
Tomi Engdahl
Site Admin
 
Posts: 1839
Joined: Mon Oct 20, 2003 6:15 pm
Location: Espoo, Finland

Re: Simple input example for parallel port

Postby Benny on Thu May 07, 2009 8:09 am

I am facing the same problem, I made a program for reading the parallel port. it works quit well in many computer, but no the one in my office. normally when I take off the device on the parallel cable, I will read "11111111" as my reply, but for my office computer , I read "00000000" instead, when I pulling up one of the data line to "1" with a +5V and a 4.7K resistor , I can read 00000001, but when I remove the resistor and the +5v, and read again, the 00000001 still remains, I repeat same process to others data pins, the outcomes are same, all the "1" status seem to be kept by th data pins, unless I end up the program and re-ececute the program again. ( I already set control 5 to "1" to disconnect the Write Latch Register.
:(
Benny
 

Re: Simple input example for parallel port

Postby atif on Wed Jan 27, 2010 11:26 am

Please if any body experienced or sured about the procedure tell me.. My computer's Parallel Port INPUT i.e. ACK gives near 5 Volts Dc (Logic 1) right after I start the system. With help of a resistance I want to reduce this voltage to make it to LOGIC 0.
Now to do this, I just placed only 1 resistance between the Input ACK pin and the ground pin# 25. It makes it to logic 0. but I want to make sure that this will never damage parallel port. My circuit is as follows:

Resistance
ACK PIN
-----/\/\/\-------|
-------------------|
Ground PIN

is it harmful for Parallel port? I used no external voltage supply.
atif
 


Return to Circuits and Components

Who is online

Users browsing this forum: No registered users and 4 guests

cron