CSE466 Lab 2 - Section D (Extra Credit): “Light Meter” 

NOTE: If completed, this Extra Credit section is worth an additional 20% of the total possible points for your Lab2 grade. This Extra Credit section has an ESTIMATED completion time of approximately 2-3 hours.

Objective:

Create a dynamically calibrated light meter by reading the analog value coming from the photoresistor. The values may not swing all the way from 0 to 0xff, but you will calibrate it to match the light scale listed in Step 2. One of your buttons should toggle between the raw ADC output displayed in hex (8 MSBs), and the scaled Weston light meter units. The other button should toggle you through a state machine that allows you to calibrate a minimum light level and a maximum light level.

In this section you will learn the following:

Helpful Hints

            Scaling should be simple:

 

                ADC value - Min Value      Index of output value
                ------------------------------- = ------------------------------
                Range (Max - Min)              Size of Light Scale
 

            Do not use floating point math!

 

Suggested Steps:

 

1.      Build a calibration state machine using two buttons. 

Button 1 will be used for the calibration sequence.

Button 2 toggles between raw data and calibrated/scaled data.

2.     Implement a lookup table with the following values to be displayed on your 7-segment LED display. The values in this table should the only values displayed when in calibrated/scaled data. Values of the calibrated scale are:

 

0.1       Min. value

0.2

0.3

0.4

0.6

0.8

1.2

1.6

2.4

3.2

4.9

6.5

9.5

13

19

25

38

50

75

99        Max. value

 

3.     Write a function to scale the ADC data bounded by the calibrated range (Step 1) to the table of values in Step 2. From the maximum and minimum values obtained during the calibration (Step 1) a range of reading values is established (possible examples are 5-200, 51-98, 110-114, 215-255, etc). A conversion should automatically occur to convert the raw ADC values and output the calibrated values in Step 2 based on the calibration information collected in Step 1.  Here are the specifics:

 

4.     If values are noisy, average 8 or 16 readings.

Deliverables:

  1. Demonstrate your light meter to a TA.
  2. Turn in a hardcopy of your C code