cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure RPM with STEVAL-ESC002V1?

WSeun.1
Associate

I succeeded in operating the Tartget Motor with STEVAL-ESC002V1.

However, since the STEVAL-ESC002V1 is not linked with'Motor Profiler 5.4.4' SDK, it is impossible to check the motor operating speed.

I know that STSPIN32F0A has a function that can measure the motor speed.

Does the STEVAL-ESC002V1 have the ability to measure the RPM of a motor like any other motor Eval Kit?

Or can I read RPM information with UART?

I have not modified the firmware of the'STSW-ESC002V1' you provide at all.

Please help if there is anything that can help with RPM measurement.

If the experiment is successful, STSPIN32F0A will be applied for mass production in our equipment.

5 REPLIES 5
Dario CUCCHI
ST Employee

Hi @WSeun.1​ , welcome to the ST Community !

Using the STSW-ESC002V1 firmware, you can enable the UART peripheral and send commands to read the actual speed of the motor.

Let me describe how with a step by step explanation.

First step is to modify the boards in order to connect the two wires needed by the UART interface.

On J2 connector you can find the TX on pin 1 and RX on pin 2, as described in the user manual UM2518.

Second step: you have to modify the firmware, in order to enable the UART and the closed loop control.

Go to the file “MC_SixStep_param_7PP_3S_propeller.h�?

0693W000003BWYTQA4.png

At the beginning in the "BASIC PARAMETERS" You have to modify:

- NUM_POLE_PAIRS: this is the number of pole pairs of the motor and must be set accordingly.

This parameter is directly used for speed computation, so it must be the one of the motor used.

- TARGET_SPEED: set an initial speed, the motor will start , does the ramp-up and reaches this speed, then it is possible to change the speed using specific UART commands

In order to guarantee a correct startup I would choose a speed in the mid low speed range of your application (for example 3000 or 5000 rpm).

-Also MIN_SPEED and MAX_SPEED should be adjusted according to the specific motor and application.

Third step: you have to modify some project defines in order to enable the UART communication and the closed loop speed control.

Right click on the project name > options… > C/C++ Compiler > Preprocessor tab

0693W000003BWSLQA4.png

0693W000003BWSfQAO.png

In the lower part of the window you can find the “Defined symbols�?; here is what to modify:

- change NO_UART_COMM to UART_COMM: it enables the UART communication

- change ST_PWM_INTERFACE to NO_ST_PWM_INTERFACE: this one is to avoid conflicts.

In fact it disables the reading of the PWM signal: now the speed is only set by sending UART commands

- change OPEN_LOOP to NO_OPEN_LOOP: this enables the controller to operate in closed loop

These parameters are described in the firmware user manual UM2530

We are almost there ! Compile and download the modified firmware in the STEVAL-ESC002V1.

Fourth step: Connect the two wires to the host in order to manage the UART communication, taking care to swap the pins:

- the TX of the STEVAL-ESC002V1 to the RX of the Host controller

- the RX of the STEVAL-ESC002V1 to the TX of the Host controller

Here the UART settings:

- Baud Rate: 230400

- Data bits: 8

- Stop bits: 1

- Parity: None

- Flow ctrl: None

Now the system is ready: try this example, it should be ok for your purposes.

Every command should be terminated by a CR + LF character

  • Send a “STARTM�? command: command starts the motor at the target speed
  • Send a “GETSPD�? command: it returns the motor measured speed
  • Send a “SETSPD�? command: it enables the controller to get a new speed value
  • Send the value: it is the value in rpm
  • Send a “GETSPD�? command to poll the actual motor speed
  • At the end you can stop the motor by sending a “STOPMT�?.

A complete list of the commands available is returned after sending “HELP�? command.

Let me know if this can help with your application development.

Dario CUCCHI
ST Employee

Hi @WSeun.1​ ,

I understand my answer came late, so I apologize and I hope my suggestions are still useful for you.

It would be interesting to know if you can now measure the speed of your motor.

Your post can help other community members dealing with similar problems, so you can mark the answer as best to improve its visibility in the community researches.

Thank You !

GenuineDeveloper
Associate III

@Dario CUCCHI​ 

Thank you for sharing this information. It was very helpful in getting started with our project. However, we are facing an issue in our application. We tried sending the STARTM command but only to receive a failure message in response. It displays: Status: LF_TIMER_FAILURE.

In the documentation, it has mentioned that Low frequency timer has got something to do with the step timer. On analyzing the code, this error is called when:

if (lf_timer_failure!=0)
  {
    MC_StopMotor();
    SIXSTEP_parameters.STATUS = LF_TIMER_FAILURE;
    BSP_BOARD_FAULT_LED_ON();
  }
 
// where (lf_timer_failure!=0) occurs when:
 
  if ((ARR_LF == 0xFFFF) && (SIXSTEP_parameters.STATUS == RUN))
  {
    lf_timer_failure++;
  }
// in the MC_SixStep_NEXT_step() function
 

What could be the possible reason leading to this error? Will any mismatch in the num_pole_pairs or target_speed lead to this error?

Dario CUCCHI
ST Employee

Hi @GenuineDeveloper​ ,

Yes, the LF TIMER is used to measure the time interval between one step and another of the six-step sequence, and eventually the speed of the motor.

The actual speed in rpm depends on the pole pairs number, as well.

However the pole pairs mismatch should not lead to this error, just it introduces a mismatch in the target speed of the motor.

If the algorithm cannot detect the speed, by measuring the BEMF generated by the motor, the timer returns a “LF_TIMER_FAILURE�?.

This can occur for different reasons, the main ones could be:

  • One ore more phases of the motor are disconnected
  • heavy mechanical load is connected to the motor, so with a too fast start-up the motor cannot run correctly and the BEMF is not detected. In this case try to decrease the acceleration.
  • The other parameter you can check is the supply voltage of the board it should be stable at the start-up without any excessive drop. In fact, at the start-up the current required by the motor is bigger.

I hope this can help you !

Laurent Ca...
Lead II

The question has been also set in the "STM32 Motor Control" section.

Best regards