Photoelectric sensor capable of communicating
By introducing voltage divider modules, MCU units and output circuits into the photoelectric sensors, two-way communication between the photoelectric sensors and the control box is realized, solving the problem of the lack of communication functions of the existing photoelectric sensors and improving production efficiency and yield.
Patent Information
- Application Number
- CN202510588457.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-06-27
AI Technical Summary
The existing photoelectric sensors lack communication functions and cannot perform data exchange and program upgrades, resulting in poor productivity and yield.
A communicable photoelectric sensor is designed, and bidirectional communication with the control box is achieved by introducing a voltage divider module, an MCU unit and an output circuit into the photoelectric sensor, and using the power supply positive electrode line and the output line as data reception and transmission lines.
The data exchange and program upgrade of photoelectric sensors have been realized, production efficiency and yield have been improved, and the need to disassemble the product for upgrading.
Smart Images

Figure CN120223048A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of optoelectronic sensors, and particularly to a communicable optoelectronic sensor. Background Art
[0002] The photoelectric proximity switch sensor is a specific application form of the optoelectronic sensor. The commonly used connecting wires of the photoelectric proximity switch are the positive power supply, the negative power supply, and the output wire. The working voltage is 10 - 30V DC, which is much higher than the TTL level and cannot be directly communicated, so data exchange cannot be realized. The optoelectronic sensor generally consists of a transmitting tube, a receiving tube, a filter, etc. During the production process, light emitted by the transmitter often shines on the receiving tube, resulting in a larger distance, a small change in the effective signal, and poor anti-interference ability. In severe cases, the optoelectronic sensor directly closes, and rework or even scrapping is required. In addition, due to differences in components and inconsistent assembly accuracy, the distance consistency of the products is not good. Only by disassembling the products can the program be upgraded, and the production efficiency and production yield are not optimal.
[0003] As above Figure 1 shows the current electrical diagram of the proximity switch with NPN-type output, Figure 2 shows the current electrical diagram of the proximity switch with PNP-type output. Generally, the working voltage is 10 - 30V DC, and the voltage change range is relatively wide, up to 20V. The positive power supply and the negative power supply supply power to the proximity switch, and switch quantity signals are output. There are NPN-type and PNP-type, and usually there is no communication function. Summary of the Invention
[0004] In view of the above-mentioned disadvantages of the prior art, the purpose of the present invention is to provide a communicable optoelectronic sensor, which is used to solve the problem that the existing optoelectronic sensor has no communication function, so data exchange and program upgrade cannot be carried out.
[0005] To achieve the above purpose and other related purposes, the present invention provides the following technical solutions:
[0006] A communicable optoelectronic sensor includes an optoelectronic sensor connected to a control box. The optoelectronic sensor is divided into an NPN-type optoelectronic sensor and a PNP-type optoelectronic sensor. Both the NPN-type optoelectronic sensor and the PNP-type optoelectronic sensor include a voltage division module and an MCU unit. The NPN-type optoelectronic sensor further includes a first output circuit, and the PNP-type optoelectronic sensor further includes a second output circuit;
[0007] The voltage dividing module is respectively connected to the junction box through the positive power line and the negative power line of the photoelectric sensor. The voltage dividing module is also connected to the MCU unit. The MCU unit is also connected to the first output circuit or the second output circuit. The first output circuit is respectively connected to the junction box through the output line and the negative power line of the photoelectric sensor. The second output circuit is respectively connected to the junction box through the positive power line, the output line and the negative power line of the photoelectric sensor.
[0008] In an embodiment of the present invention, when communicating with the control box, the positive power line, the output line and the negative power line of the photoelectric sensor are all connected to the control box. Among them, the positive power line of the photoelectric sensor serves as the data receiving line, the output line of the photoelectric sensor is the data sending line, and the photoelectric sensor communicates with the control box through the data receiving line and the data sending line.
[0009] In an embodiment of the present invention, the voltage dividing module includes a first resistor and a second resistor connected to each other. The other end of the first resistor is connected to the control box through the positive power line of the photoelectric sensor. The connection end of the first resistor and the second resistor is connected to the MCU unit. The other end of the second resistor is connected to the control box through the negative power line of the photoelectric sensor.
[0010] In an embodiment of the present invention, the MCU unit includes a comparator, a DAC module and a processor. The non-inverting input terminal of the comparator is connected to the voltage dividing module. The inverting input terminal of the comparator is connected to the DAC module. The output terminal of the comparator is connected to the first serial port of the controller. The second serial port of the controller is connected to the first output circuit or the second output circuit.
[0011] In an embodiment of the present invention, the first output circuit includes a first transistor. The base of the first transistor is connected to the second serial port of the MCU unit. The collector of the first transistor is connected to the control box through the output line of the photoelectric sensor. The emitter of the first transistor is connected to the control box through the negative power line of the photoelectric sensor.
[0012] In an embodiment of the present invention, the second output circuit includes a second transistor and a third transistor. The base of the second transistor is connected to the collector of the third transistor through a resistor. The emitter of the second transistor is connected to the control box through the positive power line of the photoelectric sensor. The collector of the second transistor is connected to the control box through the output line of the photoelectric sensor. The base of the third transistor is connected to the second serial port of the MCU unit. The emitter of the third transistor is connected to the control box through the negative power line of the photoelectric sensor.
[0013] In an embodiment of the present invention, the NPN-type photoelectric sensor and the PNP-type photoelectric sensor also both include a voltage reduction module. The voltage reduction module is also connected to the control box through the positive power line of the photoelectric sensor, and the voltage reduction module is also connected to the MCU unit.
[0014] As described above, a communicable photoelectric sensor of the present invention has the following beneficial effects:
[0015] In the present invention, the positive power line and the output line of the photoelectric sensor are respectively used as the data receiving line and the data sending line. Since the voltage levels of the MCU and the proximity switch are quite different, the MCU unit cannot directly communicate with the control box. Therefore, the present invention adds a level conversion module, that is, a voltage dividing module, and uses a comparator and a DAC module to achieve signal reception of the proximity switch. That is, when the control box sends data to the proximity switch, the pulse signal is divided by the first resistor and the second resistor in the voltage dividing module, and then transmitted to the processor after comparison by the comparator, thus completing level conversion and pulse signal level judgment, and realizing signal transmission; the present invention also uses the existing output circuit to send data to the control box to achieve signal sending of the proximity switch; the control box can perform level conversion and level inversion on the received pulse signal to complete signal recognition, thereby achieving the purpose of two-way communication. Therefore, the present invention can not only achieve data exchange, but also upgrade the program of the photoelectric proximity switch without disassembling the product, so that the production efficiency and production yield are in an optimal state. Description of the Drawings
[0016] Figure 1 Shows the output electrical schematic diagram of the existing NPN-type photoelectric proximity switch;
[0017] Figure 2 Shows the output electrical schematic diagram of the existing PNP-type photoelectric proximity switch;
[0018] Figure 3 Shows the schematic diagram of the output with communication function of the NPN-type photoelectric proximity switch of the communicable photoelectric sensor disclosed in the embodiment of the present invention;
[0019] Figure 4 Shows the schematic diagram of the output with communication function of the PNP-type photoelectric proximity switch of the communicable photoelectric sensor disclosed in the embodiment of the present invention;
[0020] Figure 5 Shows the communication logic schematic diagram of the NPN-type photoelectric proximity switch of the communicable photoelectric sensor disclosed in the embodiment of the present invention;
[0021] Figure 6It shows the communication logic schematic diagram of the PNP type photoelectric proximity switch of the communicable photoelectric sensor disclosed in the embodiment of the present invention;
[0022] Figure 7 It shows the schematic diagram of the pulse level change of the positive power supply RX in the communicable photoelectric sensor disclosed in the embodiment of the present invention;
[0023] Figure 8 It shows the schematic diagram of the level conversion in the communicable photoelectric sensor disclosed in the embodiment of the present invention. Specific embodiments
[0024] The following uses specific specific examples to illustrate the implementation manners of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. It should be noted that, without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0025] Please refer to Figures 3 to 6 , the present invention provides a communicable photoelectric sensor, including a photoelectric sensor connected to a control box. When communicating with the control box, the positive power supply line, output line and negative power supply line of the photoelectric sensor are all connected to the control box. The positive power supply line of the photoelectric sensor serves as the data receiving line (RX), the output line of the photoelectric sensor is the data sending line (TX), and the photoelectric sensor communicates with the control box through the data receiving line and the data sending line; in this embodiment, the photoelectric sensor is a photoelectric proximity switch sensor, and the photoelectric proximity switch sensor is a specific application form of the photoelectric sensor. The following content takes the photoelectric proximity switch sensor as an example for illustration. Among them, the photoelectric proximity switch sensor is divided into an NPN type photoelectric proximity switch sensor and a PNP type photoelectric proximity switch sensor.
[0026] Please refer to Figure 5 , the NPN type photoelectric proximity switch sensor includes a voltage dividing module, a voltage reducing module, an MCU unit and a first output circuit. The voltage dividing module and the voltage reducing module are both connected to the control box through the positive power supply line of the photoelectric proximity switch. The voltage dividing module is also connected to the control box through the negative power supply line of the photoelectric proximity switch. The voltage dividing module and the voltage reducing module are also both connected to the MCU unit, and the MCU unit is also connected to the first output circuit. The first output circuit is respectively connected to the control box through the output line and the negative power supply line of the photoelectric proximity switch;
[0027] Among them, the voltage dividing module includes a first resistor and a second resistor, the MCU unit includes a comparator, a DAC module and a processor, and the first output circuit includes a first transistor. It should be noted that the step-down voltage in this embodiment is an LDO circuit. The following selects the first resistor R1, the second resistor R2 and the first transistor Q1 as examples for illustration;
[0028] One end of the first resistor R1 is connected to the second resistor R2. The other end of the first resistor R1 and the buck module are both connected to the control box through the positive power line of the photoelectric proximity switch. The connected end of the first resistor R1 and the second resistor R2 is connected to the positive input terminal of the comparator. The other end of the second resistor R2 is connected to the control box through the negative power line of the photoelectric proximity switch. The negative input terminal of the comparator is connected to the DAC module. The output terminal of the comparator is connected to the serial port mRX of the processor. The serial port mTX of the processor is connected to the base of the first transistor Q1. The collector of the first transistor Q1 is connected to the control box through the output line of the photoelectric proximity switch. The emitter of the first transistor Q1 is connected to the control box through the negative power line of the photoelectric proximity switch.
[0029] Please refer to Figure 6 , the PNP type photoelectric proximity switch sensor includes a voltage dividing module, a buck module, an MCU unit and a second output circuit. The voltage dividing module and the buck module are both connected to the control box through the positive power line of the photoelectric proximity switch. The voltage dividing module is also connected to the control box through the negative power line of the photoelectric proximity switch. The voltage dividing module and the buck module are also both connected to the MCU unit. The MCU unit is also connected to the second output circuit. The second output circuit is respectively connected to the control box through the positive power line, the output line and the negative power line of the photoelectric proximity switch;
[0030] Among them, the voltage dividing module includes a first resistor and a second resistor. The MCU unit includes a comparator, a DAC module and a processor. The first output circuit includes a second transistor and a third transistor. Here, the first resistor R1, the second resistor R2, the second transistor Q2 and the third transistor Q3 are selected as examples for illustration;
[0031] One end of the first resistor R1 is connected to the second resistor R2. The other end of the first resistor R1 and the buck module are both connected to the control box through the positive power line of the photoelectric proximity switch. The connected end of the first resistor R1 and the second resistor R2 is connected to the positive input terminal of the comparator. The other end of the second resistor R2 is connected to the control box through the negative power line of the photoelectric proximity switch. The negative input terminal of the comparator is connected to the DAC module. The output terminal of the comparator is connected to the serial port mRX of the processor. The serial port mTX of the processor is connected to the base of the third transistor Q3. The emitter of the third transistor Q3 is also connected to the control box through the negative power line of the photoelectric proximity switch. The collector of the third transistor Q3 is connected to the base of the second transistor Q2 through a resistor. The collector of the second transistor Q2 is connected to the control box through the output line of the photoelectric proximity switch. The emitter of the second transistor Q2 is also connected to the control box through the positive power line of the photoelectric proximity switch.
[0032] Specifically, the present invention utilizes the existing wiring to add serial port functions to an optoelectronic proximity switch. Among them, the positive power line serves as the RX of the proximity switch, and the output line of NPN or PNP serves as the TX of the optoelectronic proximity switch. Since the serial port level of the MCU is 3.3V or 5V, while the operating voltage of the optoelectronic proximity switch is 10 - 30V DC, a voltage reduction module is required to reduce the voltage of the signal from the positive power line; since the MCU and the control box cannot communicate directly, after adding level conversion and pulse signal recognition in the present invention, it is then connected to the serial port of the MCU, thereby realizing signal reception; the optoelectronic proximity switch utilizes the existing output circuit to send as TX, thereby realizing signal transmission. For details, please refer to Figure 3 and Figure 4 .
[0033] More specifically, this communication can only achieve two-way communication together with the control box. When communication is not required, the optoelectronic proximity switch is connected to the voltage source. After passing through the voltage reduction module, the power supply voltage is VCC, and VCC supplies power to modules such as the processor, comparator, serial port, and DAC; when communication is required, the optoelectronic proximity switch is connected to the control box. Since there is a large difference in the levels between the MCU and the proximity switch, after voltage division by the first resistor R1 and the second resistor R2, it is connected to the mRX of the MCU serial port through the comparator, completing level conversion and pulse signal level judgment, and realizing signal transmission; the signal sent by the serial port mTX of the MCU in the optoelectronic proximity switch is transmitted to the control box through the output circuit, where Figure 5 the mTX in Figure 6 is reverse to the output TX;
[0034] the mTX in
[0035] is in the same direction as the output TX; the control box can process the output TX level conversion and level inversion inside to complete signal recognition, thereby realizing the two-way communication function. Figure 7 , V1 is between V0 and V2;
[0036] When the control box sends data to the photoelectric proximity switch, the pulsed voltage change of the positive power supply is transmitted inside the proximity switch. It is divided by the first resistor R1 and the second resistor R2 and sent to the positive phase terminal of the comparator. The DAC module is divided and connected to the negative phase terminal of the comparator. If the level of the positive phase terminal of the comparator is higher than that of the negative phase terminal, the comparator outputs the VCC level; if the level of the positive phase terminal of the comparator is lower than that of the negative phase terminal, the comparator outputs a low level. Under normal circumstances, it is necessary to avoid the situation where the positive phase terminal of the comparator is equal to the negative phase terminal level to prevent the output state of the comparator from being uncertain. Reasonably selecting the values of V0 and V2 is beneficial to improving the signal quality. Generally, V1 = (V2 - V0) / 2 + V0, and the value of V1 can be calculated from the voltage value V4 of the DAC module, that is, V1 = V4*(R1 + R2) / R2, so that the flip level of the comparator is in the middle position between V0 and V2, ensuring the accuracy of the pulse voltage to MCU serial port level transfer and reducing communication data errors. To improve the anti-interference ability, the comparator hysteresis is set internally by the MCU;
[0037] When the control box does not send data, that is, when the positive power supply is V0, the voltage value after passing through the first resistor R1 and the second resistor R2 is V3 = V0 / (R1 + R2)*R2. At this time, the value of V3 is less than V4, so V5 is at a low level; when the level of the positive power supply is V2, the voltage value after passing through the first resistor R1 and the second resistor R2 is V3 = V2 / (R1 + R2)*R2. At this time, the value of V3 is greater than V4, so V5 is at the VCC level. Since the comparator is a positive comparison, the positive power supply and the V5 level are in the same direction. For details, please refer to Figure 8 ;
[0038] When the proximity switch sends data to the control box and the output circuit is of NPN logic at this time, the positive power supply level is stable at V0. The conduction and cutoff of the first transistor Q1 are controlled by the mTX in the MCU serial port driving the output circuit. When mTX is at a low level, the TX level is V0; when mTX is at VCC, the TX level is at a low level, that is, mTX and the output TX are in reverse, so as to generate a pulsed signal on the output TX.
[0039] When the proximity switch sends data to the control box and the output circuit is of PNP logic at this time, the conduction and cutoff of the third transistor Q3 are controlled by the mTX in the MCU serial port driving the output circuit, and the third transistor Q3 controls the conduction and cutoff of the second transistor Q2; when mTX is at a low level, the TX level is at a low level; when mTX is at VCC, the TX level is V0, that is, mTX and the output TX are in the same direction, so as to generate a pulsed signal on the output TX; since mTX is controlled by the MCU serial port, configuring the MCU serial port to achieve serial port data sending, the internal circuit of the control box will perform level and phase conversion according to the logic of the proximity switch to achieve data parsing.
[0040] Furthermore, the present invention has other alternatives that can also achieve the purpose of the invention, and the alternatives are: 1. Adopting a similar architecture and changing the number of voltage-dividing resistors; 2. Adopting a similar architecture and using an external comparator; 3. Adopting a similar architecture and changing the DAC module to a resistor voltage divider; 3. Adopting a similar architecture for other types of proximity switches.
[0041] In summary, the present invention only needs to add two resistors to the original cable of the proximity switch, and utilizes the comparator, DAC module, and serial port module provided by the MCU, and communication can be achieved with almost no increase in cost. It not only realizes bidirectional transmission of data, but also achieves the purposes of calibration, string light calibration, threshold and hysteresis adjustment, program upgrade, and process data monitoring.
[0042] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. All equivalent modifications or changes made by those skilled in the art without departing from the spirit and technical ideas disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A communicative photoelectric sensor, characterized in that: A photoelectric sensor connected to a control box is included, wherein the photoelectric sensor is divided into an NPN photoelectric sensor and a PNP photoelectric sensor, wherein both the NPN photoelectric sensor and the PNP photoelectric sensor include a voltage divider module and an MCU unit, wherein the NPN photoelectric sensor also includes a first output circuit, and the PNP photoelectric sensor also includes a second output circuit; The voltage divider module is connected to the junction box through the positive power line and the negative power line of the photoelectric sensor respectively, and the voltage divider module is also connected to the MCU unit, and the MCU unit is also connected to the first output circuit or the second output circuit, and the first output circuit is also connected to the junction box through the output line and the negative power line of the photoelectric sensor respectively, and the second output circuit is also connected to the junction box through the positive power line, the output line and the negative power line of the photoelectric sensor respectively.
2. A communicative photoelectric sensor according to claim 1, characterized in that: When communicating with the control box, the positive power line, output line and negative power line of the photoelectric sensor are all connected to the control box, wherein the positive power line of the photoelectric sensor serves as a data receiving line, and the output line of the photoelectric sensor serves as a data sending line, and the photoelectric sensor communicates with the control box via the data receiving line and the data sending line.
3. The communicative photoelectric sensor according to claim 1, characterized in that: The voltage divider module includes a first resistor and a second resistor connected to each other, the other end of the first resistor is connected to the control box through the positive power line of the photoelectric sensor, the connected end of the first resistor and the second resistor is connected to the MCU unit, and the other end of the second resistor is connected to the control box through the negative power line of the photoelectric sensor.
4. The communicative photoelectric sensor according to claim 1, characterized in that: The MCU unit includes a comparator, a DAC module and a processor, the same-direction input end of the comparator is connected to the voltage divider module, the reverse input end of the comparator is connected to the DAC module, the output end of the comparator is connected to the first serial port of the controller, and the second serial port of the controller is connected to the first output circuit or the second output circuit.
5. A communicative photoelectric sensor according to claim 4, characterized in that: The first output circuit includes a first transistor, the base of the first transistor is connected to the second serial port of the MCU unit, the collector of the first transistor is connected to the control box through the output line of the photoelectric sensor, and the emitter of the first transistor is connected to the control box through the negative power line of the photoelectric sensor.
6. A communicative photoelectric sensor according to claim 4, characterized in that: The second output circuit includes a second transistor and a third transistor, the base of the second transistor is connected to the collector of the third transistor through a resistor, the emitter of the second transistor is connected to the control box through the positive power line of the photoelectric sensor, and the collector of the second transistor is connected to the control box through the output line of the photoelectric sensor; The base of the third transistor is connected to the second serial port of the MCU unit, and the emitter of the third transistor is connected to the control box through the negative power line of the photoelectric sensor.
7. The communicative photoelectric sensor according to claim 1, characterized in that: The NPN photoelectric sensor and the PNP photoelectric sensor both further include a step-down module, which is also connected to the control box via the positive power line of the photoelectric sensor, and is also connected to the MCU unit.