Control BLDC motor and calibrating ESC on start

I’ ve tried to translate the arudurino code to xod. The ESC calibration works fine, but after that the servo/BLDC motor doesn’t move any more. What might be the problem?
THX

#include <Servo.h> 
 
Servo servo;  // create servo object 
 
unsigned long starttime;
unsigned long measuringtime = 100000; // Measuring interval in microseconds
int val = 25;
 
void setup(){
  Serial.begin(115200);
  starttime = micros();
  servo.attach(6);
  servo.write(25); // Is required to initialize the ESC
  delay(2000);
  //servo.write(40); 
}
 
void loop(){
  if ((micros()- starttime) >= measuringtime){
    servo.write(val);
    Serial.println(val);
    starttime = micros();
  }  
  val = map(analogRead(A0), 0, 1023, 30, 110);
  servo.write(val);
 
}

Here is the solution!

At start the ESC need an offset, but after calibration we dosen’t need this part any more.
The solution is quite simpel.
Set the ACT at the servo on top to FALSE and the RST at delay to NEVER.
Now you can controll your BLDC motor with the potentiometer.

library here

gabbapeople/esc

Thx for your suggestion but the ESC library #gabbapeople/esc isn’t very convinient.
At first you have to take look at the LED is it on or off and you have to manage time. At this solution, you just plug anything together and power up. You dont to have care about anything else and it works realy fantastic.

I don’t understand why you would include a servo node and set servo-ACT to false…the node will never try to move the servo. If you want the servo to move to this position on boot, you would want the delay-SET tied to boot node, then delay-ACT tied to servo-ACT. The second servo node cannot be active at the same time, so delay-ACT would run through a ‘not’ node, then to second servo-ACT pin. Now servo moves to predefined position on boot, then after delay expires it moves to position specified by pot.

An alternate solution would be to feed servo-VAL from an if-else node. If delay-ACT, then feed calibrate position, else feed pot position. This way you only have one servo node in your patch so there is no conflict.

image

Thanks a lot. I think your suggestion is a nicer solution to solve the problem with the calibration of the ESC at the start. I put a map between pot and if-else to control the BLDC and it works real nice.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.