simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
1.95k stars 511 forks source link

[BUG]Block in InlineCurrentSense init #281

Open mailonghua opened 1 year ago

mailonghua commented 1 year ago

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

IDE you are using

Tried the Getting started guide? - if applicable yes,use example inline_current_sense_test.ino block in current_sense.init();

runger1101001 commented 1 year ago

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);

mailonghua commented 1 year ago

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

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

} `

runger1101001 commented 1 year ago

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 :-)