Friday, November 14, 2003

Basic Parallel Port Programming

HANDLING: 
ADDRESS:-
The address of parallel port is usually identified on device manager on (com and lpt) addresses. Usually it is also given on the BIOS .you can check its address by entering in the BIOS. The following is the address of parallel port.
0x378
0x3BC-0X3BF
The "x" indicates that the address is in hexadecimal number.

PIN CONFIGURATION:
  • 8 output pins accessed via the DATA Port
  • 5 input pins (one inverted) accessed via the STATUS Port
  • 4 output pins (three inverted) accessed via the CONTROL Port

PIN USED FOR OPERATIONS:
Usually we want to use the pin 2 to pin 9 through which we want to transfer data. Pin 10, 11,12,13,15 are used as a status pin means that through these pins we can check the status of our circuit. 

Pin 1,14,16,17 are control pin.

Pin 18 up to 25 are usually used as a ground pin.

Example:
The programs below are examples about the way you can program the parallel port.

#include <stdio.h>

#include <dos.h>
#include <conio.h>
/*****************************************/
/*This program set the parallel port outputs*/
/*****************************************/
void main (void)
{
clrscr();
outportb(0x378,0xff);
outportb(0x37a,0xff);
getch(); }

The first program shows you how to send a byte to the parallel port output addresses. It's as easy as you can see. The outportb (); function sends a byte to a specified I/O port. The first function parameter is the address of the port to write a byte. The second parameter is the value of the byte to send. Both parameters can be defined as variables. In this case the first parameter must be an unsigned int, and the second an unsigned char.

#include <stdio.h>
#include <dos.h>
#include <conio.h>
/***************************************/
/*This function read parallel port inputs*/
/**************************************/
int Read_Input()
{ int Byte;
Byte=inportb(0x379);
return Byte; }
void main (void)
{ int PP_Input;
clrscr();
PP_Input = Read_Input;
printf("%d",var);
getch(); }

The second example shows you how to read a byte from the parallel port input address. The main function is only used to show the value of the byte in the screen. The inportb (); function read a byte from the specified I/O address of the computer. The parameter must be an unsigned int.

Integration of SQLite3 and Netbeans C/C++ IDE

Few days back, I wanted to use SQLite database for one of my project. I spend couple of hours to find a way to integrate with Netbeans. Mayb...