A hysteresis error setting method for a photoelectric sensor capable of resisting high-frequency light interference, wherein it comprises a transmitting tube for transmitting laser light source as modulated optical signals, double receiving tubes for receiving optical signals, a filter arranged at front ends of the double receiving tubes for filtering optical signals, a band-pass filter circuit coupled to the double receiving tubes, a differential amplifier coupled to the band-pass filter circuit, a control module for controlling the double receiving tubes to receive the optical signals synchronously with the transmitting tube, and a sensor hysteresis error setting system for improving an anti-interference performance of sensors;
- the control module further collects and obtains ambient light interference signals and sets an interference signal threshold value, and when it is detected that the amplitude of the collected ambient light interference signals is larger than the set interference signal threshold value, the control module discards the light signals lower than the interference signal threshold value after the interference signals are overlaid;
- wherein the sensor hysteresis error setting system comprises a first amplifier, a potentiometer, a second amplifier, a voltage follower, and a Microcontroller Unit (MCU);
- comprising the following steps:
- the potentiometer adjusts the range by adjusting a voltage division ratio;
- input signals, after amplification and voltage division, will be amplified by the second amplifier, then the second amplifier outputs detection signals to the MCU, and the voltage follower outputs range signals to the MCU;
- the MCU receives range signals and calculates and sets hysteresis error according to a set algorithm specifically as follows:
- y=m*x−n+k;
- where, x is a range signal variable transmitted by the voltage follower, y is the hysteresis error, m and n are fixed coefficients, and k is an intercept.