Homing not attained even after homing sucessfull

Hi there.

I am running the DS402 Drive Homing sample code on RSI website, converted to C++. Everything is going according to plan except one little thing which I am not able to understand. Following is what is happening.

Setup:
Homing Method = 27
Speed to Search for Switch = 5 rpm
Speed to zero = 5 rpm
Homing acceleration = 4 rpss

Status word value before homing starts = 16951 or 4237 in HEX
Status word value once homing is triggered and the motor settles = 54839 or D637
Status word value after the drive is switched back to CSP mode = 49776 or C338

Homing is happening successfully and motor comes to rest after it is complete. However I am still getting this error message. “Homing Sample App Failed with Exit Code: -1”

I am noticing that the code is not going in the following loops in the example code.

// 4. EVALUATE HOMING SUCCESS
if ((statusWordValue & STATUS_WORD_HOMING_ATTAINED_BIT) == 1)
{
    std::cout << "Axis homed" << std::endl;
}
else if ((statusWordValue & STATUS_WORD_HOMING_ERROR_BIT) == 1)
{
    std::cout << "Error Occured during homing." << std::endl;
}

What could be the reason for it? Are there any drawbacks if the homing attained bit is not registering that the homing is indeed successful?

Hi @rdhillon ,

It appears your DS402 homing succeeded, if you are getting 0xD637 from the status word “once homing is triggered and the motor settles.”

We would expect the drive, when in homing mode, to use the 13th bit (aka Bit 12) to signify if homing succeeded. Since that bit is set in 0xD637, we would expect you to see “Axis homed.”

I think the logic is wrong and should be:

// 4. EVALUATE HOMING SUCCESS
if (statusWordValue & STATUS_WORD_HOMING_ATTAINED_BIT)
{
    std::cout << "Axis homed" << std::endl;
}
else if (statusWordValue & STATUS_WORD_HOMING_ERROR_BIT)
{
    std::cout << "Error occurred during homing." << std::endl;
}

The fact that you’re getting “Homing Sample App Failed with Exit Code: -1” must be a different issue, let us know what logic you have for the return from the main(…) function.

Thank you ! The modified code worked. I think it should be updated on the website as well for accuracy.

Thanks for pointing out the return value for exit code. I was missing this line in my try block inside the main function. “exitCode = 0; // Set the exit code to success.”

Its all good now :slight_smile:

1 Like