light sensors ece 4437 dr. j. glover 10-15-2015 team 9: jitin george zachary freeman

13
Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Upload: christal-bell

Post on 20-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Light SensorsECE 4437

Dr. J. Glover10-15-2015

Team 9:Jitin George

Zachary Freeman

Page 2: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Overview

QTR-1RC Reflectance SensorReflectance timeInitialize Pins for I/OTimerInterfacing outputs to digital I/O Data CheckWorks Cited

Page 3: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

QTR-1RC Reflectance Sensor• Carries a single infrared LED and phototransistor pair

• The LED current-limiting resistor delivers approximately 17 mA to the LED when VIN is 5 V

• The phototransistor uses a capacitor discharge circuit and the discharge time is used to take an analog reading of the reflected IR

Shorter capacitor discharge time is an indication of greater reflectance

Page 4: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Reflectance Time

• Strong Reflectance (White) - decay time can be as low as several microseconds

• No Reflectance (Black) – decay time can be as high as a few milliseconds

Page 5: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Initialize Pins for I/O

void PortE_Init(void){ volatile unsigned long delay; SYSCTL_RCGCGPIO |= 0x00000010; // Activate clock for Port E delay = SYSCTL_RCGCGPIO; // Allow time for clock to start GPIO_PORTE_CR_R = 0x10; // Allow changes to PE4 GPIO_PORTE_AMSEL_R = 0x00; // Disable analog on PE GPIO_PORTE_PCTL_R = 0x00000000; // GPIO on PE GPIO_PORTE_AFSEL_R = 0x00; // Disable alt funct on PE7-0 GPIO_PORTE_DEN_R = 0x10; // enable digital I/O on PE4}

Page 6: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Timer

• Initialize Timer

SYSCTL_RCGCTIMER = 0x00000001; // Initializing Timer0

• Clear residual bits TIMER0_TAMR &= ~ 0x00000000;

• Write the GPTM Configuration Register (GPTMCFG) with a value of 0x00000001

TIMER0_CFG = 0x00000001;

Page 7: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Timer• Set the TnEN bit in the GPTMCTL register to enable the timer and

start counting

TIMER0_CTL |= 0x01; // Starts the timer

Page 8: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Interfacing Outputs to Digital I/O

• Set the I/O line to an output and drive it high

Page 9: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Interfacing Outputs to Digital I/O

• Wait 10 microseconds for the 10[nF] capacitor to charge

Page 10: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Interfacing Outputs to Digital I/O

• Make the I/O line an input (high impedance)

volatile unsigned long start, end, meas; start = TIMER0_TAR; • Wait for the I/O line to go low

Page 11: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Interfacing Outputs to Digital I/O • Read end time

end = TIMER0_TAR;

• Calculating discharge time of the capacitor

meas = end – start;

Page 12: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Data Check

Page 13: Light Sensors ECE 4437 Dr. J. Glover 10-15-2015 Team 9: Jitin George Zachary Freeman

Works Cited

[1] J. Valvano and R. Yerraballi. (2014). Chapter 6: Parallel I/O ports [Online]. Available: http://users.ece.utexas.edu/~valvano/Volume1/E-Book/C6_MicrocontrollerPorts.htm

[2] J. Pham and C. Harder. (2014). Light Sensor [PowerPoint].

[3] Polulu Robotics & Electronics. QTR-1RC Reflectance Sensor [Online]. Available: https://www.pololu.com/product/959