Natalie C. Landon-Brace edited PIC.tex  about 10 years ago

Commit id: d0287e7402a5343395f0bfd0f883029ac1d08f5b

deletions | additions      

       

Determining if the light is on required effectively the same method as determining whether is was present, with a few exceptions. Firstly, all variables involved in light testing were initialized to 0 at the beginning of the LED testing sequence. Secondly, a light was not checked if it had been previously determined to be missing. Finally, 254 data points were taken for the voltage of the light once the switches had been activated to see how many times the voltage measured over the threshold. If the threshold was exceeded at least 10 times, the light was determined to be on and was tested for flikcering. If not, the light was recorded as an LED fail, and the next light was selected. Code for the LED\_TEST subroutine is shown in Figure \ref{fig:LED_TEST1} and Figure \ref{fig:LED_TEST2}.  \subsubsection{Determining if the LED is Flickering}  Determining if the candlelight is flickering requires a little bit more math. The first step is to obtain a "reference voltage" which will be maintained for the remainder of the test. The reference voltage was the first data point for voltage obtained from the light. It is then compared to the new, incoming voltage from the ADC. If the reference is greater, the values in the "reference" register and the "temporary" (new voltage) register are exchanged. exchanged (code in Figure \ref{fig:FLICKER_SWAP}.  The reference is then subtracted from the temporary voltage, and the result is stored in the temporary voltage register. The code to this point can be seen in Figure \ref{fig:FLICKER_TEST1}. The temporary voltage register is compared to the "Flicker Threshold" which is 0.25 V. Comparison code can be seen in Figure \ref{fig:FLICKER_COMPARE}. The flicker threshold is the difference between voltage readings from the phototransistor when the light is on versus flickered off. Each time the threshold is exceeded, the flicker\_flag increments. Once the flicker\_flag exceeds 10, the light is determined to have passed. If it does not pass 10 on the first run through the loop of 254 data points, the process is repeated up to 10 times for a total of 2540 data points. If at this time the flicker flag still does not exceed 10, the light is assigned a flicker fail status. This code can be seen in Figure \ref{fig:FLICKER_TEST2}. The combined test for LED on and LED flickering is repeated for all the lights by stepping through different selection signals for the mux (from 0 to 9). \subsection{Program Details}  \subsection{Suggestions for Improvement}