Tutorial 4-1: Homing

When the engine is started, the position of the axis may not be indicative of the axis position on the physical machine. The homing function aligns the axis coordinates to the physical machine by searching for the position on the physical machine where the axis position is 0. This zero position is called the home position.

To find the zero position, signals from sensors such as the home switch, limit switches, Z-pulses (index pulses), and touch probes are used. These sensors will signal the engine to set the home position when the axis reaches the physical location of the sensor on the machine during a homing routine.

Which sensor is used and how are described in detail in Homing. Each home type (method of homing) has advantages and disadvantages.

After the homing routine successfully completes, the axis coordinates will be aligned with the physical coordinates of the machine. After homing is finished, position commands can be commanded using the machine coordinates.

The following code executes a homing routine that uses the home switch. The home switch must be attached to the machine and configured appropriately. If using the simulator engine, the SimuConfigurator utility in the WMX3 installation directory (by default “C:\Program Files\SoftServo\WMX3”) can be used to simulate the home switch.

Config::HomeParam homeParam;

//Read home parameters
err = wmxlib_cm.config->GetHomeParam(0, &homeParam);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to read home parameters. Error=%d (%s)\n", err, errString);
    goto exit;
}

homeParam.homeType = Config::HomeType::HS; //Set home type to search for home switch

//Write home parameters
err = wmxlib_cm.config->SetHomeParam(0, &homeParam);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to write home parameters. Error=%d (%s)\n", err, errString);
    goto exit;
}

//Start homing routine
err = wmxlib_cm.home->StartHome(0);
if (err != ErrorCode::None) {
    wmxlib_cm.ErrorToString(err, errString, sizeof(errString));
    printf("Failed to start homing. Error=%d (%s)\n", err, errString);
    goto exit;
}