View Full Version: KEYPAD INTERFACING WITH PARALLEL PORT

booksbybibin >>Computer interfacing >>KEYPAD INTERFACING WITH PARALLEL PORT


yogi- 07-03-2006
KEYPAD INTERFACING WITH PARALLEL PORT
This tutorial is taken from the book MY EXPERIENCE IN PARALLEL PORT INTERFACING. you can download it free from the files section(file:-parallelport(3 files) of yahoo group-booksbybibin http://groups.yahoo.com/group/booksbybibin/ comments about this book on www.booksbybibin.blogspot.com KEYPAD INTERFACING This section i will explain about connecting keypad to the parallel port. Let's see the keypad connection. A normal keypad costs around Rs.150. A keypad has a problem of keydebouncing and we have to eliminate it in our program. KEYPAD CONNECTION WITH PARALLEL PORT KEYPAD CIRCUIT See the above circuit diagram and understand the connection. Take Row 0 and column 0. A switch has four leads in which two leads are short circuited internaly to form a swich. Suppose if you press the switch then all the terminals will be short circuited. If we send C0=1 and C2=C1=C3=0 then first row become active and remain rows will be deactive. One row of all switches get HIGH (i.e, switches in row 0 , one terminal will get high). If you won't press a switch in the row then output will be zero(you can see the output terminal of the switch is short circuited to No Connection terminal of the switch. So by default the output is zero at d1,d2,d0,d3. Suppose if you press row 0 and column1 switch then d1 become HIGH and all remaining d0,d2,d3 become LOW. Here we are using a resistance with every output to see the output voltage. When no switch is pressed the output voltage will be zero and when switch is pressed output voltage will become HIGH. In all the cases you can see that bottom 2 switches of all row become HIGH and top one is not connected=LOW and other is output. So when you press the switch all become HIGH if you had selected the row for that switch. #include"bparlib.c" void main() { int i,j; for(i=0;i<4;i++) Clear_ControlPort_bit(i); Set_DataPort_input(); printf("control Port:%x",Read_ControlPort()); for(i=0;i<4;i++) { Set_ControlPort_bit(i); for(j=0;j<4;j++) { if(Show_DataPort_bit(0)) printf("\nKey pressed row:%d column:%d",i,j); getch(); } Clear_ControlPort_bit(i); } } TROUBLESHOOTING: 1. You should avoid key debouncing problem by inserting proper delays in the program. A normal person can press only 10 switches in a second (at max). So insert a delay of 100ms after pressing a switch to void keydebouncing. 2. See the appropriate keydebouncing algoritham. 3. Soldering should be proper.Better go for a redymade keypad. 4. At the starting of the program make all output ports low. Make sure when you make a particular row HIGH, other rows should be LOW. 5. IF you want to avoid keydebouncing problem and a software making then go for 74922 or 74923.


Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.