Hello, as in the subject, I have a problem with the detection of an interrupt from a PC817C optocoupler.
The voltage is 3.3V and I have the emitter of the optocoupler (leg 3) connected to the ESP32 with the GPIO35 pin,
with an external pulldown in the form of a 10K resistor Ω connected to GND.
I have set this pin as INPUT and the interrupt mode as FALLING.
The ESP32 detects the interrupt but it is not synchronous, and mostly detects double.
My ESP32 is a DevKitC ESP-WROOM-32U.
No problems with the Arduino UNO, it detects correctly,
But the ESP32 seems to have faster sampling at a higher frequency than the Arduino UNO.
I think the ESP32 pin voltage of 3.3V is not a problem, as the Arduino UNO has a pin voltage of 5V.
I tested on my little oscilloscope and at 2V and 10ms the signal is rectangular and varies from 0.16V to 3.2V,
and when I decrease the time the signal looks more and more like a sine wave,
when I add a larger resistor the signal sharpens but the voltage floor rises significantly,
and when I decrease the resistance the signal rounds off and looks more like a sine wave.
In the function called by the interrupt I have added a check to see if there is a low state on the pin:
.
This caused me to no longer detect interrupts doubly, but they are still not synchronous.
I ad hoc solved the problem softly with code like this:
.
Is it possible to somehow improve the signal so that at higher sampling frequencies i.e. less time it is more rectangular, and so that there are no problems detecting the interrupt during the descent?
The voltage is 3.3V and I have the emitter of the optocoupler (leg 3) connected to the ESP32 with the GPIO35 pin,
with an external pulldown in the form of a 10K resistor Ω connected to GND.
I have set this pin as INPUT and the interrupt mode as FALLING.
The ESP32 detects the interrupt but it is not synchronous, and mostly detects double.
My ESP32 is a DevKitC ESP-WROOM-32U.
No problems with the Arduino UNO, it detects correctly,
But the ESP32 seems to have faster sampling at a higher frequency than the Arduino UNO.
I think the ESP32 pin voltage of 3.3V is not a problem, as the Arduino UNO has a pin voltage of 5V.
I tested on my little oscilloscope and at 2V and 10ms the signal is rectangular and varies from 0.16V to 3.2V,
and when I decrease the time the signal looks more and more like a sine wave,
when I add a larger resistor the signal sharpens but the voltage floor rises significantly,
and when I decrease the resistance the signal rounds off and looks more like a sine wave.
In the function called by the interrupt I have added a check to see if there is a low state on the pin:
Code: C / C++
This caused me to no longer detect interrupts doubly, but they are still not synchronous.
I ad hoc solved the problem softly with code like this:
Code: C / C++
Is it possible to somehow improve the signal so that at higher sampling frequencies i.e. less time it is more rectangular, and so that there are no problems detecting the interrupt during the descent?