B-G431-ESC open loop velocity control error

I used B-G431B-ESC1 with 5010 360Kv motor in PlatformIO.

I went to try that control Open Loop Velocity, but the motor keeps turning, stopping, and going back and forth again.

I checked the CCR register value, and the CCR value seems to be drawing the sin wave normally as in the image below.

However, when looking at the change in voltage with the multimeter, the voltage in CH2 of TIM1, the V phase has the same minimum voltage but lower maximum voltage compared to the other.

The voltage on V phase couldn’t go over 6V, So I tried to forced change the CCR register value 1.2 times the original value, but it did not go over 6V in the same way.

this is my platformio.ini file

[env:disco_b_g431b_esc1]
platform = ststm32
board = disco_b_g431b_esc1
board_build.mcu = stm32g431cbu6
board_build.f_cpu = 170000000L
framework = arduino
upload_protocol = stlink
monitor_speed = 115200
build_flags = 
	-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
	-D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF
lib_deps = 
	askuric/Simple FOC@2.2.3
    SPI
	Wire
lib_archive = false
	

and this is my main code

#include <Arduino.h>
#include <SimpleFOC.h>


#define POTENTIOMETER PB12

 Encoder encoder = Encoder(PB6, PB7,4096, PB8);

BLDCMotor motor = BLDCMotor(7);
BLDCDriver6PWM driver = BLDCDriver6PWM(A_PHASE_UH, A_PHASE_UL, A_PHASE_VH, A_PHASE_VL, A_PHASE_WH, A_PHASE_WL);

float target = 0.1;
float speed = 0.1;

void doA(){encoder.handleA();}// Serial2.println("a");}
void doB(){encoder.handleB();}//Serial2.println("b");}
void doC(){encoder.handleIndex();}//Serial2.println("z");}

long long t_ = 0;
void serialLoop() {
  static String received_chars;

  while(Serial2.available()) {
    char inChar = (char) Serial2.read();
    received_chars += inChar;
    if(inChar == '\n') {
      target = received_chars.toFloat();
      Serial2.print("Target = "); Serial2.println(target);
      received_chars = "";
    }
  }
}

void setup() {

  Serial2.begin(115200);
  delay(1000);
  

  encoder.quadrature = Quadrature::ON;

  // check if you need internal pullups
  encoder.pullup = Pullup::USE_EXTERN;

  encoder.init();

  encoder.enableInterrupts(doA, doB, doC);
  
  driver.voltage_power_supply = 12;
  driver.init();

  motor.linkDriver(&driver);

  motor.voltage_limit = 1;
  motor.velocity_limit = 2000;


  motor.controller = MotionControlType::velocity_openloop;

  motor.init();
  motor.enable();

  //while(1) {}
}
long long time0 = 0;
uint32_t maxs = 0;
uint32_t mins = 0xFFFFFFFF;
void loop() {
  serialLoop();
  if (millis() - time0 >= 10) {
    time0 = millis();
    if (target < speed) speed = speed - 0.1;
    else if (target > speed) speed = speed + 0.1;
    
  }
  motor.move(speed);
  
  // Serial2.print(encoder.getSensorAngle());
  // Serial2.print("\t");
  //Serial2.println(encoder.getVelocity());
  if (millis() - t_ > 200 ) {
    Serial2.print((float)TIM1->CCR1);
  Serial2.print("\t");
  Serial2.print((float)TIM1->CCR2);
  Serial2.print("\t");
  Serial2.print((float)TIM1->CCR3);
  Serial2.println("\t");

  t_ = millis();
  }
}

Hi i’m also using a flycat 5010 360kv motor but all i hear is a buzzing sound did you find the solution?

after removing that it is still not working i just hear a buzzing sound

`
Screenshot 2024-03-27 125735

I wasn’t replying to you.

okay but can you see what’s with my code ? i’m using open loop velocity control btw

First you created threads for each different question, now you are trying to hijack someone’s else’s thread ?

but i cant get the answer!!! i’m using simplefoc library and i can’t get it work so then where yous i ask it???

You already asked questions here and here, wait for an answer.
You are off topic here, please respect @Jeoungji.
Maybe when he got it working, he can help you.

1 Like

thank you for your advice. I now have a open loop velocity control. I don’t understand exactly the cause yet, but I’ll study and understand.

1 Like

I’m sorry. I’ve never heard anything like that, so I don’t know what the cause is

But it works now right?

yeah thanks to you it working now