
Visit our shop for nerds in control lifestyle products.
- PC reliability?
- Windows, real time
- PID loops
- PCs vs. PLCs
- Replacing people
- MS 'monopoly'?
- Software quality
- Where do we go from here?
- Why pay?
sleep better, but the bad seem to enjoy the waking hours much more.
-- Woody Allen
www.control.com/rss/
To get a personalized feed, become a member at no cost.
Dear all,
I have created an application using Microsoft Excel which will allow me to use my PC's parallel port.
I have downloaded inpout32 and placed it in my windows/system folder. I have typed the following code into a separate module:
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal PortAddress As Integer) _
As Integer
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _
(ByVal PortAddress As Integer, _
ByVal Value As Integer)
using a simple command like "out 888, number" I am able to output any bit pattern I wish. However I am having problems reading the inputs.
I understand the command is inp(888) and indeed if I was to output a bit pattern and then use the above command I am able to get a correct reading. The problem arises when I use external circuitry to supply the digital inputs to the port. Even something as simple as connecting a 5v powersupply to the port does not seem to work.
Any help on this matter would be GREATLY appreciated.
Many thanks.
I don't know... I'll keep test.
regards
Hi, this is a long tutorial. But at least it’s in depth. If the text looks funny due to the format of the website. I can email you the .doc file. phebejtsov@yahoo.com
I was the same author as posted above. I've solved the riddle! Before I get ahead of myself, the parallel port I used is an ECP (Extended Capability Port). Find out if your port is the same as mine, yours could be an EPP or SPP.
Go to “Control Panel / System / Hardware Tab / Device Manager / Ports (Com & LPT) / Printer Port (LPT1 or LPT2) /”
It should indicate what type you have. You can also go to the ‘Resource’ Tab to indicate the range of your port: mine is I/O Range 0378 – 037F, ignore the other I/O range.
For the ECP, there are some over headers if I was to use the data port as both input and output. Instead, I used the signal port for data processing.
As mention before, I used a DMM to test out the ports (nothing connected to the ports yet) and I used the read function from the inpout32.dll, .ie In(Port Address), my particular port address was:
Data Port: 0x378H or in VB Express &H378S
Status Port: 0x379H or in VB Express &H379S
Control Port: 0x37AH or in VB Express &H37AS
*note these port address are in HEX
I used the messagebox.show and displayed the values. Here are my results again.
Data Port: 0 <-- Correct!
Status Port: 120 Decimal; the following represents in binary form with the appropriate pins.
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Control Port: 4 Decimal: the following represents in binary form with the appropriate pins.
| C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
Now, how does this help? It helps! Since I’m using the signal port to read data in (instead of the data port, for the reasons of overheads and extra work!). Look closely at the signal port and the pins. Refer to http://www.codeproject.com/csharp/csppleds.asp for pin locations. S6-S3 are all high! (actually S7 is high too, its just inverted). If I tie one of these pins, .ie pin 11, to a ground pin, .ie pin 25 and run my program. I’ll get a readout of 248 Decimal instead of 120 Decimal! Huh?
248 Decimal: the following represents in binary form with the appropriate pins.
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Notice that the S7 (pin 11) changed from 0 to 1. It worked! Now, if I went through all the available signal pins S7-S3 one by one. These were my results.
Nothing ground: 120D, 78H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
S7 ground: 248D, F8H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
S6 ground: 56D, 38H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 0 | 1 | 1 | 1 | 0 | 0 | 0 |
S5 ground: 88D, 58H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 |
S4 ground: 104D, 68H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 |
S3 ground: 112D, 70H
| S7 | S6 | S5 | S4 | S3 | S2 | S1 | S0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
I know this was very long. But I hoped it helps. If you need the code, I’ll be happy to share. It’s in VB Express although. Email me at phebejtsov@yahoo.com
Regards
I have discovered that if you write decimal 0 to the port (ie set every bit low) and then write 1 to bit 5, this seems to "activate a read mode." With bit 5 set to 1 you can then read the status of the other bits... at least you can when you
use only a 5v power supply with no external circuitry. I attempted to connect this to an A to D converter and at this point I am unable to read anything.
I tried Win95io but it wouldn't work for me as I am using windows XP.
Try my tutorial on www.codeproject.com; I don't know if it'll help you but you might get something out of it.
http://codeproject.com/useritems/Photodiode_Amplifier.aspThis 1st article, I used a relay switch and amplifer to boost my signal.
http://codeproject.com/useritems/Inpout32_read.asp
T his 2nd article has been updated about access to parallel port via VB Express.
Hopes it helps
Regards
phebejtsov
Thanks & Regards
I.E. using inpout32 in VB for Excel:
Out 890, 32
test = Inp(888)
Thanks
Jason
i.e. output pins give a "HIGH" signal when active,
but input pins take a "LOW" signal when active.
All you need to do is to modify the input interfacing circuit...
The circuit should be such that it gives a "LOW" or "Ground" when an input is triggered to the input pins.
Dave S, EE
- Motors, drives and motion control: Green Hills Software tapped for Saab UAV
- Rockwell Automation releases VantagePoint for plant data visualization
- Fast HMI application development software
- Control system and instrumentation design software
- Off-line robotics programming software with 3D simulation
- HMIs: Rugged, instrument-grade-glass on projected capacitive touchscreens
- SCADA cyber security lessons from the movie ‘Eagle Eye’
- New keyboard for extreme conditions
Patronize our advertisers!




