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!