|
|||||
Chapter 3 problems |
- B3.10 - |
4-bit radix-2 /Johnson and 8-bit Johnson / radix-2 converters |
|||
|
1.- Specifications
Design the 4-bit binary radix-2 to Johnson code converter represented in Fig. 1 using a PIC18F4520 microcontroller, C language and Microchip IDE tools. Test your design using Proteus.
Fig.1. Symbol of the 4-bit binary to Johnson converter. |
The same project is proposed in D1.10 as a combinational circuit based on logic gates. The emphasis is focused therefore in learning how to poll/read digital inputs and writing digital outputs. The truth table will be solved using a behavioural plan B interpretation translated into C language, organising the hardware-software diagram so that the input and outputs variables will be saved in RAM memory.
Draw the truth table for the Bin_Johnson_4bit. Draw an example timing diagram.
2. Planning
You can solve the circuit in several steps, adding a few lines of code each time to develop and test immediately. And also the features can be added in phases:
- step #1 read only E and monitor its current value in a watch window.
- step #2 read the vector B(3..0) and monitor its current value in a watch window.
- step #3 write the variable var_J and observe LED values.
- step #4 complete the truth table and the project.
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: (update)
D_L(7..0) --> RB(7..0); D_L(11..8) ---> RC(3..0)
Pin assignment option #2:
D_L(7..0) --> RD(7..0); D_L(11..8) ---> RC(7..4)
Pin assignment option #3:
D_L(7..0) --> RB(7..0); D_L(11..8) ---> RD(7..4)
Project location:
C:\CSD\P9\Bin_Johnson_4bit\(files)
Organise the main program in our CSD way.
Propose a hardware-software diagram naming all the electrical signals, RAM variables and the software functions.
Describe all the RAM memory variables used in this project and its type.
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 plan B interpretation and the corresponding flowchart.
Fig. 3. Johnson_bin_8bit initial discussion on adapting the truth table using plan B flowcharts. |
3. Developing & 4. Testing (debugging)
- Step #1. Write the Bin_Johnson_4bit.c source code translating the function flowcharts. Start capturing only one input as in (LAB9) and visualising it in the watch window. And only then go step by 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.
Measure how long does it take to run the main loop code when using a 4 MHz and a 16 MHz quartz crystall oscillator.
|
|||||
Chapter 3 problems |
- B3.10 - |
4-bit radix-2 /Johnson and 8-bit Johnson / radix-2 converters |
|||
|
1.- Specifications
Design the 8-bit Johnson to binary radix-2 code converter represented in Fig. 1 using a PIC18F4520 microcontroller, C language and Microchip IDE tools. Test your design using Proteus.
Fig.1. Symbol of the Johnson_bin_8bit converter. |
The same project is proposed in D1.10 as a combinational circuit based on logic gates. The emphasis is focused therefore in learning how to poll/read digital inputs and writing digital outputs. The truth table will be solved using a behavioural plan B interpretation translated into C language, organising the hardware-software diagram so that the input and outputs variables will be saved in RAM memory.
Some questions and ideas to organise the project:
Draw the truth table for the Johnson_bin_8bit. Draw an example timing diagram.
You can solve the circuit in several steps, adding a few lines of code each time to develop and test immediately. And also the features can be added in phases:
- step #1 read only E and monitor its current value in a watch window.
- step #2 read the vector J(7..0) and monitor its current value in a watch window.
- step #3 write the variable var_B and observe LED values.
- step #4 complete the truth table and the project.
Copy and adapt a circuit from any of the previous projects (LAB9) and name it Enc_12_4.pdsprj. Assign pins to inputs and outputs accordingly to one of the following options (your instructior will tell you which):
Pin assignment option #1: (update)
D_L(7..0) --> RB(7..0); D_L(11..8) ---> RC(3..0)
Pin assignment option #2:
D_L(7..0) --> RD(7..0); D_L(11..8) ---> RC(7..4)
Pin assignment option #3:
D_L(7..0) --> RB(7..0); D_L(11..8) ---> RD(7..4)
Project location:
C:\CSD\P9\Johnson_bin_8bit\(files)
Organise the main program in our CSD way.
Propose a hardware-software diagram naming all the electrical signals, RAM variables and the software functions.
Describe all the RAM memory variables used in this project and its type.
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 plan B interpretation and the corresponding flowchart.
Fig. 3. Enc_12_4 initial discussion on adapting the truth table using plan B flowcharts. |
Step #1. Write the Johnson_bin_8bit.c source code translating the function flowcharts. Start capturing only one input as in (LAB9) and visualising it in the watch window. And only then go step by 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.
Measure how long does it take to run the main loop code when using a 4 MHz and a 16 MHz quartz crystall oscillator.