Anda di halaman 1dari 10

INDUSTRIAL ELECTRONICS AND AUTOMATICS ENGINEERING DEGREE

Embedded systems:
Report 2

Laboratory 2: Embedded System LED7SEG

Professor: Enrique Cantó Navarro

Students: Carlos Agorreta, Ramon Estalella


Embeded Systems Laboratory 2 Report

Content
Resume of our final embedded system............................................................................................................... 3
Manual of use: ................................................................................................................................................. 3
XPS hardware development ................................................................................................................................ 4
The external 7 segment board ........................................................................................................................ 4
SDK Software Development ................................................................................................................................ 4
Disp.h and Disp.c ............................................................................................................................................. 5
Main................................................................................................................................................................. 7
Photos of the Embedded System Working.......................................................................................................... 9
Conclusions ........................................................................................................................................................ 10

2
Embeded Systems Laboratory 2 Report

Resume of our final embedded system


Short explanation of the system:

Our system controls an external 4 digit 7-segment board which features a number displayed in it, which can
be controlled with the PC’s keyboard through the USB to UART driver.

The digits are displayed in hexadecimal format, stored in a 16-bit variable just like demanded. We have
implemented the on/off display mode as well as the show/hide left-side zeros mode, which can be changed
with a switch or with the PC’s keyboard through the terminal.

The display is driven with interrupts, and we have kept the LEDs blinking system, just because we have
inherited from the project in Lab 1b.

Figure 1. Development board with the external board implementing the 7 segment display attached

Manual of use:
We programmed it so that the displayed hexadecimal value can be changed using the “4” and “5” keys from
the keyboard.

The display on/off is done by the switches and the zeros on the left of the displayed number too.

3
Embeded Systems Laboratory 2 Report

XPS hardware development

Figure 2. Hardware configuration with the new peripherals

We had to add new peripherals in order to control the 7 segment display. We decided to use two of them, one
called “digit_0” to alternate between each individual display and “set_segments_0” which has 8 outputs, 7 for
the display plus 1 for the decimal point. The combination of this two new peripherals will allow us to fully
control the 7 segment display.

The external 7 segment board


We had to configure the MHS and the UCF file just like we did in Lab 1b. In order to know which pins were
used by the external board implementing the 7 segment display, we consulted its user manual from the
Moodle’s course.

SDK Software Development


The root location of the project is in edk13.3_20180511_1757\SDK\p2.

We were required to create the needed C++ classes and implement them. In other to properly control the new
peripherals and in turn control the 7 segment display.

4
Embeded Systems Laboratory 2 Report

Disp.h and Disp.c

Figure 3. disp.h file containing the declaration of the CDisplay class

The “disp.h” file contains the CDisplay C++ class declaration. This file is included in the main file in order to
use the CDisplay C++ class and be able to control the 7 segment display.

5
Embeded Systems Laboratory 2 Report

Figure 4. disp.cc file

In Figure 4 we can see the whole disp.cc file which contains the definition of the CDisplay C++ class that we
created to control the 7 segment display.

On the constructor function we set the base addresses of our I/O peripherals that control the 7 segment
display. We also initialize “Data” which is the variable containing the 16 bit number that we will display in
hexadecimal format through the 7 segment display. We also initialize “zeros” and “on” which will allow us to
display the left side zeros and turn on and off the display.

The “to7seg” function implements the truth table used to convert from the number to the 7 segment code.
We will have to do that for each digit, which in hexadecimal means for each 4 bits.

The table is implemented in a vector containing the correct combination of each single LED for each possible
number to display. We just pick the position corresponding to that value.

6
Embeded Systems Laboratory 2 Report

The function “Refresh” is the one called periodically and is interpreting the “zeros”, “on” and “Data”
information to display the correct value in the way chosen by the user. In this function first we decide,
depending on the size of our variable “Data” how many displays we’ll need to use from our four 7 segment
displays, we set “b” accordingly. Then we use b to shift bits (4 at a time) and rotate the display used. The high
speed rotation of the four 7 segment displays creates the persistence effect on our eyes and we see them all
powered on at the same time. In reality they are never turned on simultaneously.

Main

Figure 5. Includes, defines, global variables and function definitions in main.cc file

7
Embeded Systems Laboratory 2 Report

In Figure 5 the main difference we see from the laboratory 1b is that we have enhanced functionality in the
config_from_switch() function, consisting on checking the state of the now switches to decide whether to
turn on/off the 7 segment display and whether to show zeros on the left side of it or not.

In config_from_uart() function the enhanced functionality resides in having numbers 4 and 5 of the keyboard
to change the displayed value on the 7 segment display, -10 and +10 respectively.

In Figure 6 we can see that we didn’t change much regarding the ISRs and the actual “main()”, we just added
the “Display.Refresh” inside the timer interrupt service routine.

Figure 6. Interrupt service routines and main() function

8
Embeded Systems Laboratory 2 Report

Photos of the Embedded System Working

Figure 7. 7 segment display working properly

Figure 8. Testing the new functionality with the keyboard

9
Embeded Systems Laboratory 2 Report

Conclusions

In this last laboratory we managed to independently choose and add a new peripheral to an already existing
system. On top of that we created from scratch the necessary code to implement the functionality that the
new peripheral added to our system.

FPGAs and the way we used them in this subject make for an exceptional development tool for embeded
systems.

10

Anda mungkin juga menyukai