Current sensing issue

Hey @quentin,
Even though in the graph it seems like the noise is high, it actually isn’t.
You are measuring hte current or ±8miliamps, which is really low current and it is close to the precision of the sensor. Once you get to a bit larger currents you should not have much noise, at least much less than this :smiley:

What you’re seing in the graph is not motor’s sinusoid of one of the phases you’re seing the q current which is the dc current. It does not oscilate.
But as we use current component q as our control signal in foc_current mode, what you are seeing is your control output for the velocity loop.
As 0.1 rad/s is quiet low I imagine that the motor stalls, then then the integrator in the velocity PID builds up the current, creating the upward slope of the curbe, and when your motor starts, it quickly tries to slow it down, decreasing the q current value. This creates the downward slope in your graph.
So this is not sine wave of one of the phase currents, but your control signal. :smiley:

In terms of the setup: Nucleo + SPI AS5048 + shield will work great in currentmode.

Regarding the code and the PID parameters, I’d suggest you to keep the PID parameters of the q qnd d currents the same. If you change one, do the same for the other one.

I am not sure what is the the issue here, but I would definitely do with lower P gains (like 0.5 ) and lower I gains (10) for starters and see how the system reacts.

Aslo I’d really suggest you to start in the torque mode, not in velocity or angle.
Make sure, when you set your torque target to 0, you can spin your motor freely, almost with no resistance. If that works then you can hold the motor with your hand and change the torque (in the case of foc_current mode that will be current_q target value) and you should be able the feel the force your motor is applying to you augmenting linearly with the target you’re seting.

1 Like