cancel
Showing results for 
Search instead for 
Did you mean: 

BUGREPORT MCSDK 5.4.3 (and temporary fix)

chaaalyy
Senior II

Hi,

since a couple of days i tried to get the STEVAL-ROBOT-1 up and running properly. But as i mentioned here:

https://community.st.com/s/question/0D53W000003yGcdSAE/to-choice-a-kit-for-pmsm

yesterday, i got more problems, than i would have expected from libraries, provided by a "mature" company like ST.

Ok, giving up is not an option... So meanwhile i figured out, what´s wrong (After around 30 hours of search...). But step by step:

After many problems, importing the (actual) STSW-ROBOT-1 into cubeIDE and getting it to be built, i faced problems with unreliable position control, unexpected behaviour with torque regulation, unexpected moving motor and so on. Until yesterday i thought, it´s maybe just an error in some overflow calculation, but THIS is even worse:

In the file trajectory_ctrl.c , located in the folder \MCSDK_v5.4.3\MotorControl\MCSDK\MCLib\Any\Src , Lines 341 - 354 , the function void TC_EncoderReset(PosCtrl_Handle_t *pHandle) is the problem:

This function is called within the EXTI0_1_IRQHandler (void) , located in stm32f0xx_mc_it.c , EVERY time, the index pin of the provided encoder is passed by. So far, so good...

But why the hell, also EVERY time within these functions, ENC_SetMecAngle(pHandle->pENC , pHandle->MecAngleOffset) is called ??? Of course, the irq handler needs some time (not much, but anyway...) to run through. And in THIS time, of course the motor runs a few steps further. Now you take the formerly measured counter values and reset the counter to a PREVIOUS captured value ??? (Sorry, i´m just a little bit upset about so much stupidity...)

Of course this leads to absolutely undefined behaviour of the motor, up to loosing synchronisation. If you run the motor repeatedly just full revolutions (360 degree), after a while you can see, it´s definitely not "on track" anymore.

The solution is simple: placing the ENC_SetMecAngle - function within the if / else brackets. So it´s reliably called, when needed to align the motor with the encoder and afterwards, it´s just not called anymore. I attached the correted file here.

This affects ALL projects, with EVERY hardware ! Not just the STEVAL-ROBOT-1-Kit !

Ok, the next problem: As i stated in the thread, i linked above, also the motor settings and board parameters are more than just lousy. Resistance and inductivity not set correctly, Amperes just crippled, and so on, and so on ...

I made a quick fix (not perfect, still some tuning needed, but these settings work FAR better, than the original ones from ST) I attached two files (drive_parameters.h and pmsm_motor_parameters.h) with the settings, just replace them in the folder \Inc (not visible in cubeIDE project explorer, so open the folder directly in your workspace).

Last, but not least: For everybody, who doesn´t believe in these errors, provided by ST and also has no time to set up a modbus connection, i made a quick and dirty "check" run in main.c. Two possibilities, comment out the one, you don´t need. Begin with the 360 degree steps to see the behaviour without the corrected trajectory, then make the corrections and let it run for an hour or so ... NO position errors and NO unexpected behaviour or even movements anymore. For the 400 revs - routine, just running forward and backward for 10 secs each: PID settings need some more fine tuning, so it "overruns" a little bit, before PID corrects the position 😉

Edit: For everybody, who is wondering about that "encCounterValue = TIM3->CNT;" in main.c ... Add it to your live expressions while debugging to check the "stop" point after each movement... Should be within +/- 3 encoder steps, even after 100000 x moving 360 degrees forward.....

1 ACCEPTED SOLUTION

Accepted Solutions
Claire O.
ST Employee

Dears,

MCSDK5.4.4 is now available in st.com with the bug fix.

Best regards,

Claire

View solution in original post

20 REPLIES 20
Nikita91
Lead II

This kit is presented as "an excellent choice for reliable, robust and high-precision position and speed control"

But all this is ruined by the ST software ...

ST's reputation is being built in the industry, as not many hobbyist are using these techniques

Which reputation ? In large industrial environments, any product like this mcsdk would just not pass the quality control (which doesn´t seem to be existent at ST). Any product manager, facing trouble like this, would just move on to other manufacturers (Renesas, Microchip, NXP, Texas Instruments.......).

To be honest: Atm i use this robot-1-kit to evaluate (more or less...) and develop something "industrial". Not as big, as automotive, but anyway around 20-30k units. My report at monday will... let´s say "not really praise ST" ...

But i think to know, what you meant... For "hobbyists" these bldc motors are "overengineering" most of the time. It´s just not worth to spend a) a lot of money and b) more time to find manufacturer´s bugs...

If somebody needs a reliable servo system, based on cheap pwm controllers and brushed dc motors:

https://github.com/chaaalyy/2_Channel_DCMotor_Servo

Of course some experience in st cube is needed and it is far from being perfect, but at least, this works out of the box...

AdamDonovan
Associate II

Thanks for the fixes,!!!!!

Claire O.
ST Employee

​Dear Chaaalyy,

Thanks a lot for your feedback,

We will correct the bug for next MCSDK release.

If you have any other feedback to help us to improve our solution, we will be very glad to hear them.

Thanks and best regards,

Claire

chaaalyy
Senior II

Wow 🙂 NOW i´m impressed 🙂 And i honestly have to say sorry for some "not so fine conversation tone" ... You can imagine, after a whole weekend of testing and searching for bugs, i have been "a little bit" ( 😉 ) upset. Especially after the experiences, i made a long time ago… Years ago, i asked for help, also brought some clearly visible bugs and after a loooong time, they have still been present. In short words: Just nobody cared about … The way, how you handled that now, gives me back "some hope" 😉

/Charly

​Dear Charly,

Of course we understand your frustration! ST motor control team is doing is best but unfortunately sometimes, it's just not enough or just not fast enough...

Anyway, your fix should be released soon, this week I hope.

Please stay tune and don't hesitate to send other remarks and complains 😉

Claire

Hello @Claire OKU​ ,

and again an other weekend xD ... Unfortunately (for a "noob", like me...) it´s very hard to "disassemble" the libraries and to find the reasons for some "strange" behaviours. Atm i don´t have my laptop with the toolchains here but i try to "recall", what i found (or not... xD) Of course, this evening i can check all this and also send some screenshots from debugging, photos and so on.

Ok, the story so far:

to get reliable (and unaffected) timings and behaviour of the f031, i simply connected step/dir signals to PA15 / PB6 via the provided TP´s. For debugging, i just use the step signals, directly evaluated in TIM2 (external trigger) counter. All the modbus / usart stuff, according timers / interrupts are just disabled. This gives me a "testing environment", where i can be (more or less) sure, if something is wrong, it comes from the mcsdk 😉 I attached a picture of the soldering and an "early" video, where partly the dir signal is still active to give you an impression, how it works. 0693W000000X9CbQAK.jpg

I haven´t had much time this weekend, to further investigate, what´s going on below the surface, bat as far, as i remember, in trajectory and in pid controller is a lot of "weird" stuff. Example: TC_FollowCommand, that "ReceivedTH" member of the pHandle struct: In my eyes simply useless... In follow mode, the functions shall be called repeatedly (in main loop ?). So after two loops, it reches the max. possible value of 2 and therefore the "if (pHandle->ReceivedTH > ***)" statement is definitely useless after two loops. Even at 1st call, it´s not necessary and could save some valuable flash space (and maybe one or two cpu cycles xD).

In PID control, the "D"-part also is "a little bit strange". As i already said: Not enough time this weekend :( I did a quick and dirty try to get rid of that "estimate acceleration, speed and so on" stuff in TC_FollowCommand, because in TC_FollowExecution the saved values are (as it looks like so far) just reverse calculated and added then. I replaced all the content of TC_FollowCommand with a single pHandle->Theta = Angle and removed also the content of "TC_FollowExecution", as this is the one and only member, used by PID position regulation. So far, it seems, that these "TC_xxxx" functions partly do the job of a (correctly implemented) pid control, which has some problems itself or it is just "luck", that it works partly. Be honest: The "calculation" of the D component in PID is more than "strange" 😉

Maybe somebody should check all that stuff... Atm it looks like "quickly written" and never debugged or revised :(

Before i forget it: these calculations (needed or not) in TC_FollowCommand" rely on formerly stored values... Unfortunately it´s possible, these values get edited somewhere else (maybe from an isr ?) between two loops of that function. On my laptop, i have a screenshot. I´ll attach it here, when i´m back home this evening =)

Ok Charly,

I will open a ticket on your issue and ask the team to have a look.

And yes, your screenshots will be welcome 🙂

Claire

​Dear @Karl Hönemann​ 

I have the kit and the motor. If you can help me to reproduce the wrong behaviour, I can try to understand  the root cause.

Please avoid to make modifications in the mcsdk code and send to me only the user code (typlically all files that are present in the inc and Src folders, and also the .stmcx file) that generates the problem.

Thank you

Ciao

Gigi