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

0 Members and 1 Guest are viewing this topic.

Offline bayetan

  • Contributor
  • Posts: 10
  • Country: us
Re: Problems with STM32 PMSM FOC SDK
« Reply #325 on: October 11, 2017, 08:06:35 am »
Here is the final configuration I had for the Nucelo F303RE and IHM08M1 to get FOC to work with Debug output.

1) Do everything specified by Motor Profiler (http://localhost:5331/mp/bundle?ctrl=NUCLEO-F303RE&pwr=X-NUCLEO-IHM08M1%203Sh)
2) Remove SB21 on F303RE (LD2 interferes with signal on PA5)
3) On IHM08M1
  • install R76, remove R77, install R80, remove R82, remove R85
  • remove R181 - conflicts with Pot from speed controller
  • remove R63 - conflicts with BEMF3
  • remove R21 - This is also used CURRENT REF which is input to OpAmp through a low pass filter so in the case of Observer Electric angle, the saw-tooth will appear chopped at the end.
I think I finally got this FOC working.  Now time to start with the real design work.  Below is the screen capture of both Debug displaying Observer Electric Angel when the Motor was spinning at 1200 RPM.
« Last Edit: October 11, 2017, 08:09:45 am by bayetan »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #326 on: October 12, 2017, 09:51:14 am »
Would you happen to know how I can setup the Peripherals register view on IAR?
There is a "Registers" entry in the debugging menu. But that "HSEStatus" is not a controller register, but just a variable. To be able to debug this realiably, you should disable compiler optimizations.

Actually, it was't the optimization that effected the code size but the options enabled in the Motor Control/Drive parameters.
Both of them affect the code size, but you'll always be close to the 32k. You can also reduce the code size by choosing a more restricted standard library, if you can live with things like printf being restricted to integers. Go to the project options -> General options -> Library Options (and Library Configuration). There, choose smaller options.

finally got this FOC working.

 :-+

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

Offline bayetan

  • Contributor
  • Posts: 10
  • Country: us
Re: Problems with STM32 PMSM FOC SDK
« Reply #327 on: October 14, 2017, 01:07:34 pm »
I forgot that Debug and Optimization just don't go together on IAR.  But the debug feature (peripheral memory) that exists on Eclipse through Pack (CMSIS) is shown below.  I think its really useful but I can find or get the equivalent thing to work on IAR.  They have something CMSIS-Pack Installer but I just don't see anything change once I've installed it.

Thanks for the information about the restricted standard library.  I was able to compile with all the options I need without going over the 32k limit.  Do you know if moving to a Dual system will increase the size much?

And have you had any luck working with STM32F4 series.  I would at some point need move to F4 but I'm still unable to communicate with uC using Motor Controller Workbench.  Given that my SysTick configured at 1mS is still at ~3.125 mS on the scope, I'm sure that has something to do with it but haven't had much luck getting that resolved.

And I'll like to get some advice on motor selection and my current Motor parameters is below.  Voltage should be 24 V and current should be more than 10 A with lots of inertia and friction in my applications.  I would like to use a 12 power supply and so would like to change the motor to 12 V version which has quarter the resistance and inductance but I decided against because the ST Motor Porfiler was not "optimum"  for inductance below 0.1 mH, I think.  Do you think I can get FOC to work with a motor that has quarter the inductance and quarter the resistance of my current one.

Thank,
Ben
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #328 on: October 14, 2017, 05:18:28 pm »
I can find or get the equivalent thing to work on IAR.
Start a debugging session, then in the menu: View -> Register. There you can select the peripheral that you want to see. You can open this window multiple times.

Do you know if moving to a Dual system will increase the size much?
Haven't done that yet.

And have you had any luck working with STM32F4 series.  I would at some point need move to F4 but I'm still unable to communicate with uC using Motor Controller Workbench.  Given that my SysTick configured at 1mS is still at ~3.125 mS on the scope, I'm sure that has something to do with it but haven't had much luck getting that resolved.
They are well supported. Have you checked in STMCWB to select the right processor, and to match the used crystal frequency? Also, make sure to load the right project.

And I'll like to get some advice on motor selection and my current Motor parameters is below.  Voltage should be 24 V and current should be more than 10 A with lots of inertia and friction in my applications.  I would like to use a 12 power supply and so would like to change the motor to 12 V version which has quarter the resistance and inductance but I decided against because the ST Motor Porfiler was not "optimum"  for inductance below 0.1 mH, I think.  Do you think I can get FOC to work with a motor that has quarter the inductance and quarter the resistance of my current one.
I am using the library with motors having inductances as low as 50uH, still running well. It also depends: are you going to use a sensorless motor? If your motor is sensored, then some of these values are irrelevant. I am not using the motor profiler but measure the values directly on the motor.
We Are The Watt - Resistance Is Futile!
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1896
  • Country: ca
Re: Problems with STM32 PMSM FOC SDK
« Reply #329 on: October 16, 2017, 02:15:10 pm »
Hi, guyes
I was just wondering if it's possible to use this SDK with STM32F030K6T6, since it's one of the cheapest parts and I want to design an ESC for my Quadcopter  motors.
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #330 on: October 16, 2017, 02:29:23 pm »
Hi, guyes
I was just wondering if it's possible to use this SDK with STM32F030K6T6, since it's one of the cheapest parts and I want to design an ESC for my Quadcopter  motors.
These are supported. But they are 32MHz only, and I wouldn't use them for high rpm / high pole count outrunners.
We Are The Watt - Resistance Is Futile!
 
The following users thanked this post: ali_asadzadeh

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1896
  • Country: ca
Re: Problems with STM32 PMSM FOC SDK
« Reply #331 on: October 17, 2017, 06:44:29 am »
Thanks, but they are 48MHz ;)  and 0.5$ in quantity
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline bayetan

  • Contributor
  • Posts: 10
  • Country: us
Re: Problems with STM32 PMSM FOC SDK
« Reply #332 on: October 31, 2017, 08:55:40 am »
I can find or get the equivalent thing to work on IAR.
Start a debugging session, then in the menu: View -> Register. There you can select the peripheral that you want to see. You can open this window multiple times.
After spending sometime with it, I finally realized that everything was hidden behind right-click context menu.  Thanks.
 

Offline bayetan

  • Contributor
  • Posts: 10
  • Country: us
Re: Problems with STM32 PMSM FOC SDK
« Reply #333 on: October 31, 2017, 09:04:57 am »

And have you had any luck working with STM32F4 series.  I would at some point need move to F4 but I'm still unable to communicate with uC using Motor Controller Workbench.  Given that my SysTick configured at 1mS is still at ~3.125 mS on the scope, I'm sure that has something to do with it but haven't had much luck getting that resolved.
They are well supported. Have you checked in STMCWB to select the right processor, and to match the used crystal frequency? Also, make sure to load the right project.

You were right about the frequency.  I ignored the "external crystal frequency" in the STMCWB because I assumed I was using the internal one and figured it didn't apply.  Apparently it did and the option selected was 25 MHz when I had 8 MHz, whose ratio is exactly 3.125.  Thanks.
 

Offline bayetan

  • Contributor
  • Posts: 10
  • Country: us
Re: Problems with STM32 PMSM FOC SDK
« Reply #334 on: October 31, 2017, 09:40:30 am »

And I'll like to get some advice on motor selection and my current Motor parameters is below.  Voltage should be 24 V and current should be more than 10 A with lots of inertia and friction in my applications.  I would like to use a 12 power supply and so would like to change the motor to 12 V version which has quarter the resistance and inductance but I decided against because the ST Motor Porfiler was not "optimum"  for inductance below 0.1 mH, I think.  Do you think I can get FOC to work with a motor that has quarter the inductance and quarter the resistance of my current one.
I am using the library with motors having inductances as low as 50uH, still running well. It also depends: are you going to use a sensorless motor? If your motor is sensored, then some of these values are irrelevant. I am not using the motor profiler but measure the values directly on the motor.

I'm going sensorless but having trouble getting reliable start-up and reliable speed control.  Below is the data I got from the ST Motor Profiler.  They match up pretty well with vendor's numbers and measurements I made using a scope and function generator.  And the gain parameters determined by ST FOC SDK are also included.  Not clear on how they arrived at these number... are they setup properly?  Wc (bandwidth of the closed loop system) was recommended to be 1500 rad/s for a good balance but not clear on what KpDIV and KiDIV should be.  And Ls/Rs=Kp/Ki is required for pole-zero cancellation so should my system respond well as long as I keep that ratio the same, that is once I figure out what that ratio should be.
 And is T (sec?) the reciprocal of PWM frequency multiplied by the Torque/Flux regulator execution rate [PWM periods]?  And would you recommend a more accurate way to measure Ls, Rs and Kv?
« Last Edit: October 31, 2017, 05:42:36 pm by bayetan »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #335 on: November 01, 2017, 12:17:43 pm »
I'm going sensorless but having trouble getting reliable start-up and reliable speed control.  Below is the data I got from the ST Motor Profiler.  They match up pretty well with vendor's numbers and measurements I made using a scope and function generator.  And the gain parameters determined by ST FOC SDK are also included.  Not clear on how they arrived at these number... are they setup properly?  Wc (bandwidth of the closed loop system) was recommended to be 1500 rad/s for a good balance but not clear on what KpDIV and KiDIV should be.  And Ls/Rs=Kp/Ki is required for pole-zero cancellation so should my system respond well as long as I keep that ratio the same, that is once I figure out what that ratio should be.
 And is T (sec?) the reciprocal of PWM frequency multiplied by the Torque/Flux regulator execution rate [PWM periods]?  And would you recommend a more accurate way to measure Ls, Rs and Kv?
During my process, I got the feeling that there may be something wrong with the derived values that STMCWB creates from entered motor and drive parameters. My current process is to enter the measured motor parameters as you did, and let it calculate what it thinks. Then I start tuning things as follows:
- first the current controller (that has nothing to do with sensorless or speed). You can stall the motor, and program a rectangular current command of a few ten hertz. I have described some methods in previous posts of this thread. (I suggest to read it completely.) I have an oscilloscope current clamp for this. Then tune Id/Iq PI gains. Use maximum bus voltage. Don't go too close to the limits here, I use to divide my results by 2 to get final values.
- then sensorless startup, but only externally driven. The observer must be able to follow the rotation with zero torque command, use the analog output feature to validate this. I also use a magnet on the rotor and a hall sensor connected to the scope. Play with parameters like observer type (cordic/pll), and BEMF quality factor. Play with the motor kV value last.
- then speed loop. That mainly depends on your motor inertia, and I always do this manually. Program a velocity command step, and tune until you get a good step response. Divide your results by 2 again. Also use max bus voltage here.
We Are The Watt - Resistance Is Futile!
 

Offline Emmsys

  • Newbie
  • Posts: 1
  • Country: 00
Re: Problems with STM32 PMSM FOC SDK
« Reply #336 on: May 15, 2018, 08:46:33 pm »
Hi,

Apologies for resurrecting an old thread but I am also using the FOC SDK for a project and experienced some of the issues mentioned in this thread. I am going completely sensorless on a motor that works up to 36V. I haven't decided whether I will use 24V or 36 in the end but right now I am getting the motor to spin from a stop, and also using the On-the-Fly startup. I am using an F3 with the IHM08M1 demo board. The motor runs but I am seeing 2 issues.

1) When using the on-the-fly startup only, I would manually spin the motor, then (after setting a torque ramp), make a call to "Start motor" and the motor would stop temporarily then start spinning. This only happens when the motor starts from the "stop" state (although the motor itself is being turned manually to engage OTF). If torque ramps are used once the motor is spinning, the transitions are buttery smooth so it is really when the FOC SDK is told to start the motor. Could this be a torque controller PI value issue, or is it related to the on-the-fly "brake" period? I tried changing this latter parameter but with no luck.

2) The second issue might not be an issue but here it is. If I ask for maximum torque, let's say 15 amps (by setting a torque ramp), the motor will not pull 15 amps, unless the RPMs increase drastically. So there is basically very little torque at lower RPMs. It's almost like the motor needs to catch up in speed (albeit always in torque control mode), before it gives the torque I want. If there is no load, I understand that the motor can reach maximum speed with little torque/amps, but when there is a load, the torque/amp (read from a power meter) might not reach the current/torque I request unless the motor is spinning a higher speeds. Is this just normal BLDC functionality where torque and speed are related? This issue is with on-the-fly startups in torque control mode. I feel like speed-control allows pulling more amps/torque than just straight torque control mode which is strange since the speed controller basically manipulates the torque controller. Or am I getting low torque at lower speeds because I am trying to go sensorless?

BTW I al using FOC SDK 4.3.0. The new 5.0 is giving me lots of issues.

Any tips are greatly appreciated!

e

« Last Edit: May 15, 2018, 08:49:06 pm by Emmsys »
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #337 on: May 16, 2018, 08:37:08 am »
I haven't used the on-the-fly startup feature in SDK4.3.0, because that was not available in 4.0 which I had been using a lot. Meanwhile I have moved to my own code, so I am afraid but I can't help you there.

If there is no load, I understand that the motor can reach maximum speed with little torque/amps, but when there is a load, the torque/amp (read from a power meter) might not reach the current/torque I request unless the motor is spinning a higher speeds. Is this just normal BLDC functionality where torque and speed are related?
No, BLDCs don't behave like this. Their output torque is proportional to the phase current, and you can expect it to be like this from near zero rpm (down to the point where the sensorless observer loses tracking) up to the point where the motor back emf "prevents" more current flow at high rpm.

It is most critical for the sensorless rotor observer that the motor parameters (L and R) are entered correctly, you may check these and play around with changing them to see if that has an effect. Also try both PLL and CORDIC options, they behave quite differently.

This issue is with on-the-fly startups in torque control mode. I feel like speed-control allows pulling more amps/torque than just straight torque control mode which is strange since the speed controller basically manipulates the torque controller. Or am I getting low torque at lower speeds because I am trying to go sensorless?
The sensorless observers that they have implemented can typically keep track down to very low rpm like a few Hertz (electrically), if properly tuned. I'd look into this first, this may also sort out your on-the-fly startup problems.
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 #338 on: May 16, 2018, 08:45:02 am »
The new 5.0 is giving me lots of issues.

Same here.

I'm using the P-NUCLEO-IHM001 and the project compile successfully... but the motor Monitor does not work. I can't connect through the UART... the software does not pairing with the board.
 

Offline r0d3z1

  • Regular Contributor
  • *
  • Posts: 116
  • Country: it
Re: Problems with STM32 PMSM FOC SDK
« Reply #339 on: December 10, 2018, 01:36:54 pm »
anyone know where the Board IHM08M1 can be found on stock ? or maybe, anyone would like to sell it ?
 

Offline r0d3z1

  • Regular Contributor
  • *
  • Posts: 116
  • Country: it
Re: Problems with STM32 PMSM FOC SDK
« Reply #340 on: January 23, 2019, 03:34:27 pm »
is anyone using the SDK 5 ? it looks like quite buggy (also the documents have a lots of errors)
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14305
  • Country: fr
Re: Problems with STM32 PMSM FOC SDK
« Reply #341 on: January 24, 2019, 10:14:26 pm »
Sorry in advance, was tempting to just ask:

"What the FOC?"

 ::)
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #342 on: January 25, 2019, 10:02:22 am »
 

Offline psyke

  • Contributor
  • Posts: 11
  • Country: ar
Re: Problems with STM32 PMSM FOC SDK
« Reply #343 on: November 04, 2019, 05:58:45 pm »
Hi, I'm developing a motor control system with ST's SDK 5.4.1.

I developed a new PCB based in STM32F302R8, and I already verified that the hardware works OK because with sensorless algorithm I can spin motors correctly. The problems come when I want to use the magnetic encoder I have in the circuit. It's an AS5147P, almost the same as Dave_PT's AS5047.
I checked that the encoder works well, I spin manually the motor and I see the measured speed varying in the STMCWB.

If I select only encoder as primary sensor, and no secondary sensor, the shaft just locks in place, energized. Also if i put observer as auxiliary sensor, I don't see any difference from not having secondary sensor. I also found out that ST says that you can use an encoder with index output, but it never ever uses it...

When I use observer as primary, and encoder as secondary, It works randomly but works. Also if I remove the encoder IC from the shaft of the motor, it still works... which I dont like too much, because it seems like it isn't using it.

So... how can I reliably measure speed with the encoder and effectively use it without getting speed feedback errors because of observer being activated?

Thank you in advance
« Last Edit: November 05, 2019, 02:58:54 am by psyke »
 

Offline r0d3z1

  • Regular Contributor
  • *
  • Posts: 116
  • Country: it
Re: Problems with STM32 PMSM FOC SDK
« Reply #344 on: November 05, 2019, 07:17:07 am »
As first step I suggest you to use only encoder as feedback, if it doesn't run you have to fix some problem on encoder configuration in your setup. Have you set the pulse number correctly ? have you connected the encoder correctly ? have  you check with scope if the A,B signal are correct ?
 

Offline psyke

  • Contributor
  • Posts: 11
  • Country: ar
Re: Problems with STM32 PMSM FOC SDK
« Reply #345 on: November 05, 2019, 02:38:16 pm »
Hi. I already checked the encoder and it works correctly. If I spin the motor manually, I see the measured speed in ST Motor Control Workbench Monitor, and also checked, before making it work, that the signals in A and B are correct.

If you check post #46, tatus says that you cannot use only encoder as primary sensor. I don't like that, because why in the world couldn't I use an encoder as primary sensor, if other FOC implementations let you use just encoder as a sensor?
With encoder as primary sensor, the motor gets energized and stuck in place, but it doesn't spin. Also I can't configure startup ramps.
If I put observer as primary, and encoder as secondary sensor, it works, not as smooth as it would be with encoder, but works. But the weird thing comes when I unplug, while the motor is spinning, the encoder feedback: the motor keeps spinning, the measured speed is the same, and I don't notice any change.

So, is there a way to use the encoder as the primary sensor? I want a realiable speed measurement, and not an estimation.

Thank you
 

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Problems with STM32 PMSM FOC SDK
« Reply #346 on: November 05, 2019, 02:57:05 pm »
Please check if the ppr of your encoder are correct.

At the end, my problem is related with a misunderstood of the encoder datasheet.

Count with an oscilloscope, or a logic analyser (more easier) if the ppr number are correct.
 

Offline psyke

  • Contributor
  • Posts: 11
  • Country: ar
Re: Problems with STM32 PMSM FOC SDK
« Reply #347 on: November 06, 2019, 12:30:26 am »
The PPR are correct, they are set to 1024 pulses per rev, which is the default for AS5147P in SETTINGS2 register.

Here is a video in which I show the encoder measurement by spinning the motor manually.
https://www.youtube.com/embed/Z8Xcem_A4wU

This is another video in which I start the motor and show how it aligns, and after that, it remains in position, energized, but doesn't spin even if I change speed reference.
https://youtu.be/pWIWRgWoC1M
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Problems with STM32 PMSM FOC SDK
« Reply #348 on: November 06, 2019, 09:44:42 am »
I'd first verify both ppr and counting direction of the encoder. You can also use one of the DAC outputs to monitor the electrical angle along with one of the phase voltages, while spinning the motor manually. If these stay in sync after a few revolutions then you can tick that off. Regarding the encoder I channel: in earlier versions that's something that you have to code by yourself - set up an interrupt for that signal in your MCU and let the ISR manually set the correct offset (to be measured once).
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 #349 on: November 06, 2019, 10:05:46 am »
Thing that you need to do the "encoder align" first and only then you mus click on "start motor".
Have you tried this?

If you never align the encoder, the control stage will know where the rotor is and will probably get stuck.

PS: In these new versions I don't know if the "start motor" already makes the encoder alignment, but it makes no sense to me.
« Last Edit: November 06, 2019, 10:16:56 am by Dave_PT »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf