Continuing the discussion from Current sensing issue:
Code version 1
All this time, I though the correct way to initialize current sensing on the SimpleFOCShield v2 was this:
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A0, A2);
current_sense.gain_b *=-1;
current_sense.skip_align = true;
but then, as explained in the previous topic, some mode combinations wouldn’t work.
Code version 2
Out of curiosity I tried this:
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A0, A2);
current_sense.gain_b *=-1;
//current_sense.skip_align = true;
In that version, my setup doesn’t work either (same behavior as code version 1), but I get this message:
MOT: Align current sense.
MOT: Success: 2
As stated here, “2” means “success but pins reconfigured”.
Code version 3
So I inverted A0 and A2:
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A2, A0);
current_sense.gain_b *=-1;
//current_sense.skip_align = true;
In that version, everything seems to work perfectly. At last I can set aggressive current PIDs and all modes seem to work well!
Funny thing, the message is now:
MOT: Align current sense.
MOT: Success: 3
where “3” means “success but gains inverted”.
Code version 4
I tried this last modification:
InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A2, A0);
//current_sense.gain_b *=-1;
//current_sense.skip_align = true;
and got:
MOT: Align current sense.
MOT: Success: 3
as if nothing as been changed, and current sensing still works perfectly.
Any idea what’s going on here?