ESC take 2 seconds to change motor speed using writeMicroSeconds

i command an esc with servo.h and writemicroseconds istruction.
the motor is in a 90mm edf fan and esc is a super simple 100a from rcs.
problem is that it takes 2 seconds for changing speed in any moment.
i use 800/900 for start the engine and less than 2000 for max speed. with 2000 microsec the esc go in programming mode
ive checked all the code and there's no delay.

do you know why the change is so slow?

do you know why the change is so slow?

No.

i have made also this video that demostrate the delay,
im using Serial Monitor to set from low to max speed.

Still not posted any code?
Good luck.

here is the code

#include <Servo.h>
 
// Arduino digital pins
#define BUTTON_PIN  2
#define LED_PIN     13

int potpinpan = 0;  // analog pin used to connect the potentiometer
int potpintilt = 1;
int potpinesc = 2;
int valpan;    // variable to read the value from the analog pin 
int valtilt;
int valesc;
int mod = 11;  //dividendo di controllo
int maxpanangle = 150;
int maxtiltangle = 110;
int maxesc = 179;
int minesc = 0;
int escpin = 2;
String comando;
Servo esc;
 
// Button hardware is setup so the button goes LOW when pressed
#define BUTTON_PRESSED LOW
#define BUTTON_NOT_PRESSED HIGH

 
void setup()
{
  pinMode(BUTTON_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);
  esc.attach(escpin);
  Serial.begin(1200);  // Hardware supports up to 2400, but 1200 gives longer range
}
 
void loop()
{
  if(Serial.available()) 
    valesc = Serial.parseInt();    // Parse an Integer from Serial
  esc.writeMicroseconds(valesc);
  
  if  (valtilt<30) {
    digitalWrite(LED_PIN, HIGH);
    }
  else {
    digitalWrite(LED_PIN, LOW);
    }
  //delay(100); 
}
valesc = Serial.parseInt();    // Parse an Integer from Serial

No delay, but what about the timeout?

You're using pins 0 and 1 to talk to pots but also of course they get used for the monitor... may not be the cause of your problem, but it's not right.

JimboZA:
You're using pins 0 and 1 to talk to pots but also of course they get used for the monitor... may not be the cause of your problem, but it's not right.

No.

@AWOL so how much timeout can generete the Serial.parseInt?
do you think that should be better and faster using Serial.Read?

@JimboZA the variables you see in the beginning are for future implementations

@AWOL so how much timeout can generete the Serial.parseInt?

I've no idea, I've never used parseInt, but it seems to me like a good place to look.

maybe it's really parseInt, i've just found other threads that talk about 1sec or more of delay

thank you

Have a look at serial input basics as a non-blocking alternative to parseInt()

...R

simple servo test code for use with the serial monitor. You can send commands and see if the speed change is delayed with this code.

// zoomkat 10-14-11 serial servo test
// use a microseconds value like 1500 in serial monitor
// for IDE 0022 and later
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(800); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-22"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  // allow buffer to fill with next character
    }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    myservo.writeMicroseconds(readString.toInt()); //convert readString to number for servo
    readString=""; //empty for next input
  } 
}

@zoomkat thank you i was thinking same solution , but now it requires only cut and paste and i preferr lazy solutions like this.
ty

ive checked all the code and there's no delay.

Oops.

oops what?

it's ok, it was exactly the problem that serial.parseInt delay 1 sec or more