How to make a Simulink model that pans LEGO EV3 motor between 2 encoder positions

7 次查看(过去 30 天)
Hey,
I am trying to create a Simulink model that turns a motor one direction until the encoder reads a certain angle and then, once hit, turns the other direction until it hits a lower angle. At the end, I want to return to the 0 position but am having trouble getting the motor to switch directions.
I attached what I thought would work for just changing the direction of the motor, however, if the encoder blows past the desired angle it will continue to rotate in the same direction forever. I have the default speed of the motor block set to 15 and I am using a LEGO Medium motor.
Any help will be greatly appreciated!

回答(1 个)

jeff matejka
jeff matejka 2019-2-16
if you haven't figured thus out yet: Calculate the difference between where you want the encoder to be and where you are, use that to control the speed. Without more info on your goal, theres multiple ways to implement this, such as using a compare block where if the difference is greater than zero, it keeps moving at your speed and when it is zero, you could multiple 0 times the speed. Or use a proportional controller to slow the motor gradually as it closes in on zero.
hope this helps

社区

更多回答在  Power Electronics Control

类别

Help CenterFile Exchange 中查找有关 LEGO MINDSTORMS EV3 Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by