madhephaestus / ESP32Servo

Arduino-compatible servo library for the ESP32
139 stars 55 forks source link

Get the output level of servo pin #46

Open ArminJo opened 9 months ago

ArminJo commented 9 months ago

Hi, since you did not enable discussions (Settings > Features > Discussions) I have to enter my question as an issue.

I want to solve the problem, that the servo signal goes LOW at the time of detach() see output below.

Is there a way to get the current state of the I/O pin used for servo output. On AVR platform I can use digitalRead() but on ESP32, this does not work, it stops the program.

If I connect the pin to another and use the othes as input the program works well and output:

Attach servo at pin 5 and move to 0 -> 180 -> 90 degree
Connect servo out pin 5 to monitoring in pin=18
Each character is 50 microseconds
Move servo to 180 degree, wait 400 ms and then detach 600 microseconds after start of pulse
_------------___________________________________________
Move servo to 180 degree, wait 400 ms and then detach 2500 microseconds after start of pulse
_-----------------------------------____________________

Or is there a way to read out the timer counter value and to decide if it is lower than hpoint, which I can get with https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#_CPPv415ledc_get_hpoint11ledc_mode_t14ledc_channel_t ?

Thanks ArminJo