User Tools

Site Tools


lab_9

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lab_9 [2019/04/08 20:11] (current)
Line 1: Line 1:
 +====== Lab 9: Using Fixed- and Floating-Point in Embedded Systems ======
 +===== Overview =====
  
 +In this lab you shall work with floating point and fixed point numbers. You shall also create and use a lookup table.
 +
 +===== Specifications =====
 +
 +The potentiometer/​ADC and seven segment display shall be used in this lab.
 +
 +Convert the values read from the ADC into a floating point value in the range of 0.0 and 1.99951171875 (which is 4095/2048). Then convert the floating point number into a (1.5) fixed point representation. Display the (1.5) fixed point representation on the seven segment display.
 +
 +Use "​unsigned char" or "​u8"​ for the fixed point number. Technically it shall be a (3.5) fixed point representation,​ but the value should always be below 2 so it is essentially (1.5). The seven segment display should show a decimal point after the first digit, e.g. 1.96875.
 +
 +You shall use a lookup table to convert the six bits of the (1.5) fixed point number into seven segment display digits. Here we discuss two possibilities:​
 +  - A 64 entry table where each entry is an array of the six digits that should be displayed.
 +  - A 32 entry table where each entry is an array of the five fractional digits (the digits after the decimal) that should be displayed, and the value of the whole number is determined by the sixth bit.
 +Do you see how we were able to cut the number of entries in the table in half? The sixth bit is all that is necessary to determine if the whole number should be 0 or 1. This bit has no influence on the digits displayed for the fractional part of the number. Thus, we can cut out this sixth bit when looking something up in the table and use only five bits. 
 +
 +Based on the discussion in the previous paragraph, create a 32 entry lookup table that shall be used to lookup what to display on the seven segment display for the five fractional digits of a given (1.5) fixed point number'​s decimal value. Each entry in the table shall be an array of the 5 digits that need to be displayed (or you can put things into a more condensed form).
 +
 +The ADC should be read 10 times per second. The seven segment display should be updated at a proper speed to appear normal to the human eye.
 +
 +Use a task scheduler. You should have at least two tasks/state machines: one for the ADC and one for the seven segment display.
 +
 +===== Notes =====
 +
 +Programs like Excel or Matlab may help you to quickly generate all decimal representations of all fractions from 0/32 to 31/32 for your lookup table.
 +
 +Want to edit multiple lines at once in the SDK? Try Alt+Shift+A! This may help when you are creating your lookup table. The Xilinx SDK is based on Eclipse and this works in Eclipse as well.
 +
 +You may use more than one lookup table. For example, you might have one with the fractional digits in decimal and another that is used to lookup what to write to the seven segment display GPIO to display that digit. The code below demonstrates this.
 +
 +<​code>​
 +const u8 lookupTable[32][5] = {
 +{0, 0, 0, 0, 0}, // .00000
 +{0, 3, 1, 2, 5}, // .03125
 +... // Entire table is not shown in this example
 +{9, 3, 7, 5, 0}, // .93750
 +{9, 6, 8, 7, 5}  // .96875
 +};
 +// LUT to convert hexadecimal values to values that can drive the seven segment display
 +const u16 segLUT[16] = {DIGIT0, DIGIT1, DIGIT2, DIGIT3, DIGIT4, DIGIT5, DIGIT6, DIGIT7,
 + DIGIT8,​ DIGIT9, DIGITA, DIGITB, DIGITC, DIGITD, DIGITE, DIGITF};
 +</​code>​
 +===== Grading =====
 +Pass off with the TA and turn in your code(//​unaltered//​ skeleton code may be condensed to a single line to indicate their location) and feedback(spec ambiguities,​ major bugs, time to complete).
lab_9.txt ยท Last modified: 2019/04/08 20:11 (external edit)