banner

Blog

Jul 20, 2023

Learn to Build a Photoelectric Sensor System Using an Arduino Uno and OpenPLC

A vital component used in the control industry (and others, of course) is the electronic sensor. The electronic sensor’s importance in manufacturing is the ability to obtain performance data from various mechatronics-based automation systems. Mechatronics is a multi-interdisciplinary field that combines mechanical systems with electrical systems that include digital controls, electronic sensors, and control software.

A typical approach to managing mechatronics is to use a computerized-based controller capable of monitoring industrial processes and controlling electromechanical actuators. The PLC (programmable logic controller) is a computerized industrial controller capable of performing such industrial-related tasks. With an electronic sensor, the PLC can monitor various manufacturing processes and assist in improving electromechanical actuator performance.

With that background information in mind, this project will explore creating a specific electronic sensor, the photoelectric switch (also known as a photoelectric sensor), and using it with the Arduino OpenPLC platform.

A phototransistor is a semiconductor component that detects and converts light into an electrical signal and is designed to respond to light instead of an input voltage. Like a typical transistor, a phototransistor is comprised of base, collector, and emitter layers. The layer that is light-sensitive is the base-collector junction. When light falls on the base-collector junction, a flow of electrons is created, allowing current amplification within the transistor. Phototransistors are packaged as two lead or thread lead components, which can be seen in Figure 1.

Additionally, the electronic symbol for the phototransistor is shown in Figure 2.

With the base-collector junction being the sensitive layer, the two-pin component consisting of the collector and emitter leads is the commonly manufactured semiconductor part sold through electronic parts distributors. The phototransistor is typically configured as an NPN device using the base-collector junction as an internal light-sensing element. When light is present, the base-collector junction allows the base-emitter junction to conduct, thus turning the device into an optoelectrical switch. Another term used to describe the presence of light is photoemissivity, which is when a phototransistor’s base collector is in the presence of light, and the emission of electrons turns on this radiance solid-state component.

Like a limit switch, the phototransistor’s optoelectrical switching function can detect objects without physical contact. Unlike the limit switch, the phototransistor’s optoelectrical switching has no moving parts. Therefore, the phototransistor has a longer operating lifespan for switching than the limit switch. Overall, the phototransistor's longer operating lifespan is based on no mechanical contact wear like the typical limit switch.

Figure 3 shows the internal structure of a typical phototransistor.

With an understanding of the phototransistor, we will build a photoelectric switch to interact with our conceptual Arduino PLC using an OpenPLC ladder diagram (LD).

A photoelectric switch (or sensor) is an electronic device that can detect the absence or presence of an object using light and uses photo-emissive devices like photodiodes or phototransistors to detect light. The photoelectric switch has various light detection methods to detect the absence or presence of light, including:

The reflective method, shown in Figure 4, uses one housing to package the light transmitter and light receiver. With this method, the light receiver has a photodiode or phototransistor to detect light emitted from a laser or LED (light-emitting diode). The light emitted by an LED or laser is reflected off the object (target) and detected by the phototransistor or photodiode.

The thru beam approach (Figure 5) separates the transmitter and receiver components, where placing a target between the transmitter and receiver interrupts the light.

The final approach to using a photoelectric switch for object detection is retroreflective. Like the reflective model, the light emitter and receiver are packaged in one unit. The light emitted from the emitter hits a reflector and returns to the integrated light receiver. The presence of a target interrupts the emitted light. Figure 6 illustrates the retroreflective model of target detection using a photoelectric switch.

In this project, we will be building a photoelectric switch prototype based upon thru beam detection.

Finally, let's get into the hands-on information for this project! This photoelectric switch build consists of using off-the-shelf components. Here are the electrical, electromechanical, and electronic components you will use to build the photoelectric switch.

Parts Lists:

Additionally, you will need the following components to wire the reset switch and blinking LED circuits.

With the components available, you will place them on the solderless breadboard. You can use Figure 7 to guide you.

Some electronic components are polarity sensitive; therefore, proper orientation onto the solderless breadboard is important. The electronic components that are polarity sensitive are FPT1, D1, Q1, and LED1.

The phototransistor (FPT1) collector pin is long; therefore, it will need to be wired to the +5V rail of the solderless breadboard. Wiring the phototransistor collector pin to the +5 V rail will ensure proper switching operation of the component. As an additional reference, Figure 8 shows the assembled and wired photoelectric switch on the solderless breadboard.

You can test the switching operation of the photoelectric switch using a digital multimeter (DMM). The DMM will measure the control switching voltage of the phototransistor, which is lightly placed over the device. Here are the measurement setup steps to test the photoelectric switch operation:

Figure 9 shows a TinkerCAD circuit model test setup.

Figure 10 shows the actual measurement test set up with voltage readings from the phototransistor.

Congratulations, you have built a photoelectric switch prototype using off-the-shelf components! The project’s final step is to wire and test the photoelectric switch with an Arduino Uno-based OpenPLC platform.

With the photoelectric switch operating properly, the final step in this project is wiring the light detection circuit to the Arduino-based OpenPLC platform. The concept of the photoelectric switch controller consists of wiring the photoelectric switch and a reset pushbutton to the Arduino Uno. The integration of these circuits forms the photoelectric switch controller concept. A blinking LED will provide an output response status of the photoelectric switch controller, properly detecting a light source. Figure 11 shows the systems block diagram of the photoelectric switch controller.

The electrical wiring of the photoelectric switch, the reset pushbutton switch, and the blinking LED are captured on the electronic circuit schematic diagram shown in Figure 12.

The electronic circuit schematic diagram includes these circuit devices' input/output (I/O) wiring. You may reference Figure 8 for the final build of the photoelectric switch controller prototype.

The I/O circuit names, shown in Figure 13, are used to create the OpenPLC tags and the Ladder Diagram.

Figure 13 also shows the I/O tags for the OpenPLC start-reset LD. The LD shows that the photoelectric switch will perform the reset function. In an industrial control environment, a manual reset pushbutton switch will be wired as a contingency for the photoelectric switch failing in the system. The educational purpose of this conceptual controller is to show the effectiveness of the photoelectric switch in a control’s application. Pressing the "start" pushbutton switch will latch the blinking LED on. Placing a flashlight over the phototransistor will unlatch the control circuit, thereby turning off the blinking LED.

You can watch the video clip that demonstrates the photoelectric switch controller prototype in action here, or you can watch it down below.

In reviewing the start-reset LD, what output response of the Arduino-OpenPLC controller will be observed if the Photoelectric_Switch XIO (Examine If Open) bit instruction was changed to XIC (Examine If Closed)?

Let us know your answer in the comments down below!

Figure 1.Figure 2. Figure 3.Figure 4. Figure 5. Figure 6. Parts Lists:Figure 7.Figure 8.Figure 9. Figure 10. Figure 11. Figure 12.Figure 13.
SHARE