How to set programmatically the stepping mode of a stepper motor driver in Simscape?

1 次查看(过去 30 天)
I'm running a Simscape model stepper_motor.slx inspired by the demo "Stepper Motor with Control" (file ee_motor_stepper.slx). This model contains a Stepper Motor Driver block where it is possible to choice the stepping mode and eventually the number of microsteps per step.
I want to write program simulation_stepper.mlx which sets these parameters programmatically, or at least which can retrieve the values of the parameters set by the user, but I cannot find any example/documentation on how to do it. At present time the user must configure automatically the .mlx and the Simscape model in the same way, which is clearly nasty and error prone.
Any idea? Thank you in advance.

回答(1 个)

Prathamesh
Prathamesh 2023-7-18
Hi,
I understand that you want to programmatically update the parameters of the Stepper Motor Driver block. This can be done by using ‘get_param’ and ‘set_param’ functions.
%to update the stepping mode
get_param('stepper_motor/Stepper Motor Driver', 'value@stepping_mode')
set_param('stepper_motor/Stepper Motor Driver', 'stepping_mode', 'microStep')
%to update the number of micro steps
get_param('stepper_motor/Stepper Motor Driver', 'value@numMicroSteps')
set_param('stepper_motor/Stepper Motor Driver', 'numMicroSteps', '8')
Also save the model after setting appropriate parameters to reflect the changes.
Please refer to the documentation of get_param’ and ‘set_param’ functions attached.
I hope this resolves your issue.

类别

Help CenterFile Exchange 中查找有关 Electrical Sensors 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by