QRD1114IR Sensor

Not rated 6,969

QRD1114IR Sensor
QRD1114IR Sensor

Initially, a PIR Motion Sensor was selected for testing to detect motion in front of the sensor; however, it proved to be insufficiently sensitive. Therefore, a QRD1114 IR Sensor was considered as a substitute. In this test, both sensors were utilized as digital and analog inputs to compare their sensitivity. Objects or surfaces must be within 0.5 cm for detection. This circuit does not differentiate between white and black objects but indicates when an object is at the edge of a surface. To detect differences between white and black surfaces, the input pin on the microcontroller should be connected to an analog-to-digital converter (ADC) or another device capable of interpreting varying voltage levels. A black surface will produce a voltage between 0V and 5V, while a white surface will yield a voltage of 5V. Experimentation is required to determine the specific voltage levels for black and white surfaces. Object and surface detection has been tested, and efforts are ongoing to establish black and white differentiation. The schematic illustrates the connection of the QRD1114 IR Sensor to a PIC18F452 microcontroller. Port D.1 is designated for digital input from the QRD1114's signal, while Port B.7 is used for output to control an LED. Pulse-width modulation (PWM) is employed to gradually illuminate the LED, with brightness dependent on the variable "adcVar," which is directly or inversely proportional to the distance between the reflecting surface and the sensor. In the first code configuration, when the reflecting surface is beyond the detection range (0.5 cm), the sensor reads the maximum adcVar value (theoretically 1023, practically 1016), with a minimum value of 30 instead of 0.

The circuit utilizes a PIC18F452 microcontroller, configured for ADC operations with a 10-bit resolution. The oscillator frequency is set to 20 MHz, and the ADC clock source is defined as RC. The sampling time for the ADC is established at 50 microseconds. The TRISA register is set to all inputs, allowing for analog readings on PORTA. The ADCON1 register is configured to set PORTA as analog input, with the output justified to the right.

The main program loop begins by reading the ADC value from channel 0 into the variable adcVar. The serial output on PORTC.6 displays the decimal value of adcVar, followed by a carriage return. The duty cycle for PWM control is calculated based on adcVar, with two different code configurations available. In the first configuration, the duty cycle is set directly proportional to adcVar, while in the second configuration, it is inversely proportional, allowing for flexible control of LED brightness based on the detected distance from the sensor. This setup enables effective object detection and surface differentiation in various applications, including robotics and automation systems.Initially I chose another infrared sensor for test, PIR Motion Sensor, which was to detect any motion in front of the sensor but it turened out not so sensitive. So that I looked at this QRD1114 IR Sensor for substitute. In this test, I used both as digital and analog input to see what difference it has and how sensitive it is.

Object or surfaces must be within 0. 5cm. This circuit will not distinguish between white and black objects but it will let you know when you are at the edge of a surface. If you want to detect the difference between white or black surfaces, in the circuit the Input pin on the Micro should be an analog to digital converter or some other device that can utilize variable voltage levels. A black surface will give a voltage some where between 0V and 5V and white surfaces will give a voltage of 5V.

Determining the voltage level for your black and white surfaces will require experimentation. I have tested object/surface detection and stiil try to figure out Black/White difference detection. Here is the schematic of how I hooked up QRD1114 IR Sensor to PIC18F452. Portd. 1 is used for digital input from QRD1114 IR Sensor`s signal while portb. 7 is for output to light a LED. Here I use PWM to let LED light gradually. The lighness depends on the variable "adcVar", which is in direct-ratio (code 1) or inverse-ratio (code 2) to the distance between reflecting surface and the sensor. In code one, when the reflecting surface is out of the range (0. 5cm), the sensor will read adcVar in the maximum (It should be 1023 in theory but it`s 1016 in fact. Also, the minimum is 30 instead of 0. DEFINE OSC 20 DEFINE ADC_BITS 10 ` Set number of bits in result DEFINE ADC_CLOCK 3 ` Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ` Set sampling time in uS TRISA = %11111111 ` Set PORTA to all input ADCON1 = %10000010 ` Set PORTA analog and right justify output portb.

7 adcVar VAR word dutyCycle var byte main: ADCIN 0, adcVar serout2 portc. 6, 16468, [DEC adcVar, 13] dutyCycle = adcVar/5 pwm portb. 7, dutyCycle, 10 goto main DEFINE OSC 20 DEFINE ADC_BITS 10 ` Set number of bits in result DEFINE ADC_CLOCK 3 ` Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ` Set sampling time in uS TRISA = %11111111 ` Set PORTA to all input ADCON1 = %10000010 ` Set PORTA analog and right justify output portb. 7 adcVar VAR word dutyCycle var byte main: ADCIN 0, adcVar serout2 portc. 6, 16468, [DEC adcVar, 13] dutyCycle = (1023-adcVar)/5 pwm portb. 7, dutyCycle, 10 goto main 🔗 External reference