Hello,
I’ve been looking for a while so I’m sharing …
Method to use the potentiometer of our B-G431B-ESC1 (in my case used to limit the current)
// loop down-sampling counter
long loop_count = 0;
float read_pot = 0;
void setup() {
...
// set the inital target value
motor.target = read_pot;
}
void loop() {
// control loop each ~250ms
if(loop_count++ > 250){
// page ==> .../Arduino-FOC/src/current_sense/hardware_specific/stm32/b_g431/b_g431_mcu.cpp
// 1/3.27=0,305810398
read_pot = _readADCVoltageInline(A_POTENTIOMETER, currentSense.params)*0.305810398;
loop_count=0;
}
// main FOC algorithm function
motor.loopFOC();
// Motion control function
//motor.move();
motor.move(read_pot);
}