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

3 vues (au cours des 30 derniers jours)
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!

Réponses (1)

jeff matejka
jeff matejka le 16 Fév 2019
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

Communautés

Plus de réponses dans  Power Electronics Control

Catégories

En savoir plus sur LEGO MINDSTORMS EV3 Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by