Thorlabs/Motion_Control_Examples

C++ K-Cube KDC101 CC_WaitForMessage stall after CC_Home command.

Closed this issue · 2 comments

I am controlling a Z825B DC Servo Actuator.
I have a problem where the test code unpredictably stalls in the loop at line
https://github.com/Thorlabs/Motion_Control_Examples/blob/4ebcf1068b0d75f138c02cad16478966872b339c/C%2B%2B/KCube/KDC101/KDC101_Example.cpp#L63

I can see on the KCube LCD and stage position that when this stalls, the cube doesn't attempt to return home.
I have to start and kill the sample code several times until the stage starts slowly returning home.

I'm assuming this is a bug in the API since the code stalls/blocks indefinitely waiting for CC_WaitForMessage after calling CC_Home instead of timing out and returning a failure/ false bool.

This also appears to be a problem when not having the proper logical conditions to escape the while loop after running CC_MoveToPosition. If it continues to query CC_WaitForMessage after MessageType = 2 and MessageId = 1, CC_WaitForMessage will return MessageType = 3 MessageId = 1 about 3 times then stall.

Is there a fix for this?

My current Kcube firmware is V2.2.6

I discovered after poking around the header file that my homing velocity defaults to zero.
Which makes it even more confusing why the stage periodically decides to move home, with the homing velocity set to 0.

Your example code should probably include CC_SetHomingVelocity before it calls CC_Home

Thank you for you comment and suggestion. I will update the script to reflect this. This will allow it to always home as you say if the homing velocity is set to 0.