Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

how to send and process data through parallel port using C

Status
Not open for further replies.

riteshranjan007

Newbie level 4
Joined
Oct 8, 2007
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,317
how to send data to parallel port

I want to know how to read and send data through parallel port of a computer using C language.
 

btbass

Advanced Member level 5
Joined
Jul 20, 2001
Messages
1,897
Helped
438
Reputation
880
Reaction score
287
Trophy points
1,363
Location
Oberon
Activity points
12,861
sending data to parallel port

Check out 'beyondlogic.org' for info on using the parallel port
 

the_risk_master

Advanced Member level 2
Joined
Aug 12, 2005
Messages
662
Helped
79
Reputation
158
Reaction score
19
Trophy points
1,298
Location
UE+MIT, Philippines, (14°N , 120°E )
Activity points
5,527
send data to parallel port c++ code

outportb(0x378,A); //send out data through parallel port
//A = any hex value from 0x00 to 0xFF

B=inportb(0x379); //accept data
//B = unsigned char

Added after 3 minutes:

// my sample program

#include<dos.h>
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned char PIN, POUT;
while(getch()!=27){
PIN=inportb(0x379); /* get input from sensors */
switch(PIN){
case 0x00:while(PIN==0x00){
outportb(0x378,0x01); /* forward dc motor */
}
break;
case 0x08:while(PIN==0x08){
sleep(2); /* pause */
outportb(0x378,0x80); /* stepping action - left */
outportb(0x378,0x40);
outportb(0x378,0x20);
outportb(0x378,0x10);
sleep(2);
}
break;
case 0x10:while(PIN==0x10){
sleep(2); /* pause */
outportb(0x378,0x10); /* stepping action - right */
outportb(0x378,0x20);
outportb(0x378,0x40);
outportb(0x378,0x80);
sleep(2);
}
break;
case 0x18:while(PIN==0x18){
outportb(0x378,0x02); /* reverse dc motor */
}
break;
default:
outportb(0x378,0x00); /* no action */
break;
}
}
}
 

penoy_balut

Full Member level 2
Joined
Sep 8, 2007
Messages
148
Helped
26
Reputation
52
Reaction score
10
Trophy points
1,298
Activity points
1,943
how to send thru parallel port

Have you tested this code? In the while loop it should be the port that is read continuously instead of the variable PIN.
 

cfant

Full Member level 3
Joined
Apr 4, 2001
Messages
188
Helped
25
Reputation
50
Reaction score
6
Trophy points
1,298
Location
California, USA
Activity points
1,151
how i can send data through parallel port

This will not work in WinXP, Vista, only in DOS.
 

mezo

Member level 5
Joined
Jul 16, 2007
Messages
81
Helped
12
Reputation
24
Reaction score
8
Trophy points
1,288
Location
Egypt
Activity points
1,738
outportb 3f8

hey

you want to make interfacing the computer with a microcontroller with C / C++ ?

it's easy if you know two codes , this codes are :-

1- inp = input port (1-byte) , inpw = input word (2-bytes) .

2- outp = output port (1-byte) , outw = output word (2-bytes) .

- you must know your parallel port number in your computer which is usually

LPT Nu. : 3F8

The following code is a prototype for making interfacing in C++ :

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

int main(void)
{
unsigned result;
unsigned port = 1570 ; //the number of parallel port in octal system .
result = inpw(port);
printf(" Word read from port %d = 0x%X\n", port, result);
return 0;
}

try it and enjoy , if there is a problem tell me .
 

bs.classic

Newbie level 1
Joined
May 15, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
Re: help me for send and receive data on LPT port

Dear boss
Thank you
I need a program in C++ language that can send and receive data or chat between two computer through LPT port
please give me source code from sender and receiver for compile and create exe file
I think a program in your site in part "how i can send data through parallel port" is just checking port program with C++ but i need a program can send and receive data through LPT port.
Please help me
My Email Address is : bahram4447@yahoo.com & bs.classic@Gmail.com if need for your respond

best regard.
bahram sabahi far
 

waqar jamil

Newbie level 1
Joined
Apr 23, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,284
i need a c file to turn off the leds connected with paralell port using turbo c
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top