Light Sensor by Jonathan Pham & Cherub Harder ECE 4437 Dr. Glover
QTR-3RC Reflectance Sensor Array Packs three LED/phototransistor pairs Each sensor provides a separate digital I/O-measurable voltage output Sensors spaced at intervals of ″ (9.525 mm)
Light Sensor Schematic
Interfacing the Outputs to Digital I/O Lines Set the I/O line to an output and drive it high. Wait several microseconds to give the 2.2 nF capacitor node time to reach 5 V. Make the I/O line an input (high impedance). Measure the time for the capacitor node voltage to decay by waiting for the I/O line to go low.
Reflectance Time Strong Reflectance(Light) - decay time can be as low as several microseconds No Reflectance(Black) – decay time can be as high as a few milliseconds
NVIC( Nested Vector Interrupt Controller) Provides global interrupt masking( 154 interrupt sources), prioritization( 8 levels), and handler dispatching Supplies address of function to handle interrupt directly instead of putting interrupt handler in query spmu298a_TivaWare_Peripheral_Driver_ Lib.pdf spmu298a_TivaWare_Peripheral_Driver_ Lib.pdf
HWREG( hardware register) A macro that expands to the absolute address of hardware register( 32-bit address!!!) read and write Allow to read and write into the hardware register
Enable Counter
Enable Counter(cont.) NVIC_DBG_INT defined in hw_nvic.h TRCENA( Trace Enable) Must be set to 1 to use the trace/ debug blocks DWT( Data Watchpoint and Trace) Allows us to use DWT( Data Watchpoint and Trace)
Enable Counter(cont.) DWT register contains counters for clock cycles and other miscellaneous things DWT_Base + DWT _O_CYCCNT (E )– Register that contains the counter DWT_Base (E )– Register that enables counter
R EFLECTANCE S ENSOR W E W ILL U SE QTR-1RC Reflectance Sensor QTR-1RC QTR-3RC
Coding Set the I/O line to an output and drive it high Allow at least 10us for the 10-nF capacitor to charge Make the I/O line an input (high impedance) Measure the time for the capacitor to discharge by waiting for the I/O line to go low
Coding Set the I/O line to an output and drive it high Step 1:
Coding Allow at least 10us for the 10-nF capacitor to charge Step 2:
Coding Make the I/O line an input (high impedance) Step 3:
Coding Measure the time for the capacitor to discharge by waiting for the I/O line to go low Step 4:
Coding
Extras
Extras