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

Chapter 3 problems

      - B3.7 -

- 2-digit multiplexed 7-segment display

Products

B3.6

B3.8


1.- Specifications

We want to use the same 7-segment decoder function for driving multiple common-anode displays. To keep it simple, we implement only a 2-digit multiplexed 7-segment display circuit. In this way, we will multiplex the information to be represented between Digit 1 and Digit 0. As seen in Fig. 1, only one display is active at a given time controlled by input D. 

Using the same principle, it is easy to imagine how to expand the circuit for driving a larger number of common-anode 7-segments displays. Thus, this idea on multiplexed display systems or scanning display controllers is generalised in tutorial MDS

The same project is proposed in D1.7 as a combinational circuit based on logic gates. This Hex_7seg_MUX_2digit.pdsprj simulation in Proteus, give you a better idea how the multiplexer works. 

2-digit 7-segment display multiplexed system

Fig. 1. Symbol of Hex_7seg_MUX_2digit.

Complete the symbol in Fig. 1 and the circuit's truth table in Fig. 2 adding a new input E (enable) that blank the two digits when active.

Truth table

Fig. 2. Initial idea of the circuit truth table.

Draw an example of timing diagram.

Picture report

Fig. 3. Timing diagram example.

 

2. Planning

You will solve the circuit in several steps, adding a few lines of code each time to develop and test immediately to debug any error before adding more code. For instance:

- step #1 read only D and monitor its current value var_D in a watch window.

- step #2 read only E and monitor its current value.

- step #3 read the vector H(3..0) and monitor its current value in a watch window. In this way, your read_inputs() function will be validated.

- step #4 Imagine a given value for the variable that will control the display anodes var_AN, write it in the corresponding pins and observe LED values.

- step #5 Complete and validate your function write_outputs().

- step #6 complete the truth_table() and the project.

 

A) Planning hardware

Copy and adapt a circuit from any of the LAB9 projects and name it Bin_Johnson_4bit.pdsprj. Assign pins to inputs and outputs accordingly to one of the following options (your instructior will tell you which):

Pin assignment option #1:

E --> RA3; D --> RB7; H(3..2) ---> RC(3..2); H(1..0) ---> RD(7..6); AN(1..0) ---> RA(1..0);  a_L ---> RB6;  b_L ---> RB5; c_L ---> RB4; d_L ---> RB3; e_L ---> RC7; f_L ---> RC6; g_L ---> RC5 

Pin assignment option #2:

E --> RA1; D --> RA0; H(3..2) ---> RD(7..6); H(1..0) ---> RC(3..2); AN(1) ---> RA3;  AN(0) ---> RB7; a_L ---> RC7;  b_L ---> RC6; c_L ---> RC5; d_L ---> RC4; e_L ---> RB6; f_L ---> RB5; g_L ---> RB4 

Pin assignment option #3:

E --> RD7; D --> RD6; H(3..2) ---> RA(1..0); H(1..0) ---> RC(7..6); AN(1) ---> RA2;  AN(0) ---> RC5; a_L ---> RB3;  b_L ---> RB2; c_L ---> RB1; d_L ---> RD5; e_L ---> RD4; f_L ---> RD3; g_L ---> RD2 

Project location:

 C:\CSD\P9\Hex_7seg_MUX_2digit\(files)

 

B) Planning software

Organise the main program in our CSD way. Copy and adapt a circuit from any of the LAB9 projects and name it  Hex_7seg_MUX_2digit.pdsprj.

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

Picture report

Fig. 3. Hardware-software diagram. 

Describe all the RAM memory variables used in this project and its type.

Explain how to configure the µC in init_system().

Organise using a flowchart the interface function read_inputs().

Picture report

Fig. 4. Reading inputs.

Organise using a flowchart the interface function write_outputs().

Picture report

Fig. 5. Writing outputs.

Infer the truth_table() software function using a behavioural plan B interpretation from the corresponding flowchart.

Picture report

Fig. 6. Shifter_4bit initial discussion on adapting the truth table using plan B flowcharts.

 

3. Developing & 4. Testing (debugging)

- Step #1. Write the  Hex_7seg_MUX_2digit.c source code translating the function flowcharts. Start capturing only one input as in (LAB9) and visualising it in the watch window as a RAM variable as indicated in the sequence of steps above in the planning section. And only then go to the next step developing & testing more inputs. 

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.

Note: Step-by-step tactical approach for developing and testing the project: Read one input at a time and run to check that the voltage value is correctly captured as a valid digital value in RAM memory. Write one output at a time and run to check that your code is correct to light the LED connected at the output pin.

Add a few lines of code every time, compile and run the test intereactively to check results watching variables.

Picture report

Fig. 7. Example pictures demonstrating how the circuit works.

Measure how long does it take to run the main loop code when using a 4 MHz and a 16 MHz quartz crystal oscillator.

Picture report

Fig. 8. Loop execution time measurements.