Retro-Reflective Photoelectric Sensor

Submitted by Bert on Wed, 05/13/2020 - 16:04

Retro-reflective means that the light hitting the reflector is snet back in the same direction as where the light came from. This means that the sensor detecting the light can be very close to the light source.

A retro-reflective sensor can detect an object moving through a light beam.

The sensor uses infra red light which makes the ligth invisible to the naked eye. It also means that cold objects are easier to detect and that the sensor is easier to use in a cold environment.

Brand : OMRON

Product Nr : E3Z-B81

Specifications

  • Minimum distance : 80mm
  • Maximum distance : 500mm
  • Output : PNP
  • Output current : 30mA max
  • Input voltage : 12V - 24V +10%
  • Operating temperature range : -25° → +55°C

Remark : The output is PNP which means that when the sensor sends a high signal, the ouput is pulled high to the input voltage. So when you use 24V as the input voltage and you put your hand in the light beam to couse the signal to go high, 24V is put on the signal pin. An Arduino does not like that (don't ask how I know) so you need a voltage devider on the output pin to get the signal to a usable level.

When you look closely at this picture you can see the light source and the sensor behind the red plastic cover.

Typical application for Arduino

The light sensor is connected through connector J1. It needs 24V to work. The Arduino label is conneted to an Arduino digital input pin.

The output of the sensor is floating when nothing is detexted en 24V when the light beam is interrupted. Of course the Arduino does not like 24V on its input pins so we need to use a voltage devider made with R1 and R2. The 24V is spread over both resistors. The voltage between the two is calculated by the furmula (24V / (47K + 10K)) * 10K = 4.2V. So when the light beam is interrupted, the voltage on the Arduino connection is 4.2V. As this is a digital connection, the Arduino will rigard this as a HIGH signal.

Arduino sample code

The code below uses the built in LED to indicate whether something is detected. The LED switches on when the light beam is interrupted. At the same time it provides an indication on the Serial port.

  1. //Define the pin assignment
  2. //The light sensor is connected to pin 7
  3. #define LIGHTSENSORPIN 7
  4.  
  5. void setup() {
  6. //prepare the seerial port
  7. Serial.begin(9600);
  8. //Set input or output modes for the used ports.
  9. //LED_BUILTIN is a standard pin assignmet for Arduino for the LED on the board. It uses pin 13. This pin is set to output
  10. pinMode(LED_BUILTIN, OUTPUT);
  11. //Define the sensor pin as an input
  12. pinMode(LIGHTSENSORPIN, INPUT);
  13. //Let the user know through the serial port the setup is done
  14. Serial.println("Setup done");
  15. }
  16.  
  17. void loop() {
  18. //Input is high = active so we need to check if the port is equal to one.
  19. if (digitalRead(LIGHTSENSORPIN) == 1) {
  20. //The input is high so we detected a bottle. Let the user know through the serial port
  21. Serial.println("detection = 1");
  22. //Switch the LED on the Arduino board on by switching the pin HIGH
  23. digitalWrite(LED_BUILTIN, HIGH);
  24. } else {
  25. //Let the user know through the serial port nothing is detected
  26. Serial.println("detection = 0");
  27. //Switch the LED on the Arduino board off by switching the pin LOW
  28. digitalWrite(LED_BUILTIN, LOW);
  29. }
  30. }