Every automated equipment which features at least an actuator must have also a system and a procedure for its actuators homing, and of course, this is also true for our Lego Mindstorms Ev3 robots. In this page, a procedure for manual actuators homing is described.
The homing procedure for an actuator is the automated or manual sequence by which the actuator itself is returned to a given position that the control system considers to be the its zero position.
A simple homing procedure for a linear axis actuated by an electric motor, for instance, consists in gently pulling back the axis, until a proximity sensor on the home position detects it; when the proximity sensor detects the axis, the control system stops its movement and reset its sensor readings to zero.
If the equipment does not have absolute encoders, exactly like our Lego Mindstorms Ev3 Motors, a procedure similar to the one described above must be executed at the beginning of each execution of a program.
The Ev3 Contact Sensor is not accurate enough to be effectively used as a homing sensor, and besides it’s just one and there are three motors to calibrate. So we need a manual procedure to reset the axis to the zero position before a program re-start.
Consider the R3PTAR: you need to calibrate the neck orientation and the neck contraction before starting your program to be sure that the program always start from the same zero position.
One way to do this, it is to take advantage of the Monobrick Ev3 Firmware and create a custom menu which can be used to manually home every actuator on board your robot. Simply, create an ItemWithNumericInput for each motor, and on the call back method use the Motor.SpeedProfileTime() method to jog the correspondent axis in the right direction; when you start the program, you will be able to manually home the axis before starting the actual robot program.
The custom menu is presented at the start of the robot program; you can use the up and down to select the desired actuator, and the left and right key to jog it to zero position.
The zero position is conventional and depends on how you have programmed the robot. For the R3PTAR program, the zero positions are with the straight snake body and with the contracted neck.
No need to dismantle the robot before each start anymore !
Code for the manual actuators homing
The C# code is the following:
/// Main class
#region Static Fields
private static int previousNeckValue = 0;
private static int previousHeadValue = 0;
static public MenuContainer container;
public static void Main (string args)
Menu menu = new Menu ("Reptar");
container = new MenuContainer (menu);
// menu.ParentMenuContainer = container;
menu.AddItem(new ItemWithNumericInput("Calibrate Neck", 0, CalibrateNeck, -30, 30));
menu.AddItem(new ItemWithNumericInput("Calibrate Head", 0, CalibrateHead, -30, 30));
menu.AddItem (new MainMenuItem ("Start", Start_OnEnterPressed));
menu.AddItem (new MainMenuItem ("Quit", Quit_OnEnterPressed));
public static void TerminateMenu()
public static void CalibrateNeck (int newValue)
sbyte maxSpeed = 10;
sbyte speed = 0;
Motor Motor = new Motor (MotorPort.OutA);
if (newValue > previousNeckValue)
speed = maxSpeed;
speed = (sbyte)-maxSpeed;
previousNeckValue = newValue;
public static void CalibrateHead (int newValue)
sbyte maxSpeed = 10;
sbyte speed = 0;
Motor Motor = new Motor (MotorPort.OutC);
if (newValue > previousHeadValue)
speed = (sbyte) - maxSpeed;
speed = (sbyte) maxSpeed;
previousHeadValue = newValue;
Motor.SpeedProfileTime (speed, 100, 100, 100, true);
public static void Start_OnEnterPressed()
Reptar reptar = new Reptar ();
public static void Quit_OnEnterPressed()
// Wait a bit