Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to monitor parallel port data of win 3.1 system

Hi nqn827,
 
Before testing with the win 3.1 system, we tried to do some test on two win xp system
We used a cable with following connection:
Data Port 1 - Data Port 2
Status Port 1 - Control Port 2
Control Port 1- Status Port 2
 
to connect the parallel ports (1 & 2) of two windows xp system. One is a PC and the other is a laptop.
Ran an application on both sides. On the PC side we monitor all the registers and on the laptop side, we try to write some data to the data port.
The problem is both the PC and laptop try to control the data port. So we couldn't monitor the data written at the laptop side from the PC side. For e.g. laptop side writes 0x22 to data port, the laptop side data register will show 00100010, the PC side is not able to see this. It always reads its data register as 11111111 which is the value at power up.
 
Am I missing on some basics? Do you have any suggestion?
Aromal Lilly
Columbus, OH
0 Kudos
Message 11 of 23
(2,006 Views)
Hello Aro,

Did you set the port as "bi-directional" in the BIOS of both computers?

Have a great day!
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 12 of 23
(1,970 Views)

Thanks O_Proulx! I will try changing the BIOS setting on both Win XP systems. But utltimately our intention is to monitor the data send and received by a Win 3.1 system and I am not sure, if its parallel port mode can be changed to bi-directional.

Aromal Lilly
Columbus, OH
0 Kudos
Message 13 of 23
(1,955 Views)

Hi KC, nqn827

I followed you guys' advice to monitor the data transferred between the host PC (win 3.1) and the peripheral (vision system).

The setup is like this. My monitor PC (win xp) has two parallel ports - port1, port2. Both are PS/2. Port1 is connected to host PC's i/o port using a cross over cable whose connection is in the code attached. Port2 is connected to the peripheral's i/o port using straight through 25 pin cable. Wrote a monitor program to read port1 and port2 and send the status byte from peripheral to host PC and the control byte from host PC to the peripheral. The data byte is copied from port 1 to port 2 or the other way based on the host PC's strobe bit. If the strobe bit is 1 (signal is low), data byte of port1(c5=1, data is input) is copied to port2(c5=0, data is output) and vice versa.

The mechanism works partially. When the software on host PC starts, it send the contents of a known file to the peripheral using proper handshake "compatibility mode" as confirmed from my monitor's log. After the file is downloaded, it expect to receive something back from the peripheral. For some reason, this is not happening. So the software on host PC reports, "download complete but device failed to start" and quit running. The communication is definitely slowed down by this mechanism, but I don't understand why the peripheral fails to send data back to the host PC. Do anyone know what I am doing wrong here?

The program use publicly available "inpout32.dll" to read and write to parallel ports and is attached.

Thanks...

Aromal Lilly
Columbus, OH
0 Kudos
Message 14 of 23
(1,872 Views)
Hello again Aro,

I think the first thing we need to do is narrow down the problem:  Are you sure the peripheral is receiving the entire file?  Then, are you sure that it is replying properly when the file is done?  Then, are you sure the monitor PC is receiving this signal?  Is it passing it properly to the other port?  If we go down this chain, I think we can find where the trouble is.

On a seperate track, it seems like you could implement this system very easily with a digital IO card.  I know it may be a little late now, and I know you have mentionned it before, but here are a few links for NI digital IO boards you can use in PCI or USB format.  You can also look at the data acquisition page for many more options.  These are very easy to use from LabVIEW and LabWindows/CVI.

Please let me know if you need more help with any of this.  Have a great day.
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 15 of 23
(1,837 Views)

Hi Aro,

Can you provide more info ?

Like the program (LV I hope) you use. A despription of the protocol. etc.

0 Kudos
Message 16 of 23
(1,829 Views)

Hi O_Proulx, KC

The program is attached to my last post. The peripheral is receiving the file from the log below which shows the handshake between host PC (CONTROL1) and peripheral (STATUS2). When host set strobe bit c0=1 (CONTROL1) at port1, my monitor set c5=1 at port1 and c5=0 at port2 and copy DATA1 to DATA2 so that the character 'S' set by host appear at the peripheral. The peripheral whose busy bit s7=1 (STATUS2) till now change to s7=0. Seing that s7=0, host set strobe bit c0=0 (CONTROL1). The peripheral by now have read 'S' from DATA2 sets s7=1 (STATUS2) again ready for the next byte of data. The host continues to send the next byte.

10:48:16, CONTROL1 = (00001101); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 36 (00100100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00101101); STATUS1 = (11011000); DATA1 = 83 {S} (01010011) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00101100); STATUS1 = (01011100); DATA1 = 83 {S} (01010011) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 83 {S} (01010011)
10:48:16, CONTROL1 = (00001100); STATUS1 = (01011000); DATA1 = 83 {S} (01010011) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00001101); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00101101); STATUS1 = (11011000); DATA1 = 48 {0} (00110000) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00101100); STATUS1 = (01011100); DATA1 = 48 {0} (00110000) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 48 {0} (00110000)
10:48:16, CONTROL1 = (00001100); STATUS1 = (01011000); DATA1 = 48 {0} (00110000) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
10:48:16, CONTROL1 = (00001101); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)

At the end of transmission

11:08:41, CONTROL1 = (00001101); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00101101); STATUS1 = (11011000); DATA1 = 48 {0} (00110000) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00101100); STATUS1 = (01011100); DATA1 = 48 {0} (00110000) CONTROL2 = 13 (00001101); STATUS2 = 88 (01011000); DATA2 = 48 {0} (00110000)
11:08:41, CONTROL1 = (00001100); STATUS1 = (01011000); DATA1 = 48 {0} (00110000) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00001100); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00001100); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00001100); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)
11:08:41, CONTROL1 = (00001100); STATUS1 = (11011000); DATA1 = 255 {ÿ} (11111111) CONTROL2 = 44 (00101100); STATUS2 = 216 (11011000); DATA2 = 255 {ÿ} (11111111)

After host send last character '0', nothing happens on CONTROL1 or STATUS2. It stays the same. Notice that c5=0 (CONTROL1) meaning port 1 data is now output and c5=1 (CONTROL2) meaning port2 data is input. Also host's strobe c0=0(CONTROL1), so it is ready to receive. All bits at all register stays the same for ever and host software displays error that file downloaded but peripheral wouldn't start.



Message Edited by Aro on 04-25-2008 09:07 AM

Message Edited by Aro on 04-25-2008 09:09 AM
Aromal Lilly
Columbus, OH
0 Kudos
Message 17 of 23
(1,817 Views)
Hello Aro,

You wrote:

The peripheral is receiving the file from the log below which shows the handshake between host PC (CONTROL1) and peripheral (STATUS2). When host set strobe bit c0=1 (CONTROL1) at port1, my monitor set c5=1 at port1 and c5=0 at port2 and copy DATA1 to DATA2 so that the character 'S' set by host appear at the peripheral. The peripheral whose busy bit s7=1 (STATUS2) till now change to s7=0. Seing that s7=0, host set strobe bit c0=0 (CONTROL1). The peripheral by now have read 'S' from DATA2 sets s7=1 (STATUS2) again ready for the next byte of data. The host continues to send the next byte.

Should it be:

When host set strobe bit c0=1 (CONTROL1) at port1, my monitor set c5=1 at port1 and c5=0 at port2 and copy DATA1 to DATA2 so that the character set by host appear at the peripheral. The peripheral keeps the bit s7=0 (STATUS2) until it is done reading the data.  When it is done reading the data, it change to s7=1. Seing that s7=0, the monitor sets bit c0=0 (CONTROL1). The host sees that c0=0, knows that the monitor (and peripheral) are ready for more data.

Am I understanding this process right?

O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 18 of 23
(1,792 Views)

Hi O_Proulx,

For the parallel port, the control lines c0..c3 are physical TTL lines controlled by the PC which can be seen at the printer side. Rest of the lines c4..c7 are internal register entries set by PC/printer for their respective ports. Similarly the status lines s3..s7 are physical TTL lines controlled by the printer which can be seen at the PC side and rest of the lines are internal register entries set by printer/PC for their ports. All data lines d0..d7 are physical TTL lines. For PS-2 type bi-directional parallel ports, the data lines can be set as input or output with respect to the PC by setting PC's control register bit c5. At PC side if we set c5=1, then the data lines become input to PC port. Any software on the PC if it reads the data lines will see the value set by printer and vice versa if host PC set c5=0.

In connection 1 from host PC to port1 of monitor PC, strobe bit c0 can only be set by host PC. It cannot be set by monitor PC because this c0 (pin1) voltage from host PC's port will appear at s6 (pin10) of the monitor PC's port 1 as we are using a cross over cable. From monitor PC port1's point of view the host PC is a printer and vice versa.

 

Aromal Lilly
Columbus, OH
0 Kudos
Message 19 of 23
(1,787 Views)
Hello again Aro,

I apologize for the constant back and forth here, but I am trying to fully understand the details of your application and trying to narrow down where the problem is exactly occurring.

How is the monitor PC signaling to the device that there is no more data available?
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 20 of 23
(1,756 Views)