RA Flexible Software Package Documentation  Release v5.6.0

 
Motor Speed Controller (rm_motor_speed)

Functions

fsp_err_t RM_MOTOR_SPEED_Open (motor_speed_ctrl_t *const p_ctrl, motor_speed_cfg_t const *const p_cfg)
 Opens and configures the Motor Speed Module. Implements motor_speed_api_t::open. More...
 
fsp_err_t RM_MOTOR_SPEED_Close (motor_speed_ctrl_t *const p_ctrl)
 Disables specified Motor Speed Module. Implements motor_speed_api_t::close. More...
 
fsp_err_t RM_MOTOR_SPEED_Reset (motor_speed_ctrl_t *const p_ctrl)
 Reset the variables of Motor Speed Module. Implements motor_speed_api_t::reset. More...
 
fsp_err_t RM_MOTOR_SPEED_Run (motor_speed_ctrl_t *const p_ctrl)
 Run(Start) the Motor Speed Control. Implements motor_speed_api_t::run. More...
 
fsp_err_t RM_MOTOR_SPEED_SpeedReferenceSet (motor_speed_ctrl_t *const p_ctrl, float const speed_reference_rpm)
 Set Speed Reference Data. Implements motor_speed_api_t::speedReferenceSet. More...
 
fsp_err_t RM_MOTOR_SPEED_PositionReferenceSet (motor_speed_ctrl_t *const p_ctrl, motor_speed_position_data_t const *const p_position_data)
 Set Position Reference Data. Implements motor_speed_api_t::positionReferenceSet. More...
 
fsp_err_t RM_MOTOR_SPEED_ParameterSet (motor_speed_ctrl_t *const p_ctrl, motor_speed_input_t const *const p_st_input)
 Set Input parameters. Implements motor_speed_api_t::parameterSet. More...
 
fsp_err_t RM_MOTOR_SPEED_SpeedControl (motor_speed_ctrl_t *const p_ctrl)
 Calculates the d/q-axis current reference.(Main process of Speed Control) Implements motor_speed_api_t::speedControl. More...
 
fsp_err_t RM_MOTOR_SPEED_ParameterGet (motor_speed_ctrl_t *const p_ctrl, motor_speed_output_t *const p_st_output)
 Get Speed Control Parameters. Implements motor_speed_api_t::parameterGet. More...
 
fsp_err_t RM_MOTOR_SPEED_ParameterUpdate (motor_speed_ctrl_t *const p_ctrl, motor_speed_cfg_t const *const p_cfg)
 Update the parameters of Speed Control Calculation. Implements motor_speed_api_t::parameterUpdate. More...
 

Detailed Description

Calculation process for the motor control on RA MCUs. This module implements the Motor speed Interface.

Overview

The motor speed is used to control the speed of motor rotation in an appication. This module should be called cyclically in an application (e.g. in cyclic timer interrupt). This module caliculates d/q-axis current reference with input speed reference, current rotational speed, and d/q-axis current.

Features

The motor speed module has below features.

Configuration

Build Time Configurations for rm_motor_speed

The following build time configurations are defined in fsp_cfg/rm_motor_speed_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
Position Support
  • Enabled
  • Disabled
Disabled Enable position algorithm support.

Configurations for Motor > Motor Speed Controller (rm_motor_speed)

This module can be added to the Stacks tab via New Stack > Motor > Motor Speed Controller (rm_motor_speed).

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_motor_speed0 Module name.
Speed control period (sec)Must be a valid non-negative value0.0005F Period of speed control function.
Step of speed climbing (rpm)Must be a valid non-negative value0.5F Step of speed change at start of open-loop.
Maximum rotational speed (rpm)Must be a valid non-negative value.2650.0F Maximum rotational speed (Limit speed).
Speed LPF omegaMust be a valid non-negative value10.0F Design parameter for speed LPF.
Limit of q-axis current (A)Must be a valid non-negative value0.42F Limit of q-axis current.
Step of speed feedback at open-loopMust be a valid non-negative value0.20F Step of speed feedback at open-loop.
Natural frequencyMust be a valid non-negative value.100.0F Natural frequency for disturbance speed observer.
Open-loop damping
  • Disable
  • Enable
Enable Select enable/disable Open-loop damping control.
Flux weakening
  • Disable
  • Enable
Disable Select enable/disable flux weakening control.
Torque compensation for sensorless transition
  • Disable
  • Enable
Enable Select enable/disable torque compensation for sensorless transition.
Speed observer
  • Disable
  • Enable
Enable Select enable/disable Speed observer process.
Selection of speed observer
  • Normal
  • Disturbance
Normal Select speed observer type.
Control method
  • PID
  • IPD
PID Select the control method [PID or IPD].
Control type
  • Sensoreless
  • Encoder
  • Induction
  • Hall
Sensoreless
Open-Loop
Step of d-axis current climbingMust be a valid non-negative value0.3F Step of d-axis current climbing
Step of d-axis current descendingMust be a valid non-negative value0.3F Step of d-axis current descending
Step of q-axis current descending ratioMust be a valid non-negative value1.0F Step of q-axis current descending ratio
Reference of d-axis currentMust be a valid non-negative value0.3F Reference of d-axis current
Threshold of speed control descendingMust be a valid value600.0F When rotational speed reaches this speed, d-axis current is controlled descending.
Threshold of speed control climbingMust be a valid value500.0F Until rotational speed reaches this speed, d-axis current is controlled climbing.
Period between open-loop to BEMF (sec)Must be a valid non-negative value0.025F Margin time between open-loop control changes to BEMF PI control.
Phase error(degree) to decide sensor-less switch timingMust be a valid value10.0F Phase error(degree) to decide sensor-less switch timing.
Design parameter
Speed PI loop omegaMust be a valid non-negative value5.0F Speed PI loop omega
Speed PI loop zetaMust be a valid non-negative value1.0F Speed PI loop zeta
Estimated d-axis HPF omegaMust be a valid non-negative value2.5F HPF cutoff frequency for ed (Hz)
Open-loop damping zetaMust be a valid non-negative value1.0F Damping ratio of open-loop damping control
Cutoff frequency of phase error LPFMust be a valid non-negative value10.0F Cutoff frequency of phase error LPF
Speed observer omegaMust be a valid non-negative value200.0F Speed observer loop omega
Speed observer zetaMust be a valid non-negative value1.0F Speed observer loop zeta
Motor Parameter
Pole pairsMust be a valid non-negative value.2 Pole pairs
Resistance (ohm)Must be a valid non-negative value8.5F Resistance
Inductance of d-axis (H)Must be a valid non-negative value0.0045F Inductance of d-axis
Inductance of q-axis (H)Must be a valid non-negative value0.0045F Inductance of q-axis
Permanent magnetic flux (Wb)Must be a valid non-negative value0.02159F Permanent magnetic flux
Motor Parameter > Rotor inertia (kgm^2)Must be a valid non-negative value0.0000028F Rotor inertia
Interrupts
CallbackName must be a valid C symbolNULL A user callback function. If this callback function is provided, it is called at timer interrupt.
Input dataName must be a valid C symbolNULL Structure for Speed control Input. If you set this content, Speed Control function read these data automatically. (No need to use Set API.)
Output dataName must be a valid C symbolNULL Structure for Speed control Output. If you set this content, Speed Control function write need data automatically. (No need to use Get API.)

Clock Configuration

This module doesn't depend on clock setting, because this module is a simple calculation process.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Limitations

Examples

Basic Example

This is a basic example of minimal use of the motor speed in an application.

void motor_speed_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
/* Initializes the module. */
err = RM_MOTOR_SPEED_Open(g_motor_speed0.p_ctrl, g_motor_speed0.p_cfg);
handle_error(err);
/* Set speed reference before get current reference */
(void) RM_MOTOR_SPEED_SpeedReferenceSet(g_motor_speed0.p_ctrl, 104.72F);
/* Set position reference before get current reference
* (Basically Exclusive to SpeedReferenceSet. This is only sample,) */
(void) RM_MOTOR_SPEED_PositionReferenceSet(g_motor_speed0.p_ctrl, &g_posref_sample);
/* Basically run this module at cyclic interrupt (e.g. AGT timer).
* This implementation is an example. */
// while (true)
{
/* Application work here. */
/* Set input parameter data before get current reference */
(void) RM_MOTOR_SPEED_ParameterSet(g_motor_speed0.p_ctrl, &g_test_speed_input);
/* Activate Speed Process */
(void) RM_MOTOR_SPEED_Run(g_motor_speed0.p_ctrl);
/* Perform Speed Control Process */
(void) RM_MOTOR_SPEED_SpeedControl(g_motor_speed0.p_ctrl);
/* Get output parameters */
(void) RM_MOTOR_SPEED_ParameterGet(g_motor_speed0.p_ctrl, &g_test_speed_output);
//
/* Update parameters */
(void) RM_MOTOR_SPEED_ParameterUpdate(g_motor_speed0.p_ctrl, &g_motor_speed0.p_cfg);
}
/* Reset Speed Control */
(void) RM_MOTOR_SPEED_Reset(g_motor_speed0.p_ctrl);
/* Close Speed Control */
(void) RM_MOTOR_SPEED_Close(g_motor_speed0.p_ctrl);
}

Enumerations

enum  motor_speed_control_type_t
 
enum  motor_speed_openloop_damping_t
 
enum  motor_speed_flux_weaken_t
 
enum  motor_speed_less_switch_t
 
enum  motor_speed_observer_switch_t
 
enum  motor_speed_observer_select_t
 
enum  motor_speed_ctrl_status_t
 

Enumeration Type Documentation

◆ motor_speed_control_type_t

Enumerator
MOTOR_SPEED_CONTROL_TYPE_SENSORLESS 

Sensorless type.

MOTOR_SPEED_CONTROL_TYPE_ENCODER 

Encoder type.

MOTOR_SPEED_CONTROL_TYPE_HALL 

Hall type.

MOTOR_SPEED_CONTROL_TYPE_INDUCTION 

Induction type.

◆ motor_speed_openloop_damping_t

Enumerator
MOTOR_SPEED_OPENLOOP_DAMPING_DISABLE 

Disable openloop damping.

MOTOR_SPEED_OPENLOOP_DAMPING_ENABLE 

Enable openloop damping.

◆ motor_speed_flux_weaken_t

Enumerator
MOTOR_SPEED_FLUX_WEAKEN_DISABLE 

Disable flux-weakening control.

MOTOR_SPEED_FLUX_WEAKEN_ENABLE 

Enable flux-weakening control.

◆ motor_speed_less_switch_t

Enumerator
MOTOR_SPEED_LESS_SWITCH_DISABLE 

Disable soft switching between open-loop mode and normal field oriented control mode.

MOTOR_SPEED_LESS_SWITCH_ENABLE 

Enable soft switching between open-loop mode and normal field oriented control mode.

◆ motor_speed_observer_switch_t

Enumerator
MOTOR_SPEED_OBSERVER_SWITCH_DISABLE 

Disable speed observer.

MOTOR_SPEED_OBSERVER_SWITCH_ENABLE 

Enable speed observer.

◆ motor_speed_observer_select_t

Enumerator
MOTOR_SPEED_OBSERVER_SELECT_NORMAL 

Normal speed observer.

MOTOR_SPEED_OBSERVER_SELECT_DISTURBANCE 

Disturbance speed observer.

◆ motor_speed_ctrl_status_t

Enumerator
MOTOR_SPEED_CTRL_STATUS_INIT 

Speed control status is INIT.

MOTOR_SPEED_CTRL_STATUS_BOOT 

Speed control status is BOOT.

MOTOR_SPEED_CTRL_STATUS_RUN 

Speed control status is RUN.

Function Documentation

◆ RM_MOTOR_SPEED_Open()

fsp_err_t RM_MOTOR_SPEED_Open ( motor_speed_ctrl_t *const  p_ctrl,
motor_speed_cfg_t const *const  p_cfg 
)

Opens and configures the Motor Speed Module. Implements motor_speed_api_t::open.

Return values
FSP_SUCCESSMotor Speed Module successfully configured.
FSP_ERR_ASSERTIONNull pointer, or one or more configuration options is invalid.
FSP_ERR_ALREADY_OPENModule is already open. This module can only be opened once.
FSP_ERR_INVALID_ARGUMENTConfiguration parameter error.

◆ RM_MOTOR_SPEED_Close()

fsp_err_t RM_MOTOR_SPEED_Close ( motor_speed_ctrl_t *const  p_ctrl)

Disables specified Motor Speed Module. Implements motor_speed_api_t::close.

Return values
FSP_SUCCESSSuccessfully closed.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SPEED_Reset()

fsp_err_t RM_MOTOR_SPEED_Reset ( motor_speed_ctrl_t *const  p_ctrl)

Reset the variables of Motor Speed Module. Implements motor_speed_api_t::reset.

Return values
FSP_SUCCESSSuccessfully reset.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SPEED_Run()

fsp_err_t RM_MOTOR_SPEED_Run ( motor_speed_ctrl_t *const  p_ctrl)

Run(Start) the Motor Speed Control. Implements motor_speed_api_t::run.

Return values
FSP_SUCCESSSuccessfully start.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SPEED_SpeedReferenceSet()

fsp_err_t RM_MOTOR_SPEED_SpeedReferenceSet ( motor_speed_ctrl_t *const  p_ctrl,
float const  speed_reference_rpm 
)

Set Speed Reference Data. Implements motor_speed_api_t::speedReferenceSet.

Return values
FSP_SUCCESSSuccessfully data is set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SPEED_PositionReferenceSet()

fsp_err_t RM_MOTOR_SPEED_PositionReferenceSet ( motor_speed_ctrl_t *const  p_ctrl,
motor_speed_position_data_t const *const  p_position_data 
)

Set Position Reference Data. Implements motor_speed_api_t::positionReferenceSet.

Return values
FSP_SUCCESSSuccessfully data is set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTInput structure pointer is NULL.

◆ RM_MOTOR_SPEED_ParameterSet()

fsp_err_t RM_MOTOR_SPEED_ParameterSet ( motor_speed_ctrl_t *const  p_ctrl,
motor_speed_input_t const *const  p_st_input 
)

Set Input parameters. Implements motor_speed_api_t::parameterSet.

Return values
FSP_SUCCESSSuccessfully data is set.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTOutput pointer is NULL.

◆ RM_MOTOR_SPEED_SpeedControl()

fsp_err_t RM_MOTOR_SPEED_SpeedControl ( motor_speed_ctrl_t *const  p_ctrl)

Calculates the d/q-axis current reference.(Main process of Speed Control) Implements motor_speed_api_t::speedControl.

Return values
FSP_SUCCESSSuccessful data calculation.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_MOTOR_SPEED_ParameterGet()

fsp_err_t RM_MOTOR_SPEED_ParameterGet ( motor_speed_ctrl_t *const  p_ctrl,
motor_speed_output_t *const  p_st_output 
)

Get Speed Control Parameters. Implements motor_speed_api_t::parameterGet.

Return values
FSP_SUCCESSSuccessfully the flag is gotten.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTOutput pointer is NULL.

◆ RM_MOTOR_SPEED_ParameterUpdate()

fsp_err_t RM_MOTOR_SPEED_ParameterUpdate ( motor_speed_ctrl_t *const  p_ctrl,
motor_speed_cfg_t const *const  p_cfg 
)

Update the parameters of Speed Control Calculation. Implements motor_speed_api_t::parameterUpdate.

Return values
FSP_SUCCESSSuccessfully data was updated.
FSP_ERR_ASSERTIONNull pointer.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_INVALID_ARGUMENTConfiguration parameter error.