1 / 42

ECE 447: Lecture 10

ECE 447: Lecture 10. ECE 447: Lecture 12. Keypads. ECE 447: Matrix Keypad. ECE 447: Matrix Keypad Microcontroller Interface. ECE 447: Matrix Keypad - Scanning. 1. 1. 1. 1. ECE 447: Matrix Keypad - Scanning. Matrix Keypad - Scanning. 1. 1. 1. 1. ECE 447: Matrix Keypad - Scanning.

mohr
Download Presentation

ECE 447: Lecture 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECE 447: Lecture 10 ECE 447: Lecture 12 Keypads

  2. ECE 447: Matrix Keypad

  3. ECE 447: Matrix Keypad Microcontroller Interface

  4. ECE 447: Matrix Keypad - Scanning 1 1 1 1

  5. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 1 1

  6. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 0 1 1 1

  7. Matrix Keypad - Scanning ECE 447: Matrix Keypad - Scanning 1 0 1 1

  8. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 0 1

  9. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 1 0

  10. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning PC0 PC1 PC2 PC3 PC4 PC5 PC6

  11. ECE 447: Matrix Key Codes F0 11110000 outputs inputs

  12. ECE 447: Key Scanning Function while (1) { do ( PORTC = "XXXX0000" while ( PORTC = "X111XXXX"); c=decode_key(); ..... do something dependent on the key being pressed... PORTC = "XXXX0000" while (PORTC != "X111XXXX") /* do nothing */ } Wait until any key pressed Decode the key being pressed Wait until all keys released

  13. ECE 447: Key Scanning Function int decode_key() { PORTC = "XXXX1110" if ( PORTC != "X111XXXX”) return decode_output (PORTC, 1) else { PORTC = "XXXX1101" if ( PORTC != "X111XXXX") return decode_output(PORTC, 2) } else { PORTC = "XXXX1011" if ( PORTC != "X111XXXX") return decode_output (PORTC, 3) } else { PORTC = "XXXX0111" if ( PORTC != "X111XXXX") return decode_output (PORTC, 4) else return NONE_KEY_PRESSED; } check Row 1 check Row 2 check Row 3 check Row 4

  14. Possible Key Decoding Procedure (3) ECE 447: Key Scanning Function Decoding a column XCCCXXXX • Three bits of interest • Three combinations valid (“110”, “101”, “011”) • Decoding column possible

  15. F0 11110000 inputs ECE 447: Matrix Key Codes

  16. F0 11110000 outputs ECE 447: Matrix Key Codes

  17. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 0 0 outputs 0 0 1 inputs 1 1

  18. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 0 0 outputs 0 0 1 inputs 1 1

  19. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 0 0 outputs 0 0 1 inputs 1 1

  20. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 0 0 outputs 0 0 1 inputs 0 1

  21. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 outputs 1 0 1 inputs 0 1

  22. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 outputs 1 0 1 inputs 0 1

  23. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 outputs 0 1 1 inputs 1 0

  24. ECE 447: Matrix Keypad - Scanning Matrix Keypad - Scanning 1 1 outputs 0 1 1 inputs 1 0

  25. Simplified Key Decoding Procedure (4) ECE 447: Key Scanning Function – Alternative decode_key() { unsigned char keys = [NONE, ONE, TWO, …, TWELVE]; for (i=0, i<=12, i++) { PORTC = keys[i] if (PORTC == keys[i] return i; } return UNKNOWN; }

  26. ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE NONE F0 11110000 ECE 447: Matrix Key Codes

  27. ECE 447: Key Scanning Function – No Debounce while (1) { do ( PORTC = "XXXX0000" while ( PORTC = "X111XXXX"); c=decode_key(); ..... do something dependent on the key being pressed... PORTC = "XXXX0000" while (PORTC != "X111XXXX") /* do nothing */ } Wait until any key pressed Decode the key being pressed Wait until all keys released

  28. ECE 447: Key Bounce Key Bouncing key bounce, tBOUNCE key bounce, tBOUNCE typically, tBOUNCE < 10 ms

  29. ECE 447: Key Bounce KeypadBouncing key bounce, tBOUNCE key bounce, tBOUNCE typically, tBOUNCE < 10 ms NONE NONE NONE NONE

  30. ECE 447: Key Bounce Keypad Debouncing in Software key bounce, tBOUNCE key bounce, tBOUNCE typically, tBOUNCE < 10 ms NONE NONE NONE NONE wait debouncing period wait debouncing period wait until all keys released wait until any key pressed wait until any key pressed decode_key; action dependent on the key

  31. Key Decoding Procedure (7) ECE 447: Key Scanning Function – with Debounce while (1) { while (key_decode() == NONE) /* do nothing */ ; wait debouncing period(); c=decode_key(); ..... do something dependent on the key being pressed... while(key_decode()!=NONE) /* do nothing */ ; wait debouncing period(); } Wait until any key pressed Decode the key being pressed Wait until all keys released

  32. ECE 447: 2 of 7 Keypad 2 out of 7 Keypad C

  33. ECE 447: 2 of 7 Keypad Microcontroller Interface

  34. ECE 447: 2 of 7 Keypad Scanning 0 C

  35. ECE 447: 2 of 7 Keypad Scanning 2 out of 7 Keypad - Scanning 1 1 1 0 1 0 1 0 C

  36. ECE 447: 2 of 7 Keypad Scanning Function decode_key() { unsigned char keys = [NONE, ONE, TWO, …, TWELVE]; for (i=0, i<=12, i++) { PORTC = keys[i] if (PORTC == keys[i] return i; } return UNKNOWN; }

  37. ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE NONE ECE 447: 2 of 7 Key Codes

  38. ECE 447: 2 of 7 Keypad Microcontroller Interface

  39. ECE 447: 2 of 7 Keypad Scanning Function (Simplified) decode_key() { unsigned char keys = [NONE, ONE, TWO, …, TWELVE]; code = PORTC for (i=0, i<=12, i++) { if (code == keys[i] return i; } return UNKNOWN; }

  40. ECE 447: 2 of 7 Keypad Scanning Function while (1) { while (decode_key() == NONE) /* do nothing */ ; wait debouncing period(); c=decode_key(); ..... do something dependent on the key being pressed... while(decode_key()!=NONE) /* do nothing */ ; wait debouncing period(); } Wait until any key pressed Decode the key being pressed Wait until all keys released

  41. ECE 447: 2 of 7 Keypad Hardware Debounce Key Debouncing in Hardware

  42. ECE 447: 2 of 7 Keypad Hardware Debounce Key Debouncing in Hardware Capacitors associated with all pull-up resistors

More Related