Are several weeks that I’m trying to figure out what’s wrong with the Iq/Id currents on my project and I’m still not knowing what’s wrong with the board or the code.
I have two current sensors one on the phase A and the second on the phase B, the current readed from the sensors seem to be correct (I get some sinewaves) but when I run the simplefoc in torque control with foc_current I can’t tune the PID and the Iq and the Id are not dc but a kind of sine.
The green and red lines are the Vq and Vd of the current PID (P = 0.001 , I = 0.05 , D = 0). Looking at the PID output (Vq and Vd) I think the PID isn’t the problem, there is no oscillation on that part, so maybe is somewhere else the problem. The PID values are too weak (maybe?) but if I increase the P to 0.5 and the I to 0.1 the oscillations on the Iq and Id start going crazy.
When I hold the motor the Iq current reach the target and Id goes to 0.
It’s not easy to change the library in the project because I’m using stm32cube, so I adapted some part to be used on the stm32 ide, but using the oscilloscope I checked the two currents and to me they seems correct.
The yellow signal is the timer that generates the pwm for the drv8302 (3pwm mode) and the same timer is used to trigger the adcs (the adcs are triggered on the lvel change of the yellow signal, so on both edges). The red and cyan signals are the phase A and phase B low gates output generated by the drv8302.
the green line is the mechanical angle readed from the sensor with the smoothing. I noticed that also the Iq goes better or worst depending on what electrical angle the library find at the initialization of the system.
my “smoothSensor” variable it’s a pointr, so it’s correct to pass it without the “&”… I tried without the smoothing part and the errors on the Iq/Id still there, so maybeit’s not a problem with the smoothing part. A wrong zero electric angle could create this kind of problem?