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 connect 6 switches to LPT port and check their states?

Status
Not open for further replies.

Bizum

Junior Member level 2
Joined
Jul 10, 2002
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
112
Hi there
Can someone tell me how to connect 6 switches to lpt port(25 pin or centronics 36 pin) to be able to check their states? What adresses i should use(base adress h378). THX for any help.
 

cheolim

Full Member level 1
Joined
Dec 3, 2002
Messages
97
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
873
input lpt

Hello, Bizum

Re. your inquiry, if you need only check port status, it's very simple.
You may do like belows.

#include <dos.h>
#include <bios.h>
#include <stdio.h>
#include <stdlib.h>

#define LPT2 0x379
#define LPT3 0x37A

void main(void)
{
... decalare your variables here;

tmp_dt = inportb(LPT2);
tmp_dat= (tmp_dt & 0x78) >> 3;
tmp_dt = (tmp_dt ^ 0x80) & 0x80;
tmp_dt >>=3;
tmp_dat= tmp_dat + tmp_dt;
tmp_dt = inportb(LPT3);
tmp_dt = (tmp_dt ^ 0x03) & 0x03;
tmp_dt <<= 5;
tmp_dat= tmp_dat + tmp_dt;
tmp_dt = inportb(LPT3);
tmp_dt = (tmp_dt ^ 0x08) & 0x08;
tmp_dt <<= 4;
tmp_dat= tmp_dat + tmp_dt;

... Now you can check 8-pins status;

... Other your codes here;

}

In this point, you'd better to know, there are some pins are Read only
and some are Write only on parallel port of PC.
For detailed information re. this, I attached scanned book image.
Please refer to that, hope to be a useful.

Good luck.
:roll:
 

yogi

Full Member level 6
Joined
Jan 8, 2005
Messages
339
Helped
22
Reputation
44
Reaction score
5
Trophy points
1,298
Activity points
2,181
lpt data output capturing

first connect switches to the data port. Put data port in bidirectional mode(C5=1), then use lpt.exe to see the status of the input pins

bibin john
www.bibinjohn.tk
 

ashad

Full Member level 6
Joined
Mar 28, 2006
Messages
394
Helped
40
Reputation
80
Reaction score
27
Trophy points
1,308
Location
Trento, Italy
Activity points
3,298
lpt input freebsd

as u know that in the LPT port there are Data, control and status pins ........ the status pins u can use as the input
 

budhy

Advanced Member level 3
Joined
Oct 21, 2006
Messages
828
Helped
218
Reputation
436
Reaction score
31
Trophy points
1,308
Location
Indonesia
Activity points
5,265
lpt ecp receive data

ashan wrote :
the status pins u can use as the input
The data port also can use as input port!
 

ashad

Full Member level 6
Joined
Mar 28, 2006
Messages
394
Helped
40
Reputation
80
Reaction score
27
Trophy points
1,308
Location
Trento, Italy
Activity points
3,298
lpt inputs

there are so three different mode of LPT port

in normal mode the Data port can be use as a output port

but in ECP EPP mode we can take input from the data port

i want to say that if u are using any mode then status pins always can be use as a Input
 

budhy

Advanced Member level 3
Joined
Oct 21, 2006
Messages
828
Helped
218
Reputation
436
Reaction score
31
Trophy points
1,308
Location
Indonesia
Activity points
5,265
set lpt spp mode

in normal mode the Data port can be use as a output port
in Normal SPP mode, the Data port can be use as a input port !
 

ashad

Full Member level 6
Joined
Mar 28, 2006
Messages
394
Helped
40
Reputation
80
Reaction score
27
Trophy points
1,308
Location
Trento, Italy
Activity points
3,298
lpt input pins

basically with changing in any Bios i tried to get in the SPP mode to take input from the data port by using C language inport function but i could not get the data but from the status pin i got the correct data ..... i tried it practically then write........

but may be i was making some mistake ........ kindly send me the C code for reference
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top