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

3 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Prathamesh
Prathamesh el 18 de Jul. de 2023
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.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by