UPC EETAC Bachelor's Degree in Telecommunications Systems and in Network Engineering EEL

Chapter 3 problems

      - B3.6 -

12-to-4 encoder




1. Specifications

The project objective is to design an encoder Enc_12_4 similar to the one presented in tutorial Enc_10_4 using a µC. For instance, the application can be integrated as a subsystem in a professional PBX door phone with dialing keypad as represented in Fig. 1. The device has to generate the 4-bit code of the clicked key. BCD codes for keys from 0 to 9, "1010" for the hash symbol "#" and "1011" symbol for the asterisk symbol "*". Group select output (GS) has to be held high when any key is pressed. The encoder also has enable input (Ei) and enable output Eo to detect when it is disabled and when is active but no one is pressing keys. Finally, a 7-segment output will represent the code of the key pressed.


Fig. 1. The keyboard that that has to be interfaced to a commercial PBX and the commercial reference of the diagram

The emphasis is set therefore in learning basic polling digital inputs and writing digital outputs. The truth table will be solved using a behavioural plan B interpretation in C language, organising the hardware-software diagram so that the input and outputs variables will be held in RAM memory. Your planning has to be similar to the one discussed in Chapter 1, but using C code instead of VHDL. The symbol for the Enc_12_4 that will have priority high as usual in this kind of devices is represented in Fig. 2.


Fig. 2. Enc_12_4 symbol and the idea of designing it using a µC. You can solve in a step #1 the circuit with GS, Ei, Eo, and the BCD outputs Y; and later in a step #2 you can add the feature of the 7-segment interface including the other S_L signals.

Some questions to organise the project:

- Draw the truth table for this Enc_12_4.

- Propose a hardware-software diagram naming all the electrical signals, RAM variables and the software functions.  

- Hardware. Copy and adapt a circuit from any of the previous projects and name it Enc_12_4.pdsprj. Assign pins to inputs and outputs.

- Software. Explain how to configure the µC in init_system(). List all RAM variables required and their type.

- Organise using a flowchart the interface function read_inputs().

- Organise using a flowchart the interface function write_outputs().

- Infer the truth_table() software function using a behavioural interpretation and the corresponding flowchart.

- Write the Enc_12_4.c. source code translating the function flowcharts.

- Start a software IDE project for the target microcontroller PIC18F4520 and generate the configuration files €œ.cof€ and €œ.hex€ after compilation. Discuss the project summary: % of ROM used for the code, number of RAM bytes used, etc.

- Find the RAM memory position of the variable Var_D. How many bytes does it occupy?

- Test. Do it interactively in Proteus every time a few lines of code are added to the source file.

- Measure how long does it take to run the main loop code when using a 4 MHz oscillator.