SIBW-1Y

From Curuxa

Very simple reflectivity sensor. Useful for detecting white or black objects, but it can also measure the reflectivity of an object or its color in a greyscale.

Contents

Electronic circuit

Schematic

Bill of materials:

  • 1x CNY70 reflectivity sensor (see its datasheet)
  • 1x 18k 1/4W resistor
  • 1x 220 1/4W resistor
  • 3x Straight female headers (usually sold as 40-pin strips)
  • Some thin wire
  • Some heat shrink tubing


Wiring

Printable version: Single, Double

How it works

The most important component is the CNY70 reflectivity sensor. It contains an infrared light-emitting diode (IrLED) and a phototransistor.

Once SIBW-1Y is connected to a Main Board, as long as the Main Board is powered the CNY70's IrLED will be emitting a constant amount of light. The phototransistor allows current flow through it as it receives more infrared light. If you put a reflective object in front of the sensor most of the light emitted by the IrLED will be reflected on the object, the phototransistor will receive a lot of light so the microcontroller will read a voltage close to 0V.

If you set the microcontroller pin where SIBW-1Y is connected to as a digital input, you'll read a logic "0" when there is a reflective object very close to the sensor (less than 1cm), and a logic "1" when there is a non-reflective object or no object at all in front of the sensor.

This way you can use SIBW-1Y as a very simple black/white detector, just plug this Module to your Main Board and you'll read "1" when you put a white object in front of it, and "0" when the object is black or there is no object. You can assemble two SIBW-1Y on a robot and use them to follow a white line painted on a dark background, or a black line on a white background. You can also assemble four, five, six or more SIBW-1Y on a robot and program the Main Board so it can detect and follow complex paths painted on black and white.

You can also plug SIBW-1Y to an analog input on your Main Board, and you'll be able to measure the reflectivity of an object, or measure its color in a greyscale.

Changing the resistor values will also change the sensor's sensitivity and working range. The 18kΩ-220Ω pair is useful for detecting white and black objects, but a more sensitive sensor could be used, for example, for detecting any kind of object closer than a few centimeters.

Construction

SIBW-1Y SIBW-1Y SIBW-1Y SIBW-1Y SIBW-1Y SIBW-1Y SIBW-1Y

Test

C

The following code can be compiled using SDCC.

/*==================================================================
* Sample program for LTIND-A and SIBW-1Y using an MBP18
*
* Plug SIBW-1Y to RB3 (pin 9) and LTIND-A to RB4 (pin 10).
* The LED will light up when there is a white or reflective object
* very close to the sensor (less than 1cm, aprox)
*
* http://curuxa.org
*=================================================================*/
 
#include <MBP18.h>
 
ConfigBits1(_CP_OFF & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO);
 
#define Sensor RB3
#define White 0
#define Black 1
 
#define LED RB4
#define LedON 1
#define LedOFF 0
 
void main() {
	TRISB3=DigitalInput;
	TRISB4=DigitalOutput;
 
	while(1){
                if(Sensor==White) LED=LedON;
                else LED=LedOFF;
	}
}