Yeah they seems good also to me… I don’t know what’s going on
is it possible you impacted the code when adapting for stmcubeide ?
It can be, but I changed only the parts that are connected to “hardware”. I changed the parts when the system generate the pwm (dutycyle) and the adc reading, in my case I use a dma triggered by the same timer that generates the pwm to read the adc, so the mcu doesn’t have to handle interrupts… I can try to compare the to codes and see if there are some differences.
Which stm family?
Yesterday I created a PR that removes the adc interrupts for stm.
[EDIT] Sorry you mentioned G4.
At the beginning I started with the interrupts, but then I changed because the mcu was too busy handling them and the main loop was too slow.
I checked the code and It’s the same, the only different part it’s the setPhaseVoltage() function, I changed the code with the dev branch but I get the same result
OK good to know.
Is it fast enough with the dev branch now ?
The code without interrupt is not merged yet.
yes, it’s faster … also with the dma transfer of the adcs the main loop is fast
This has a faster svpwm that is already on the dev branch, the current sense fix, and no adc interrupt, all 3 changes should improve the speed for you.
Happy to get feedback even if it’s not solving your issue.
I’ve done some other tests and the Id is related to the phase currents that are not always the same amplitude. The Id current is “synced” to the phase A current. Seems to be a calculation error…
This changing the PID low pass filter to 0.5 for the PID_D
0.5 is too high.
Can your motor have a problem?
Can you try with another one?
This is what I get in torque/foc_current mode with the PR I shared:
I haven’t touch the PID or filters at all.
I also only use 2 phase currents, the chip is much slower (STM32F1), with hall sensors and smoothing.
D current is a bit noisy but not sinusoidal.
yeah, I know 0.5 is very high, I don’t know if the motor can have problems, I used it to develop the board so it may have suffered some excessively high current discharge, but the phases measured with an LCR seem ok. I have another motor so I can test with the new one.
I tried with the new motor in Velocity_openloop and the Torque Control in voltage mode.
At the first try I get the Iq and Id as perfect sinewave (figure above), in this try the problem is the sensor (AS5048) and the motor direction that were not “synchronized”, I change the sensor direction to match the motor direction and I get this:
but to me they still sinewave or Am I wrong?
Are you using hall effect sensors for phase current sensing?
No, I read the low side currents without hall effect sensor, the adc start is triggered when the low side mosfets are on. In my case I use one timer for all the three pwm and the same timer generate the ADC trigger when all the low-side mosfets are on.
OK simplefoc does the same
I’ve noticed now that in velocity open loop when I increase the speed the current consumption (power supply current meter) goes lower… it’s strange I imagine faster I go more current consumption I have…
I’m doing some other tests and I find this (myabe is correct or not), I put in the chart the electrical angle (blue) and the mechanical angle (yellow), so why the electrical angle is not following the mechanical angle?
The system is in voltage_mode toqrue control.
Wow the electrical angle looks weird.
Is this the smoothed mechanical angle ? Maybe something goes wrong while doing the smoothing.
The electrical angle calculation is simple:
return _normalizeAngle( (float)(sensor_direction * pole_pairs) * sensor->getMechanicalAngle() - zero_electric_angle );