Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Digital Circuits ECET 146 Week 9 Professor Iskandar Hack ET 221G, 481-5733

Similar presentations


Presentation on theme: "Advanced Digital Circuits ECET 146 Week 9 Professor Iskandar Hack ET 221G, 481-5733"— Presentation transcript:

1 Advanced Digital Circuits ECET 146 Week 9 Professor Iskandar Hack ET 221G, 481-5733 hack@ipfw.edu

2 This Week’s Goals Introduction to Keyboards Development of Scan Function Development of Decode Function Incorporating Keyboard into an example design Lab 8 – Keypad to Seven-Segment-Display

3 Introduction to Keyboards Almost always built from a array of rows and columns Most use momentary close push-button switches When a switch is closed this causes a short between one column and one row Either the rows or columns are taken high (or low for an active low system) one at a time and the lines for the columns or rows are monitored for a high (or low if active low system)

4 An Example Keyboard Row Lines are on Pins 1-4 Column Lines are on Pins 5-8

5 What happens when a button is Pressed If the ‘6’ button is pressed then there will be a short between the 2 nd row (pin 2) and the 3 rd column (pin 7)

6 Scan Function The purpose of the scan function is to drive the input lines (we’ll use the rows as the inputs in this example) with a high during each clock cycle Take the first row high Then 2 nd rowThen 3 rd Last rowRepeat cycle

7 Scan Function Designed in AHDL (note in cut and paste format) SUBDESIGN scan ( clk, reset : INPUT; scanlines[3..0] : OUTPUT; ) VARIABLE ss: MACHINE OF BITS (scanlines[3..0]) WITH STATES ( s0 = B"0001", s1 = B"0010", s2 = B"0100", s3 = B"1000"); BEGIN ss.clk = clk; ss.reset = reset; TABLE ss=> ss; s0=> s1; s1=> s2; s2=> s3; s3=> s0; END TABLE; END; Note in this case I’m assigning the Outputs for each state in the declaration. Not always the most best for optimization, But makes the design a bit simpler.

8 Symbol for Scan Function

9 Decode Function First of all it must look for a high on ANY of the four return lines (this are the rows in this example) If any input is high then we know a key has been pressed. Then we look at what scan line is high and what return line are high (note there will always a high scan line because of the way we designed the scan function) and decode what key has been pressed. The decode function is unique for every keyboard and the way it’s used in the circuit – for example if we chose to have the scan lines go to the columns and the return lines go to the rows we would have a different table for the decode function. We will have two four bit inputs for this function – scan and return. We’ll have a four bit output for the keycode and an one bit output for active keypress.

10 Decode Table Guidelines First look at the keyboard layout and what keys are at each row/column position For each position you’ll output that key value when that row/column position is high You only have to include in the table the values for the row/columns of 1, 2, 4 and 8 since only one line can be high (we’re ignoring multiple key presses) at a time

11 Decode Table Column Value (scan) Row Value (return) KeyCode 111 124 147 18CLEAR (10) 212 225 248 280 413 426 449 48Help (11) 81Up (12) 82Down (13) 842 nd (14) 88Enter (15) 3 rd column has a value of 4 and 3 nd row has a value of 4

12 Decode Function AHDL (cut and paste format) SUBDESIGN decode ( scan[3..0], return[3..0] : input; keycode[3..0], keypress:output; ) BEGIN TABLE scan[],return[]=> keycode[], keypress; x,0=> 0,gnd; 1,1=> 1,vcc; 1,2=> 4,vcc; 1,4=> 7,vcc; 1,8=> 10,vcc; 2,1=> 2,vcc; 2,2=> 5,vcc; 2,4=> 8,vcc; 2,8=> 0,vcc; 4,1=> 3,vcc; 4,2=> 6,vcc; 4,4=> 9,vcc; 4,8=> 11,vcc; 8,1=> 12,vcc; 8,2=> 13,vcc; 8,4=> 14,vcc; 8,8=> 15,vcc; END TABLE; END;

13 Symbol for Decode Function

14 Complete Keypad System The complete system will have a scan function that will drive the columns (also go into the decode function) and the decode function Of course you’ll need the keypad itself One important point – you will need to place pull- down resistors on the return lines. Whenever there is no key pressed then the return lines are floating (neither high or low), thus we need to place a 1K resistor between the return lines and ground to ensure that when there no connection to VCC (through the scan lines)

15 Altera Keypad Project Keypad and pull-down resistors are external from the Altera Part Note the names of the nets and I/O

16 Symbol for Altera Keypad Project

17 Drawing of Connections between Altera and Keypad Note – Pulldown Resistors

18 Lab 8 (Will be demonstrated – Don’t Do) Using the Keyboard data sheet on the next page design a keypad system that will display whatever key is pressed (it will display 0 when no key is pressed) Note that this keypad is different from the example, so the decode table will be different Output ‘E’ for a # and ‘F’ for a * Save this project (no report due) for inclusion in Lab 9

19 Keypad Data Sheet


Download ppt "Advanced Digital Circuits ECET 146 Week 9 Professor Iskandar Hack ET 221G, 481-5733"

Similar presentations


Ads by Google