cancel
Showing results for 
Search instead for 
Did you mean: 

B-G431B position control doesn't achieve maximum speed

msingh08
Associate III

Hi all, 

 

I have profiled the motor using the motor profiler V5.4.8 where the motor was able to achieve 4500RPM, and then created a position control project CMWB V6.2.1. the motor is using 4096CPT incremental encoders as a primary feedback source. With this project I am only able to achieve maximum speeds of 700RPM and nothing more. Can anyone explain why that would be? I am aware that motor pilot can be used to plot graphs and I have been using that to display the current motor position however I'd like to know if it is possible to plot the target position as well? 

 

 

/**
  ******************************************************************************
  * @file    drive_parameters.h
  * @author  Motor Control SDK Team, ST Microelectronics
  * @brief   This file contains the parameters needed for the Motor Control SDK
  *          in order to configure a motor drive.
  *
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DRIVE_PARAMETERS_H
#define DRIVE_PARAMETERS_H

/************************
 *** Motor Parameters ***
 ************************/

/******** MAIN AND AUXILIARY SPEED/POSITION SENSOR(S) SETTINGS SECTION ********/

/*** Speed measurement settings ***/
#define MAX_APPLICATION_SPEED_RPM       4596 /*!< rpm, mechanical */
#define MIN_APPLICATION_SPEED_RPM       0 /*!< rpm, mechanical,
                                                           absolute value */
#define M1_SS_MEAS_ERRORS_BEFORE_FAULTS 3 /*!< Number of speed
                                                             measurement errors before
                                                             main sensor goes in fault */
/*** Encoder **********************/

#define ENC_AVERAGING_FIFO_DEPTH        16 /*!< depth of the FIFO used to
                                                              average mechanical speed in
                                                              0.1Hz resolution */

/* USER CODE BEGIN angle reconstruction M1 */
#define REV_PARK_ANGLE_COMPENSATION_FACTOR 0
/* USER CODE END angle reconstruction M1 */

/**************************    DRIVE SETTINGS SECTION   **********************/
/* PWM generation and current reading */

#define PWM_FREQUENCY   10000
#define PWM_FREQ_SCALING 1

#define LOW_SIDE_SIGNALS_ENABLING        LS_PWM_TIMER
#define SW_DEADTIME_NS                   750 /*!< Dead-time to be inserted
                                                           by FW, only if low side
                                                           signals are enabled */

/* Torque and flux regulation loops */
#define REGULATION_EXECUTION_RATE     1    /*!< FOC execution rate in
                                                           number of PWM cycles */

#define ISR_FREQUENCY_HZ (PWM_FREQUENCY/REGULATION_EXECUTION_RATE) /*!< @brief FOC execution rate in
                                                           Hz */
/* Gains values for torque and flux control loops */
#define PID_TORQUE_KP_DEFAULT         100
#define PID_TORQUE_KI_DEFAULT         5
#define PID_TORQUE_KD_DEFAULT         100
#define PID_FLUX_KP_DEFAULT           200
#define PID_FLUX_KI_DEFAULT           5
#define PID_FLUX_KD_DEFAULT           100

/* Torque/Flux control loop gains dividers*/
#define TF_KPDIV                      126
#define TF_KIDIV                      16384
#define TF_KDDIV                      8192
#define TF_KPDIV_LOG                  LOG2((126))
#define TF_KIDIV_LOG                  LOG2((16384))
#define TF_KDDIV_LOG                  LOG2((8192))
#define TFDIFFERENTIAL_TERM_ENABLING  DISABLE

#define POSITION_LOOP_FREQUENCY_HZ    ( uint16_t )2000 /*!<Execution rate of position control regulation loop (Hz) */

#define PID_SPEED_KP_DEFAULT          10000/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
#define PID_SPEED_KI_DEFAULT          100/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
#define PID_SPEED_KD_DEFAULT          200/(SPEED_UNIT/10) /* Workbench compute the gain for 01Hz unit*/
/* Speed PID parameter dividers */
#define SP_KPDIV                      32
#define SP_KIDIV                      1024
#define SP_KDDIV                      16
#define SP_KPDIV_LOG                  LOG2((32))
#define SP_KIDIV_LOG                  LOG2((1024))
#define SP_KDDIV_LOG                  LOG2((16))
/* USER CODE BEGIN PID_SPEED_INTEGRAL_INIT_DIV */
#define PID_SPEED_INTEGRAL_INIT_DIV 1 /*  */
/* USER CODE END PID_SPEED_INTEGRAL_INIT_DIV */

#define SPD_DIFFERENTIAL_TERM_ENABLING DISABLE
#define IQMAX_A                          1

/* Default settings */
#define DEFAULT_CONTROL_MODE           MCM_POSITION_MODE //MCM_SPEED_MODE
#define DEFAULT_TARGET_SPEED_RPM       0.1
#define DEFAULT_TARGET_SPEED_UNIT      (DEFAULT_TARGET_SPEED_RPM*SPEED_UNIT/_001HZ)
#define DEFAULT_TORQUE_COMPONENT_A       0
#define DEFAULT_FLUX_COMPONENT_A         0

#define PID_POSITION_KP_GAIN			30000
#define PID_POSITION_KI_GAIN			1000
#define PID_POSITION_KD_GAIN			22000
#define PID_POSITION_KPDIV				128
#define PID_POSITION_KIDIV				32768
#define PID_POSITION_KDDIV				512
#define PID_POSITION_KPDIV_LOG			LOG2((128))
#define PID_POSITION_KIDIV_LOG			LOG2((32768))
#define PID_POSITION_KDDIV_LOG			LOG2((512))
#define PID_POSITION_ANGLE_STEP			0.01
#define PID_POSITION_MOV_DURATION		30.0

/**************************    FIRMWARE PROTECTIONS SECTION   *****************/
#define OV_VOLTAGE_THRESHOLD_V          28 /*!< Over-voltage
                                                         threshold */
#define UD_VOLTAGE_THRESHOLD_V          8 /*!< Under-voltage
                                                          threshold */
#ifdef NOT_IMPLEMENTED

#define ON_OVER_VOLTAGE                 TURN_OFF_PWM /*!< TURN_OFF_PWM,
                                                         TURN_ON_R_BRAKE or
                                                         TURN_ON_LOW_SIDES */
#endif /* NOT_IMPLEMENTED */

#define OV_TEMPERATURE_THRESHOLD_C      70 /*!< Celsius degrees */
#define OV_TEMPERATURE_HYSTERESIS_C     10 /*!< Celsius degrees */

#define HW_OV_CURRENT_PROT_BYPASS       DISABLE /*!< In case ON_OVER_VOLTAGE
                                                          is set to TURN_ON_LOW_SIDES
                                                          this feature may be used to
                                                          bypass HW over-current
                                                          protection (if supported by
                                                          power stage) */

#define OVP_INVERTINGINPUT_MODE         INT_MODE
#define OVP_INVERTINGINPUT_MODE2        INT_MODE
#define OVP_SELECTION                   COMP_Selection_COMP1
#define OVP_SELECTION2                  COMP_Selection_COMP1

/******************************   START-UP PARAMETERS   **********************/
/* Encoder alignment */
#define M1_ALIGNMENT_DURATION              700 /*!< milliseconds */
#define M1_ALIGNMENT_ANGLE_DEG             0 /*!< degrees [0...359] */
#define FINAL_I_ALIGNMENT_A               1 /*!< s16A */
// With ALIGNMENT_ANGLE_DEG equal to 90 degrees final alignment
// phase current = (FINAL_I_ALIGNMENT * 1.65/ Av)/(32767 * Rshunt)
// being Av the voltage gain between Rshunt and A/D input

#define TRANSITION_DURATION            25  /* Switch over duration, ms */

/******************************   BUS VOLTAGE Motor 1  **********************/
#define  M1_VBUS_SAMPLING_TIME  LL_ADC_SAMPLING_CYCLE(47)
/******************************   Temperature sensing Motor 1  **********************/
#define  M1_TEMP_SAMPLING_TIME  LL_ADC_SAMPLING_CYCLE(47)
/******************************   Current sensing Motor 1   **********************/
#define ADC_SAMPLING_CYCLES (6 + SAMPLING_CYCLE_CORRECTION)

/******************************   ADDITIONAL FEATURES   **********************/

/*** On the fly start-up ***/

/**************************
 *** Control Parameters ***
 **************************/

/* ##@@_USER_CODE_START_##@@ */
/* ##@@_USER_CODE_END_##@@ */

#endif /*DRIVE_PARAMETERS_H*/
/******************* (C) COPYRIGHT 2023 STMicroelectronics *****END OF FILE****/

 

I have attached the code drive_parameters.h file that I am currently using 

1 REPLY 1
GMA
ST Employee

Hello @msingh08,

Where the 700RPM measure come from? Is-it from an external measure or from Motor Pilot tool?
There is an issue on the ENCODER_SPEED value reported on the High Frequency plot of Motor pilot tool that will be corrected on the next MCSDK release. 
Using Motor Pilot Position Control GUI, the speed indicator reports a correct value.

GMA_1-1742379639880.png

 

 

 

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA