I am currently working on a project that uses large motors. I want the project to return to a "starting position" (0,0,0) at the touch of a button so that it can be used multiple (identical) times. How can I do this with the regular Mindstorms EV3 software (I am using the education version)?
1 Answer
The simplest way to "remember" a starting position is to make the starting position 0
. You can do this using Rest in the Motor Rotation block (1). After your motors have moved (simulated by (2)), you can use a loop (3) to run the motors back to zero.
The basic idea though is that if the motor position is negative, then we need to run the motor in the positive direction and vice versa. This way we run back towards a position of 0
. Once we reach a motor position of 0
, we exit from the loop and stop the motor (5).
This is meant to be an example to point you in the right direction and can be improved. For example, you could use a proportional controller at (4) to slow the motor as it nears the 0
position. The sample code as it is below will oscillate several times before it gets exactly to 0
, which is not very nice.
Additionally, you will need to add code that waits for a button press before starting the loop and you will need additional loops for each motor.