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.

key scanning for 89c52

Status
Not open for further replies.

garg29

Advanced Member level 1
Joined
Nov 17, 2004
Messages
443
Helped
25
Reputation
50
Reaction score
10
Trophy points
1,298
Activity points
3,593
generating millisecond in 89c52

hi friends,
i have designed a unit in which i m measuring temp using ds1820 with 89c52and dispklaying the result on lcd(16 X 2) .
the unit incorporates a menu key for setting max temp value .it uses two additional keys (plus and minus) for setting the

values.

If the temp goes beyond this value a relay is activated .
Now my problem is if sometime the user presses this menu key to set the temp. the microcontroller doesnt detect the key press

cause it is busy reading ds1820 which includes some small delay routines also as required by ds1820.

how can i improve key scanning i.e.. how can i make the system or microcontroller respond to any of its key as soon as it is

pressed.it should not miss the key scanning.


open_menu:
----- coding for plus minus key
------
-----
-----
ret

loop:
jnb menu_key, open_menu

write_ds1820:
----
-----
------
also includes delay routines




read_ds1820:
-----
-----
---- also includes delay routines


display_lcd:
----
---
--
ajmp loop





this is the code sequence please help me out for proper method of key scanning.

with best regards
amit
 

89c52 keypad

Reading DS1820 should not take more than a few milliseconds. Keyscanning can be a lot slower. The tasks that you have described should not be a problem for keypad scanning. You can even scan at 100ms interval and still dont see any perceptable delay in response.
 

key scanning

Hi.. if you use low Crystal for 89C52 and have a slow and long delay for 18S20 then it could slow for keyscan.. and also it is possible to use interrupt for keymatrix.. But for your code I think it should not be a problem. Try check your delay code first or you could also try put
"jnb menu_key, open_menu " to each end routines
 

Buttons, keys or keyboards should in most cases activate an interrupt. This should put the other tasks aside for a while, read a key or button, set some flags or bytes, which will be acted upon in the main loop, and go back to where you stopped, and continue..
You will not be loosing anything ..
 

thanks for replying friends ,

"IanP " as u said the keys should generate a interrupt but can u please tell me how to generate interrupt for a whole keypad...cause 8051 has two external interrupt we can use only two keys on interrupt.... please solve my problem..
 

That depends on the cofiguation of your circuit.
If it is kepad-keyboard configuration, you can employ proper key-pad decoder IC, such as MM74C922/923, and these IC have "data available" line which can be connected to the µP interrupt.
If you have several buttons connected to several µP pins you can realize AND function by connectig diodes or multi-input AND (NAND) gates.
There is always a solution..
Regards,
IanP
 

I use keypads in a lot of projects and have almost never used interrupts. They require extra hardware and extra software. Since keyscanning does not require high speeds, you can check them every 50ms or so. The 50ms tick can be generated by the system timer besides doing other timed tasks.

Here is what you do.

Code:
main() {

  initializations();

  while (1) {
     if  (key_data != 0) {
        do the key parsing task;
     }
      read ds1820
      update LCD      
  }
}

//------------- Interrupt routine of Timer 0
timer_int interrupt 1 {   // occuring every 50ms
  reload timer;
  do other timed things
   read  buttons and set key_data to value other than zero
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top