Arduino-FOC
Arduino-FOC copied to clipboard
[BUG]Block in InlineCurrentSense init
Describe the bug After instantiating the InlineCurrentSense object, and calling init() based on the object, it is found that the program will stay in the init function and not return
Describe the hardware setup For us it is very important to know what is the hardware setup you're using in order to be able to help more directly
- Which motor:
- Which driverDRV8313
- Which microcontroller:ESP32S3FN8
- Which position sensor:AS5600
- Current sensing used?:INA240A2
IDE you are using
- Arduino IDE
- Platformio
Tried the Getting started guide? - if applicable yes,use example inline_current_sense_test.ino block in current_sense.init();
Dear @mailonghua , thank you for reporting it.
Could I ask you to share the initialisation code?
Are you linking the driver to the current sense before the init? currentsense.linkDriver(&driver);
thank you for your reply No, I used the example inline_current_sense_test.ino directly, and only modified A0 and A2 to become my current pins ` #include <SimpleFOC.h> InlineCurrentSense current_sense = InlineCurrentSense(0.01f, 50.0f, 8, 9);
void setup() { current_sense.init(); current_sense.gain_b *= -1;
Serial.begin(115200); Serial.println("Current sense ready."); } void loop() { PhaseCurrent_s currents = current_sense.getPhaseCurrents(); float current_magnitude = current_sense.getDCCurrent();
Serial.print(currents.a*1000); // milli Amps
Serial.print("\t");
Serial.print(currents.b*1000); // milli Amps
Serial.print("\t");
Serial.print(currents.c*1000); // milli Amps
Serial.print("\t");
Serial.println(current_magnitude*1000); // milli Amps
} `
Ok, I understand. I have looked at the code, but I don't see the problem. I or one of my colleagues will have to test it out.
If you find out what the problem is, please let us know :-)