BUG? Servos go to 0 during initialization for about 1 second?

I'm noticing something weird using the Arduino Servo library with my ESP8266 board.

In setup, I immediately attach two servos and set them to the center position (90)

Approximately 350 milliseconds after startup, the servos go to the left extreme, then about 1200 miliseconds they go back to the center.

I investigated a bit more and discovered the arduno "loop" function stopped getting called at 350 ms and started getting called again at 1200ms, like something in the Arduino core/os called a blocking function that stopped everything the ESP8266 was doing for about a second, including messing up the servo outputs.

Has anyone else seen this? It's causing me a serious problem because the code is controlling an RC car and this causes the car to jump into full a reverse left turn during for one second when execution blocks.

I can get around the problem by delaying attaching the servos for 1200ms but this causes problems as the electronic speed controller is trying to calibrate itself during the first 3 seconds after power-on.

So I really need the servos to start up in the right position (which they do) and stay there for 3 seconds straight.

Post your code, click the </> symbol in the top left corner of the reply page and paste your code in the box that appears.

Malformed/inappropriate control pulses or poor servo/arduino grounding can cause the rotation to the servo internal hard stop.

milo_mindbender:
I'm noticing something weird using the Arduino Servo library with my ESP8266 board.

I think there are other Forums for the ESP8266 board if you are not using it with an Arduino board.

...R

I’m running Arduino 1.6.7 on Adafruit Feather Huzzah ESP8266 Overview | Adafruit Feather HUZZAH ESP8266 | Adafruit Learning System

I think the servo problem is just a symptom, the cause seems to be that “loop” stops getting called for about a second and during that time Servos either aren’t updating at all or the pulse width changes.

I can’t post my whole code but here is a simplified repro case that shows the stall.

// Case to reproduce hang during startup
void setup() {
  // put your setup code here, to run once:
  Serial.begin ( 115200 );
  Serial.println ( "" );

}

void loop() {
  // put your main code here, to run repeatedly:
  if(millis() < 2000)
  {
      Serial.print(millis(),DEC);
      Serial.println(F(": running"));
  }
}

When when I run this I see a stall happen at time 339, it recovers at 1226. ie: the output goes like this.

339: running
339: running
339: running
339: running
339: running
1226: running
1226: running
1226: running
1226: running
1226: running
1226: running
1226: running

During that stall between 339 and 1226 is when servos act odd. I haven’t had a chance to put a scope on it to see if it goes dead or the pulse width changes, but if in setup you do this

steering.attach(STEERING_SERVO_PIN);
steering.write(90);

The servo will go to center, then when it hits the stall at 339 ms it goes to zero position and returns to center position at 1226 when the stall ends.

It only seems to do this once, about 339 ms after startup.

milo_mindbender:
I'm noticing something weird using the Arduino Servo library with my ESP8266 board.

But your code with the hiccup at t=339 doesn't use the library. My Uno doesn't stall with your test code.

So this....

Robin2:
I think there are other Forums for the ESP8266 board

.... is probably a valid point.

jimboZA,

I was trying to make the simplest possible test case. The servo library doesn't CAUSE the stall, but the operation of servos is effected by the stall.

Thanks for trying it on an UNO, seems likely that the problem is related to the ESP8266 port of the Arduino environment.

Just to be clear, this is not something like an UNO with ESP8266 attached. The board I'm using is an ESP8266 ONLY, with the Arduino code running directly on the ESP8266 cpu.

What forum were you thinking of that is "Arduino on ESP8266" specific?

milo_mindbender:
Just to be clear, this is not something like an UNO with ESP8266 attached. The board I’m using is an ESP8266 ONLY, with the Arduino code running directly on the ESP8266 cpu.

This is an Arduino Forum - don’t expect advice about other microprocessors.

Google can find lots of ESP8266 stuff.

…R