Hi all,
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.
Yes Iq it’s better, the issue still present on the Id current.
I’m using the AS5048 sensor with the smoothing part, I initialize the “parts” in this way
smoothSensor = new SmoothingSensor(spiAngleSensor, motor);
motor->linkSensor(smoothSensor);
// Initialize motor hardware
motor->init();
motor->PID_current_q.P = 0.2f;
motor->PID_current_d.P = 0.2f;
motor->PID_current_q.I = 0.0f;
motor->PID_current_d.I = 0.0f;
motor->PID_current_q.D = 0.0f;
motor->PID_current_d.D = 0.0f;
motor->LPF_current_q.Tf = 0.01f;
motor->LPF_current_d.Tf = 0.01f;
motor->PID_current_q.limit = 20.0f;
motor->PID_current_d.limit = 20.0f;
motor->PID_current_q.output_ramp = 1000.0f;
motor->PID_current_d.output_ramp = 1000.0f;
motor->velocity_limit = RPM_LIMIT * _RPM_TO_RADS;
motor->current_limit = CURRENT_LIMIT; // [A]
//current_sense->gain_a *= -1;
//current_sense->gain_b *= -1;
//current_sense->skip_align = true;
// Initialize hardware current sense
current_sense->init();
// link motor and current sense
motor->linkCurrentSense(current_sense);
// Initialize motor FOC
motor->initFOC();
There is something wrong with my “initiliaze” sequence?
yes, sure…
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.
yes, the motor ha 40 magnets so 20 pole pair, also during the initial check I Pass the pp check. The motor is high power bldc (eaglepower LA8308 160kv)
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?