2024-02-09 09:57 PM
I am trying to tune a 28 pole 50V 20 Amp motor 6 step with hall sensors. Motor Pilot does not work for me. To get over this I am using STM32CubeMonitor to plot the speed response. I have also tried to change the values through Cube Monitor by writing to PID_SpeedHandle_M1.hdDefkpgain and even though the values change it has no effect on the performance. Changing values (#define PID_SPEED_KP_DEFAULT) in the drive_parameters.h file and recompiling does not work either.
I am only able to change the Kp values by going back to workbench and completely regenerating the project, which is a time-consuming operation.
I would appreciate some advice - thanks.
Solved! Go to Solution.
2024-02-15 07:13 AM
Hi @RoyStevens ,
to change the Kp on the fly, you have to update the parameters hKpDivisor and hKpDivisorPOW2 in the structure PIDSpeedHandle_M1.
For instance, to write 1024 (hKpDivisor=1024 and hKpDivisorPOW2=10)
However, you can easily do that with the Motor Pilot clicking on "advanced parameters" button
Alessio
2024-02-09 10:16 PM
you can use a regular variable instead of define and you can change value of that variable.
2024-02-10 07:52 PM
Thanks for the reply Tinnagit and yes it would be best for this to be a simple variable. I have just spent the last 3 hours trying to change the code to do exactly that, and even with Chat GPT looking over my shoulder I have not been successful. I would be the first to admit that I am not an experienced programmer, but I am trying hard to learn.
2024-02-11 09:07 PM
Could someone please explain to me why changing the value of #define PID_SPEED_KP_DEFAULT) in the drive_parameters.h and recompiling (even using the clean option) has no effect on the Kp used by the controller. I know it does not have any effect as I am measuring the motor phase currents with an oscilloscope.
I thought that when I changed the Kp value in work bench and then run STM32Cubemx that the header file drive_parameters.h was created and this was solely the information that STM32CubeIde was using.
Clearly it is not that simple. Can someone explain what is going on please.
Thanks
2024-02-11 11:23 PM
Do you ever try Motor Control SDK (MCSDK) on ST.
Is it work fine?
2024-02-12 12:20 AM
Yes I am using Workbench 6.2. Motorpilot 6.2 does not seem to be useful for a motor with Hall effect device feedback.
2024-02-13 06:56 AM
Hello @RoyStevens ,
The modification you did is correct. Changing PID_SPEED_KP_DEFAULT is what you have to do. But be careful, this is only the numerator part of the KP, there is also the divider stored int #define SP_KPDIV .
If the divider is huge, then your modification is perhaps too small to make any difference.
Could you elaborate a bit more about "Motorpilot 6.2 does not seem to be useful for a motor with Hall effect device feedback. " what is the issue you are facing ?
Regards
Cedric
2024-02-13 04:46 PM
Thanks for the reply, Cedric.
I will revisit Motor Pilot later and give you a careful description of the difficulties I had.
With regard to Changing the Kp the following is the process I have followed.
I am using 6 step. control.
I am running a PMSM motor on 20 V and have added a 1.0 Ohm resistor in each of the phases so that i can do experiments without accidental excessive current demand. Phase to phase resistance is about 2.8 Ohm.
I am using a Nucleo-G431RB and a X-Nucleo-IHM08M1.
I monitor the current by measuring the voltage across the 1.0 Ohm resistor with an oscilloscope. I have physically locked the rotor.
in main.c I use the instruction MC_ProgramSpeedRampMotor1(30/6,0) which is run for 1 second .
In workbench in drive settings, I set Kp = 32766/8. I set Ki to 0 and Kd =0
After going through the process of cube Mx and cubeIDE I run the motor and measure the current which is about 8.0 Amp peak.
The second test I do is back to workbench and set Kp = 32766/512 recompile and measure the current which is about 3.0A peak.
Now when I change from #define SP_KPDIV 512 back to #define SP_KPDIV 8 in the drive_parameters.h file and recompile the code there is no change in current. The current peak remains at 3.0 Amp.
I also tried doing a clean build but there is no difference.
What am I doing wrong?
Regards
Roy
2024-02-13 05:37 PM
Ok after writing that and going back to the code I see that for changing the denominator KPDIV I need to change
SP_KPDIV_LOG(()) also and now it all works. It now makes sense to me.
I expect that in the future I may wish to change Kp and KpDiv in the future on the fly in the main.c while loop, for high torque low speed situations.
I have struggled trying to do this for hours. Please give me some advice on this.
Thanks
Regards
Roy
2024-02-15 07:13 AM
Hi @RoyStevens ,
to change the Kp on the fly, you have to update the parameters hKpDivisor and hKpDivisorPOW2 in the structure PIDSpeedHandle_M1.
For instance, to write 1024 (hKpDivisor=1024 and hKpDivisorPOW2=10)
However, you can easily do that with the Motor Pilot clicking on "advanced parameters" button
Alessio