-->
Page 1 of 1

control servo every 10 ms bug http connect stop the servo

PostPosted: Fri Feb 24, 2017 4:38 am
by SomeOneASDF
HI

i have a esp8266 and i2c pwm servo ic

i went to servo rotate slowly, so i change pwm value every 10ms

but if there is a http request coming

the servo loop will be break , servo look lag

handleClient() need about 100ms to finish

how can i do make the servo smooth rotate and recv data from http service??




i have tried async web server, but the server still will break servo control loop

can i have a high priority interrupt pause the web server a little time to update pwm??

Re: control servo every 10 ms bug http connect stop the serv

PostPosted: Sun Feb 26, 2017 11:13 am
by mrburnette
The design of the ESP8266 under Arduino sets up two task using the non-OS task switcher.
http://bbs.espressif.com/viewtopic.php?t=838

The Arduino code MUST relinquish control or the RF section will "starve" and the WDT will force a reset. Documentation is contradictory but the refresh seems to be in the range of 30-50mS ... see delay(0) and yield().

You will need to design your Arduino code to manage dark periods. The top of loop() always passes control to switch tasks. The delay(0) and yield() are to be used inside the loop() control structure if the loop() cannot be cycled in the required time.

The answer is Arduino running on the 2-core ESP32 ... just not fully baked, yet.

Ray