Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

parralel port

Status
Not open for further replies.

danielsmusic

New Member
i bet this topic has been posted many times, iv look everyware and cannot find why i cannot read from the parallel port.
i just reads what i send eg:
i send 10 from the computer.
then read the port it will be 10, it will not change even when i put a logic level on one of the status pins
 
this uses an external dll
Code:
#include <iostream>
using namespace std;

short _stdcall Inp32(short PortAddress);

int main()
{
                while(1)
	{
		cout << Inp32(888) << endl;
	}
                return 0;
}

v++(3volts) - pin 15
v-- - pin 25
 
Not all parallel ports are bi-directional. Check out this: **broken link removed**

The input port address is 1 after the output port address. And I don't think you can read all bits of the input port.

Mike
 
Yh, beyondlogic explains it all.
You read the status and control pins trough BasePort+1 and BasePort+2
Some of them are hardware reversed, remember that.

Also, the parallel port uses TTL levels, 3V may not be enough for a logic '1'. You need 5V
 
AT

Use 5V on that pin15 you wanted to read ...

Then read the STATUS port of the parallel port, not the data port
bit 3 of the result is the value of pin15

Code:
if (Inp32(889) & 8)							//Read the PP STATUS port and extract bit 3 from the result
		cout << "PIN 15 is High (5V)\n";
	else
		cout << "PIN 15 is Low (0V)\n";

Also remind never leave the pin floating. If you want to put a logic 1 on it you should connect 5V to it, if you want logic 0 you should connect the pin to GND. Leaving it unconnected causes irratic results.
 
The parallel port has an output that is buffered by an 8-bit flip-flop. The previous data is always held until new data arrives. See beyondlogic.org and look up the standard parallel port for a schematic of what I am talking about.
 
a printer can do it. i don't see why you cant just give it a logic "1" and it will work
 
danielsmusic said:
a printer can do it. i don't see why you cant just give it a logic "1" and it will work

Remember, you are programming the parallel port as a 'Standard parallel port', Thats the old format used in the '80's thats still there on current pc's for compatibility's sake. The SPP doesnt support 2 way comm's. A printer CAN NO do it, the only way a SPP printer can send data back to the pc is trough the status and control ports mentioned earlier...

On modern devices the printer talks to the pc using the parallel port in 'Ehanced parallel port (EPP)' or the 'Extended Capabilities port (ECP)' wich do support 2 way comms, but isn't as simple to program as the SPP.

Also, in EPP and ECP mode the device you are talking with needs to perform specific handshakes.
 
iv tryed everything on the net read through all the posts on this topic.
is there anything else, it wont read from the port. i putting the wires in there right place a have a 6v batt on pin 15 and the negative on the battery on the case iv made sure its making contact.

iv also ouputed a logic 1 to pin 2 and used a wire to connect pin 2 to 15 still it does'nt work
 
danielsmusic said:
a printer can do it. i don't see why you cant just give it a logic "1" and it will work

Like I said, the data outputs of the parallel port are buffered by an 8-bit flip-flop. In each bit of the flip-flop, there is only one input and one output. The inputs are connected to the PC, and the outputs are connected to pins 2-9 of the port's connector. It is impossible to force the chip to update its data by applying the data to the OUTPUTS :shock: (in SPP mode) unless of course, you happen to have a damaged chip in your computer.

The only way a flip-flop chip can be updated is when data is set at the D pins of the flip-flop and the clock is activated. Since there is no way of controlling this clock externally, we have no choice but to treat pins 2 through 9 as outputs. Because the port has control and status lines, you can add the control lines (I think there is 4) to the outputs to get a 13 bit output (9 + 4). and you can send data to the status lines. (I think there is 5). But to make things easier, use only 4 status lines and drive 8-bit data into a 2-1 demultiplexer, so that you can read 4 bits at a time.

Please be advised that you will need to make or obtain software that uses all the parallel port lines. Most software with printing capabilities will only manage the strobe, data lines, error and busy lines.
 
I forgot to mention that the outputs of the port are floating, and you need to define the defaults.

For each output, make an assumption that every output is high. Connect pin 2 to VCC through a 1K resistor. Do the same with pins 3 through 9 inclusive.

Now you can get 2 defined states. A 1, or a 0.

Make sure that pins 18 through 25 are grounded.
 
are you sure 18 - 25 should be grounded, do you mean to the negative on my battery
 
thats fine. ground is ground, negative is negative. you could hook up 10 -ves from 10 battery sources if you wanted to, and call it ground.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top