And with STM32F405RGT6 you have to put
current_sense.linkDriver(&driver);
In this order, otherwise I canât get it to work
As in your Github example, but the current measurement doesnât work?
yes much smaller, but i think simply adding a delay is not a solution but rather a work around. the real problem lies somewhere in the fact that the pid isnât updating when the motor is disabled and also that you sample bad currents. so the solution would be to: restart pid with an output value close to the motor bemf to have a smooth transition, sample once the current readings, from then on the pid could take over like normal
It would also be nice to protect the current overflow if the delay is exceeded.
Me @rungerâs solution
driver.voltage_power_supply = 24.0f ;
driver.voltage_limit = 20.0f ;
is fine with me, but a user could fry equipment if thereâs no protection âŚ
Very interesting! But normally when the motor is disabled, then the current sense values are not retrieved because _readADCVoltageLowSide wonât get calledâŚ
So what exactly is happening? Does it mean after re-enabling, it is retrieving at least one old value? When adding the delay, the peak is less, because the old valueâs influence is reduced via the LPF?
And when disabling the trigger, we donât get the old value, so we donât get the same peak?
What happens (if I may ask you to try it) if instead of disabling the trigger, you instead call _readADCVoltageLowSide() for each pin, or maybe getPhaseCurrents() once after motor.enable() but before the call to loopFOC()?
â that might get rid of the old value?
Just to summarize the findings:
With low side current sense, if phase currents are sampled while the low side mosfet is OFF, the phase currents are completely off. This happens if the duty cycle is very high, or when the driver is disabled.
While the motor is disabled, _readADCVoltageLowSide is not called but you still have those wrong phase current values either in the DMA buffer or in the injected adc registers, those values are used the next time _readADCVoltageLowSide is called.
I donât think running getPhaseCurrents() before loopfoc will help as loopfoc will get those bad values again.
To me this is not a bug.
You need to know that with Low side current sensing, you shouldnât reach 100% duty cycle so you have to limit the voltage. I am not sure the library should do this for you.
Yes, youâre right, we would have to wait for the next update from the ADC, which can only yield correct values after the PWM has been set.
Itâs a tricky case, but we should find a way to take care of it. So far your method of disabling the trigger is the best idea we have.
So for a future release of SimpleFOC:
we should extend the disable() function to also call a currentsense.disable() - same for enable(). So calling motor.dis/enable() forwards this intent to driver and current sense, who can deal with it if needed.
current sense: we can then call a new method in the hardware API to disable the triggers, which is MCU specific.
additionally, the motor.enable() function should call pid.reset() for all the PIDs.
The disadvantage of this solution is that you sacrifice % of duty cycle on top and bottom so the maximum line to line voltage is even lower.
The advantage is that the modulation is centered, and the conduction losses are equal between high side and low side mosfets. I am not sure how much it matters in reality.
@Candas1 Hello,
I think thereâs a serious bug in the current version of dev ?
Iâve just downloaded the latest version of dev to try it out,
I connected my power supply (without sending commands to the motor), and it immediately went into current protection.
I quickly switched off the power supply, put the old firmware back on (version downloaded on 8 January) and everythingâs fine âŚ