Click to See Complete Forum and Search --> : Help with Hardware interfacing with parallel port


Shahzad
April 8th, 1999, 10:47 AM
I need to interface hardware through parallel port. More specifically I need to read and write data into the registors of an IC (MT8888C). If you know anything related to hardware interfacing, Please do reply!

shahzad.alam@usa.net

J.P.M.-SOFT
April 8th, 1999, 01:56 PM
It depends on what operatingsystem you are using. Until now you can use in Win 95/98 the "in" and "out" standard C functions to read and write your parr. port from within your program. A much better solution (and the only one in NT) is writing a driver to access your port.
If you know the address of your port, the offset adresses of the different registers of the I/O chip can be found in the data-sheets (mostly you can find them on Internet.

I hope I've put you on the way
Greetings

Jean Paul Mertens
ON1AMI
jpmsoft-at-glo.be (repl -at- with @)
http://user.online.be/~gd30347

Doug Sisco
April 8th, 1999, 02:31 PM
I worked on a program last year to write to hardware via the parallel port. Fortunately I was writing code for Win95/98 which is very easy since Win95/98 allows you to talk directly to the hardware. Check-out http://www.lvr.com/parport.htm.

Shahzad
April 9th, 1999, 09:14 PM
In visual C++ there are command like _out _in etc that start with the underscore. Are they counter part of those 'in' and 'out' of C++. Are the similar to those more or less?
Shahzad
u940098@giki.edu.pk

Shahzad
April 9th, 1999, 09:45 PM
Thankx for the web site address.

Imran Rajwani
June 29th, 1999, 05:17 PM
nt or 95/98, they both recognize LPT1 as parallel port 1 device and so on. Use createfile() to open the device, readfile() & writefile() to perform i/o, .DeviceIoControl() to control and monitor control lines,closehandle to close the handle.
in createfile();

The fdwShareMode parameter must be zero, opening the resource for exclusive access.
The fdwCreate parameter must specify the OPEN_EXISTING flag.
The hTemplateFile parameter must be NULL.

Search online help for these functions for details.

deepak_warrier
January 21st, 2000, 05:39 AM
I want to read signals from a user defined H/W unit connected to the LPT1 port, interpret it and display some valuable information at the front-end.
I'm using CreateFile, ReadFile CloseFile functions. I was able to successfully open the port, read the current comm status using GetCommState(...). But ReadFile(...) function returned a failure, reading zero bytes, even when the signal from the H/W unit was given to the Data pins of the port.
1] Is there any value to be set using the SetCommState(...) funtion before calling ReadFile(...), in the DCB(Device control block structure), to facilitate parallel port communication?
2] Is there a need of a generating a STROBE signal in the H/W unit, to intimate the arrival/availibility of data at the port?
3] What are the other bare minimum signals to be generated from the H/W unit, so as to facilitate efficient reading from the s/w side?
4] Is there any signal to be generated from the part of the s/w, like an acknowledgement, and written back to LPT1, in between each read cycle?
Thankx for any help.

kvasilak
January 21st, 2000, 07:00 AM
I have a simple class that allows direct access to the parallel port. NOT NT compat of course...
I will EMail you a copy
Keith

( I suppose I should post the code here at CG :-)

kvasilak
January 21st, 2000, 07:14 AM
Here is the code...

Header...
class CParPort
{
public:
void Address(unsigned int address );
bool Set(BYTE Byte);
BYTE Get();

CParPort();
virtual ~CParPort();

protected:
void Init();
unsigned int m_Address;
unsigned int m_Status;
unsigned int m_Control;
};

CPP
CParPort::CParPort()
{
m_Address = 0x378;
}

CParPort::~CParPort()
{

}

//Write the byte to the parallel port
bool CParPort::Set(BYTE Byte)
{
_outp(m_Address,Byte);

return true;
}

//Read a Byte from the parallel port
BYTE CParPort::Get()
{

BYTE Lowbyte = _inp(m_Status);// & 0xF0; /* Read MSnibble */

return Lowbyte;//Byte;
}

//Set the address for the port
void CParPort::Address(unsigned int address)
{
m_Address = address;
m_Status = address +1;
m_Control = address +2;

Init();
}

void CParPort::Init()
{

BYTE Old = _inp(m_Control +1);

_outp(m_Control, Old & 0xF0 | 0x04 );
}


Just create it, set the address then read and write bytes to the parallel port..
Yea it's simple, but easy to understand :-)

Keith