Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write a device driver for communicating from the PC parallel port to a device

Status
Not open for further replies.

avimit

Banned
Joined
Nov 16, 2005
Messages
412
Helped
91
Reputation
182
Reaction score
23
Trophy points
1,298
Location
Fleet, UK
Activity points
0
I need a very simple device driver, which can send 0s and 1s to the parallel port of a PC running win XP? any ideas how to write it or how to get it? It will only be one way communication, i.e form the PC parallel port to the device/board, and no signal coming back from the device/board
Kr,
Avi
 

Re: Device Drivers

avimit said:
I need a very simple device driver, which can send 0s and 1s to the parallel port of a PC running win XP? any ideas how to write it or how to get it? It will only be one way communication, i.e form the PC parallel port to the device/board, and no signal coming back from the device/board
Kr,
Avi

Quite simple with Delphi.
See here:
http://www.sixca.com/eng/articles/pardel/
 

Re: Device Drivers

If you can code in VB60 use the inpout32.dll library, this allow to set the I/O bit of the parallel port.

Declare into a .bas module:

Code:
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)

put the dll into the program folder, to output data on the data line (D0,..., D7) use this simple code inside a form:

Code:
Out (888), <data_to_output_on_LPT1_data_word>

to read the status register (then the line BUSY, ACK, PE, SLCT, ERROR line) use this code:

Code:
Dim status As Integer
status = Inp(889)

also if (status AND 128) = 128 then the BUSY line was high otherwise is low, in a similar way you can check the other lines then:

Code:
' Bit 8 status register
If ((status And 128) = 128) Then
        ' BUSY IS HIGH
Else
        ' BUSY IS LOW
End If
    
' Bit 7 status register
If ((status And 64) = 64) Then
        ' ACK IS HIGH
Else
        ' ACK IS LOW
End If

and so on for the other input lines (and with 32, 16 and 8 ).

I've also attached a zip file with inside a pdf tutorial and the required dll.

Hope it help.

Bye
Pow
 

Re: Device Drivers

**broken link removed**

Just saw something related in a Taiwan website

Looks like doing I/O without device driver

ha ha notepad controlled 8051.:?::?:
 

Re: Device Drivers

This can be done very easily in Turbo C++ without any requirement of any file

just using the C function (outp) . if you have a turbo C++ or Borland C++ you will find

a total example in the help . you just know the parallel port number which is usually

0x37f or 0x378
 

Re: Device Drivers

mezo said:
This can be done very easily in Turbo C++ without any requirement of any file

just using the C function (outp) . if you have a turbo C++ or Borland C++ you will find

a total example in the help . you just know the parallel port number which is usually

0x3f8 or 0x378

May be this isn't able to work with WinXP type OS, this type of OS require driver to communicate with printer port due to the kernel, but I don't know if this is also implemented into the TC++.

Bye
Pow
 

Re: Device Drivers


yes this can be done with TC++ under the Windows XP Enviroment , coz i did myself . Here is the code to do it , you will find it in the TC++ help :

sending through port :

#include<stdio.h>
#include<conio.h>

int main(void)
{
unsigned port = 0x378 // first pin in parallel port 0x378-0x37f
int value ;
value = outp(port,'c') // c is the number you'll send to LPT
printf("value %c sent to port %d\n", value, port);
return 0
}


receiving through port
:

#include <stdio.h>
#include <dos.h>
int main(void)
{
int result;
int port = 0x378;
result = inoprt(port);
printf("Word read from port %d = 0x%X\n", port, result);
}


Try it & tell me.
 

Re: Device Drivers

Dear mezo,
I seriously doubt that what you have written is going to work. But you say you have checked it? Please let me know how did you check it.
A very simple way to check it, is to connect a LED board at the o/p parallel port. Did you use something like that?
If what you say will work, and it is as simple as you have written, then why so much 'fuss' about device driver?
 

Re: Device Drivers

Dear , My friend

i checked it using µc AT89c52 interfacing with a seven segment register and my PC's serial port .
i typed the number on the output program that i typed before using the serial port number and when i compiled the program the number i typed to be transmitted was written on the seven segment .
that's how i checked it . hope you check it
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top