Author Topic: Problems with STM32 PMSM FOC SDK  (Read 117797 times)

0 Members and 1 Guest are viewing this topic.

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #250 on: March 08, 2017, 10:02:25 am »
I do not know if this can give any clue ...

I had the motor running with Vqd.qV_Component2 = 3000 for ~ 15min.
I turn off the motor and it is super hot! The whole motor is really hot!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #251 on: March 08, 2017, 12:07:43 pm »
I did some tests to try to understand what's going on ...

Code: [Select]
encoder align 90º
Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;
Weak rotation. Clockwise

Code: [Select]
encoder align 90º
Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;
No rotation.

Code: [Select]
encoder align 0º
Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;
No rotation.

Code: [Select]
encoder align 0º
Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;
Very weak rotation. Clockwise.
« Last Edit: March 20, 2017, 10:15:01 am by Dave_PT »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #252 on: March 08, 2017, 02:55:40 pm »
I do not know if this can give any clue ...

I had the motor running with Vqd.qV_Component2 = 3000 for ~ 15min.
I turn off the motor and it is super hot! The whole motor is really hot!
If the motor gets hot and does not produce torque, it means that the magnetic forces are not pointing in the right direction. The flowing current is then mostly generating heat.

Keep in mind that the angle that you enter in this mask is not an offset that would be added to the electrical orientation after alignment. It just determines at which angle the measurement takes place. For a "sinusodial" motor this does not make a difference, but for a BLDC as in your case this will result in slightly different alignment results depending on which angle you choose.
We Are The Watt - Resistance Is Futile!
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #253 on: March 08, 2017, 03:16:31 pm »

300ms is quite a short time for the rotor to mechanically move into the correctly aligned position, and to keep it. Maybe increase that. I also suggest to do the ramp with as much current as possible. This helps it keep that position even when there is some torque at the output shaft.
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Dave_PT

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #254 on: March 08, 2017, 03:20:17 pm »
Eu fiz alguns testes para tentar entender o que se passa...

Code: [Select]
encoder align 90º
Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;
Weak rotation. Clockwise

Code: [Select]
encoder align 90º
Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;
No rotation.

Code: [Select]
encoder align 0º
Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;
No rotation.

Code: [Select]
encoder align 0º
Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;
Very weak rotation. Clockwise.

Google is my friend  8) That is very confusing. You should have torque at least in one of the two situations:

Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;

Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;

Maybe try this one as well:

Vqd.qV_Component1 = 3000;
Vqd.qV_Component2 = 3000;

That gives a 45°.

I start thinking if there is something wrong with the motor windings. Very confusing...  :o
We Are The Watt - Resistance Is Futile!
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #255 on: March 08, 2017, 03:30:08 pm »
I think it will can very difficulty if impossible to have more progress by playing with forms and numbers. Do you have the possibility to make a setup with Hall sensors like I pictured? I think you really need to shed more light on things like electrical and mechanical rotor orientation, encoder output, phase voltages and currents. There is something very weird going on, and remember that was already the case when you tested the ST eval board.
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #256 on: March 08, 2017, 05:09:42 pm »
Google is my friend  8) That is very confusing. You should have torque at least in one of the two situations:

Vqd.qV_Component1 = 0;
Vqd.qV_Component2 = 4000;

Vqd.qV_Component1 = 4000;
Vqd.qV_Component2 = 0;

Maybe try this one as well:

Vqd.qV_Component1 = 3000;
Vqd.qV_Component2 = 3000;

That gives a 45°.

I start thinking if there is something wrong with the motor windings. Very confusing...  :o

Maybe I'm doing something very wrong  |O |O |O
But with these modifications I still have no rotation....


 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #257 on: March 08, 2017, 05:37:52 pm »
I think it will can very difficulty if impossible to have more progress by playing with forms and numbers. Do you have the possibility to make a setup with Hall sensors like I pictured? I think you really need to shed more light on things like electrical and mechanical rotor orientation, encoder output, phase voltages and currents. There is something very weird going on, and remember that was already the case when you tested the ST eval board.

I'll prepare everything to get these tests done.

 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #258 on: March 09, 2017, 09:02:23 am »
I had the motor running with Vqd.qV_Component2 = 3000 for ~ 15min.
I turn off the motor and it is super hot! The whole motor is really hot!
Something that I forgot to mention. Please be careful with higher values here. The driver is directly converting these into voltage. 3000 means roughly 10% bus voltage, so the power stage feeds 2.4V(peak) to the motor. If that cannot spin (or does only spin slowly), then it creates no (or little) back-emf voltage. And in this case there is nothing that limits current, except internal resistance of driver power stage, cabling and motor windings. That can easily trip your overcurrent protection (if it hasn't already). And 2.4V can then cause a lot of current flow.
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #259 on: March 13, 2017, 04:53:33 pm »
- place small permanent magnet onto motor shaft/gear
- place Hall sensor in some orientation, such that it triggers once per mechanical rev, connect to scope channel, use it as trigger
- connect oscilloscope between two motor phases
- turn motor by hand and determine voltage zero crossing on scope --> this is your zero phase reference; you can now move the hall sensor such that its trigger point is right at the zero crossing; alternatively you can determine the phase between the two

I can not do this ...
The motor magnets are very strong and I can not turn with precision by hand ...
With the motor cables off, the rotor gives 6 strong bumps when rotating by hand.
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #260 on: March 14, 2017, 05:02:13 pm »
If I use 6 step commutation, will I be able to have lower speeds?
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #261 on: March 14, 2017, 05:09:23 pm »
They use FOC with BLDC ....

 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #262 on: March 14, 2017, 11:52:48 pm »
I'm on the road seeking for new employment, couldn't check emails...

To BLDC: these motors are sort of optimized for 6step commutation, but in my experience that does not improve closed-loop behaviour with velocity control at low speed. It makes things even worse when adding position control and can cause oscillation at standstill, because the motor can only move by 60 degree steps.

If your motor has that huge cogging that it cannot be turned by hand easily then this means to me that it is not optimized for robotics use at all. You want cogging free behaviour for that. I have used Maxxon BLDC for this purpose, they are coreless and turn 100% smooth.With anti-cogging you should be able to improve behaviour with your motors, but don't expect too much. You are limited  by their poor construction.

But anyway, there's something wrong with torque generation. When back home tomorrow I will come back with ideas to verify current phase without having to turn the motor manually

« Last Edit: March 14, 2017, 11:57:34 pm by tatus1969 »
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #263 on: March 15, 2017, 10:26:45 am »
I'm on the road seeking for new employment, couldn't check emails...
Good luck!!

To BLDC: these motors are sort of optimized for 6step commutation, but in my experience that does not improve closed-loop behaviour with velocity control at low speed. It makes things even worse when adding position control and can cause oscillation at standstill, because the motor can only move by 60 degree steps.

If your motor has that huge cogging that it cannot be turned by hand easily then this means to me that it is not optimized for robotics use at all. You want cogging free behaviour for that. I have used Maxxon BLDC for this purpose, they are coreless and turn 100% smooth.With anti-cogging you should be able to improve behaviour with your motors, but don't expect too much. You are limited  by their poor construction.

But anyway, there's something wrong with torque generation. When back home tomorrow I will come back with ideas to verify current phase without having to turn the motor manually
What bothers me is that the seller says that he has a controller that regulates the motor speed practically from 0RPM.
I'm pretty sure they use 6-step commutation, but it's hard for me to believe they can do that kind of regulation!

PS: Watch this video of me turning the motor shaft by hand.
https://meocloud.pt/link/40b64946-03ec-450a-8910-c3945be29637/VID_20170315_100905.3gp/
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #264 on: March 15, 2017, 02:38:32 pm »
I made some adjustments on my board to run this example.

I get a slow and smooth movement ... :o

http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #265 on: March 15, 2017, 02:59:41 pm »
I made some adjustments on my board to run this example.

I get a slow and smooth movement ... :o

http://www.berryjam.eu/2015/04/driving-bldc-gimbals-at-super-slow-speeds-with-arduino/

checked that website, he is driving the motor in a stepper-like fashion by generating three phase shifted sine waves with certain amplitude. This is similar to a test that I suggested earlier. Remember how I described to manually control the electrical angle with a small hack? If you combine that with open-loop mode, then the result *must* be exactly the same.

Currently preparing a video that describes how to check phases with a Hall sensor... Probably this evening.
We Are The Watt - Resistance Is Futile!
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #266 on: March 15, 2017, 03:08:26 pm »
Good luck!!
thanks  :)

What bothers me is that the seller says that he has a controller that regulates the motor speed practically from 0RPM.
I'm pretty sure they use 6-step commutation, but it's hard for me to believe they can do that kind of regulation!
when looking at your video, and looking at the phase current and voltage measurements that you did in the past, I would expect that your FOC solution should perform better that it currently does. But as you also experience too little torque and heated up motors, I think the most important part is to get that problem solved. I expect that, once that encoder alignment and motor phase voltages and currents are working as they should, your low-rpm results will drastically improve as well.
We Are The Watt - Resistance Is Futile!
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #267 on: March 15, 2017, 03:39:55 pm »
I'm having trouble for quite some time ...

I'm wondering if it's not better build my own firmware that does a mix of SVPWM and 6-step commutation.
I have not start yet because I can not understand how I can control current. In other words, in brushless motors the speed is related to the frequency and the torque is related to the duty cycle of the PWM.
If the motor starts to slow down, my control should increase the duty cycle, but also reduce the step frequency, so that the rotor does not lose the magnetic field.
But the control
is still not clear to me ...  |O
« Last Edit: March 15, 2017, 04:08:32 pm by Dave_PT »
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #268 on: March 15, 2017, 05:48:18 pm »
Maybe a mixed control will work.

Low revs
Stepper motor (SVPWM)

High revs
6 step commutation

I understand the control in 6 step commutation, but in low revs I can not figure it out (using SVPWM).
In a stepper motor the switching frequency is related to the speed of rotation, but I can not understand how to make the PWM duty cycle adjustment ...
 

Offline nuno

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: pt
Re: Problems with STM32 PMSM FOC SDK
« Reply #269 on: March 15, 2017, 06:31:13 pm »
At low speeds there's hardly any back EMF. Some FOC systems still have halls, I think mainly for starting in the right direction without "attempts" but probably for low speeds too.
You can try a "Lebowski controller" too, put it on google.
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #270 on: March 15, 2017, 06:39:18 pm »
Hello nuno

Thanks for comment.

I am using an incremental encoder of 500ppr.

This is my feedback to the controller.

There should be no problem, but at low speed the motor does not run smooth...
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #271 on: March 15, 2017, 09:15:01 pm »
I have prepared some videos that show how I validated the relationship between phase voltages, phase currents, and the rotor position feedback. Hope this helps

https://www.kicksurfer.de/index.php/2017/03/15/bldc-motor-and-foc-controller-phase-current-validation/

I did an extra video for you that shows how it should look like when you use open-loop control. You can see that the phase current signal looks just as good, and is in perfect phase with the Hall sensor / back-emf.

https://www.kicksurfer.de/index.php/2017/03/15/video2


We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Dave_PT

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #272 on: March 15, 2017, 09:38:54 pm »
Maybe a mixed control will work.

Low revs
Stepper motor (SVPWM)

High revs
6 step commutation

I understand the control in 6 step commutation, but in low revs I can not figure it out (using SVPWM).
In a stepper motor the switching frequency is related to the speed of rotation, but I can not understand how to make the PWM duty cycle adjustment ...

(please don't confuse terms - SVPWM is just describing a way to create three 120°-spaced sinusodial phase voltages. That's what FOC is using, and that's what is used in the video. FOC calculates the amplitude and orientation/frequency to turn the motor into a motor, and the guy from the video gives fixed amplitude (100%) and programmable frequency.)

At high revs, there is no advantage of 6-step commutation over FOC.

The problem with a stepper motor is that you always have to run it at maximum current, as it does not have a mechanism to detect its shaft load. If current is too low for the given load, it will "jump". If current is always max, it will quickly heat up. I don't think that this is a good strategy.

You can try this out by turning the ST FOC into a stepper controller:

a) forced rotor angle (here you can set the speed by changing the increment step) as already explained:

Code: [Select]
uint16_t FOC_CurrController(uint8_t bMotor)
{
  Curr_Components Iab, Ialphabeta, Iqd;
#if defined(HFINJECTION) || (defined(DUALDRIVE) && defined(HFINJECTION2))
  Curr_Components IqdHF = {0,0};
#endif
  Volt_Components Valphabeta, Vqd;
  int16_t hElAngledpp;
  uint16_t hCodeError;
 
  hElAngledpp = SPD_GetElAngle(STC_GetSpeedSensor(oSTC[bMotor]));

  // <<<<<<<<<<<<<<<<<
  if( StateM1 == RUN )
  {
    static int16_t k=0; k+=10; hElAngledpp=k;
  }
  // <<<<<<<<<<<<<<<<<

 ...



b) set controller to torque mode in STMCWB, and apply current.

This way the FOC algorithm will just create three sinusodial phase currents, rotating at a given frequency, no matter what the motor is doing. The encoder feedback is not used here.

Then, try to stop the output shaft and see how the motor "jumps".

I still think that the problem is neither the motor nor the control scheme, but a remaining problem with the voltage/current/mech_position relationships. I'm sure that you can find it.

One hint: when you try to turn the motor to do the Hall sensor measurements I proposed, can you extend the shaft with locking pliers or similar? I did that with the Maxxon motor, it had a similar output gear as your motor. You can attach the permanent magnet for the Hall sensor to its arm then.
« Last Edit: March 15, 2017, 10:55:41 pm by tatus1969 »
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #273 on: March 15, 2017, 11:11:44 pm »
One hint: when you try to turn the motor to do the Hall sensor measurements I proposed, can you extend the shaft with locking pliers or similar? I did that with the Maxxon motor, it had a similar output gear as your motor. You can attach the permanent magnet for the Hall sensor to its arm then.

Thanks for all the information.

Tomorrow I will insist on all this and see if I start to get results.

I will make a plastic part to be able to fit into the motor shaft gear.

PS: I've been watching the STM forum and there are some complaints of problems at low speeds. However, the general problems are because they all use sensorless ... which is not my case.
« Last Edit: March 15, 2017, 11:14:20 pm by Dave_PT »
 

Offline nuno

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: pt
Re: Problems with STM32 PMSM FOC SDK
« Reply #274 on: March 16, 2017, 02:10:00 am »
I didn't read the whole thread, just picked on the slow motion problems, yeah, sorry. Are you sure your encoder is behaving well at low speed? Or maybe the code isn't prepared to or doing enough "debouncing" on the encoder's signal (don't know which encoder you're using). Throwing out some possible causes at you :P
 
The following users thanked this post: Dave_PT


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf