cancel
Showing results for 
Search instead for 
Did you mean: 

Recommended setup for small motor position control?

Martin294
Associate III

I have a small BLDC motor with magnetic encoder (like this one https://www.aliexpress.com/item/33053552345.html) and would like to set up a position control. The NUCLEO-IHM03 comes pretty close https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/stm32-nucleo-expansion-boards/p-nucleo-ihm03.html and I think I can use it from the hardware side. In this demo, no encoder is used, but connecting the AS5048A via SPI (for absolute position output) should not be a problem.

I am not so sure about the software. I have tried the motor control workbench, but this only seems to focus on speed control. There is a torque mode available, which would mean I would have to add a PID position controller on top. I could do BLDC/FOC from scratch if necessary, but would like to minimize effort by re-using an existing project. Can the motor control workbench do this or is it for low speed fan and compressor stuff only?

1 ACCEPTED SOLUTION

Accepted Solutions
Claire O.
ST Employee

Hello Martin294,

From last MCSDK version (5.4.3) we added a position control option for sensored solution. Did you try it?

Thanks and best regards,

Claire

View solution in original post

8 REPLIES 8
Claire O.
ST Employee

Hello Martin294,

From last MCSDK version (5.4.3) we added a position control option for sensored solution. Did you try it?

Thanks and best regards,

Claire

Martin294
Associate III

Hi Claire,

thanks for the info - I'll give it a try! Can I upgrade the MCSDK only without messing up my existing STM32F4Cube installation? I am working on a F4 project and don't want a new HAL version to be installed.

Thanks! Martin

Claire O.
ST Employee

Hello Martin,

It should be ok but please copy your current version for more security.

You can download the last MCSDK version and when generating motor control code use the same CubeMX version that the one you use for your STM32F4 project.

Please take care, you may not be able to come back to previous MCSDK version later on (but that should not be a problem if I understand your request..)

Thanks and best regards,

Claire

Frakk
Associate II

Hi Claire,

Can you recommend documentation with regards to the position control feature in 5.4.3, and how to implement the communication protocol?

Is there a way to test this feature through the Workbench and Monitor? I'm using the latest WB and I would like to try evaluate position control.

Thank you in advance,

Adam

Hello Adam,

We are currently preparing an application note on this topic. It should be ready soon (now review phase)

Anyway In the meantime...

The position control mode is accessible from MC Workbench:

Control Unit> Firmware Drive Management> Drive Setting 

And you can get more details from the release note:

"Using the Position Control feature

The position control feature can be activated on any configuration that uses an Encoder for speed and position feedback. To activate it, open the Drive Settings dialog from the main configuration panel of the workbench, and select the Position Control item from the Control mode combo box. Dual drive configurations are also supported; the position control can then be activated on any motor equipped with an Encoder.

A set of new APIs is provided to exercise the feature. Among these, the most important ones are the following:

  • void MC_ProgramPositionCommandMotor*(float fTargetPosition, float fDuration)
  • to set the mechanical angle the rotor is to reach and the duration of the movement to reach it
  • float MC_GetCurrentPosition1( void )
  • to retrieve the current rotor position
  • float MC_GetTargetPosition1( void )
  • to get the target rotor position
  • float MC_GetMoveDuration1( void )
  • to get the duration of the programmed movement.

The

MC_ProgramPositionCommandMotor*

functions work as the other ramp functions of the API. For a complete description of this API, refer to the reference documentation of the Motor Control SDK.

Note that when the Position Control is activated on a motor, the speed and torque control mode cannot be used.

The Position Control feature uses floating point arithmetic. It may require a lot of CPU power on STM32F0 and STM32G0 devices that do not have an FPU."

Please take care, with the current monitor, there is no direct access to this feature.

Anyway new motor control toolset should be ready mid-2020 without this limitation.

I hope it helps you,

Claire

PS: I will check communication protocol doc as well...

Thank you so much Claire,

I did read the release notes carefully but I was hoping for an easier path to implement it.

I already have a motor driver running fine with a secondary controller in torque mode and I can also do position control if I share the encoder signals. I would very much like to do position control inside the MC, with only a communication interface to it.

Sending out commands from the secondary controller is not a problem if I know the registers, I don't necessarily need the WB and Monitor.

Martin294
Associate III

What about the EVALKIT-ROBOT-1? It already has a BLDC motor with encoder. Although it's only a Cortex M0 and not something beefier as an M4F as I would have hoped. Can the MCSDK be used for this eval kit as well?

Hello Martin,

Unfortunately not yet, even if the position control basic code is the same...

We will work on this point.

Thanks for your question,

Claire