Can I Use LPT Ports as I/O with a Program or C++ Directory?

  • Thread starter Thread starter TuviaDaCat
  • Start date Start date
  • Tags Tags
    Controller
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 8K views
TuviaDaCat
Messages
85
Reaction score
1
i want to use my lpt ports as I/O. for example to run a relay, or react to an outside contact.
i need a program which can check the state of ports, or output to ports, and make conditions according to the inputs...

is there some kind of program for this? or maybe a c++ directory?

thanks
 
Engineering news on Phys.org
I am currently working on such an interface. Its called Linux Parallel Port+.
https://sourceforge.net/projects/linuxparaport/

The current version is very limited and can currently output a byte of data and read form the port. Over the weekend I will upload a new version. This version will give the ability to have control of individual output pins and read the status of the input pins individually (hopefully I'll have PWM working).

You can read CVS for the most current version of the source code and the documents (there's probably typos, grammar, and a few technical mistakes). The documents have some help on the port architecture and how one should control relays and so on. It isn't that detailed; I will try my best to change that soon.

There are still other goodies that I'm working on such as PWM and networking for remote monitoring.
BTW, its written in C. The code is written for Linux and certain version of UNIX.
 
thanks, but I am using windows, and more worrying, I am using windows 64 bit...
 
Well if you're programming skills are good, you could port it to windows. It should be easier to port now considering that the network functions are not implemented.

Alternatively, you can learn the windows API for this and code on your own:
http://www.epanorama.net/circuits/parallel_output.html
Parallel Port Complete by Jan Axelson is a very good port. I highly recommend this book if you're getting started with port programming (they have source code for windows).

Also Katupitiya and Bentley (2006) is a very good book focusing on using C++ for port programming while making good use of the OOP nature of C++. There are many practical circuits in the book with fairly good explanations. The good thing is that the book comes with a circuit board so you can build all the circuits in the book. Both linux and windows source codes are available.
 
Under anything newer than win95 you can't talk to the port directly yourself. Only kernel mode device drivers are allowed to break your system!
There are a couple of direct to parrallel drivers around, see:
http://www.codeproject.com/useritems/Inpout32_read.asp

You can also write your own with the device driver devkit, it includes an exammple miniport driver ( or at least it did under NT4 last time I did it.)
 
Last edited by a moderator: