C# API - AddLinearMoveRel Blocking Implementation
Posted: Mon May 06, 2024 2:37 pm
Hi All,
I am working on upgrading our custom manufacturing control systems to use the UC100 controller.
So far, the API has been great and we've been able to upgrade all of our systems to use the UC100.
A typical work-flow looks like this:
It seems the AddLinearMoveRel functions does not block and will return control to the callee.
This work great for most of our use cases, but other times I need to know when the movement is complete.
I have used this method below to wait for the desired movement to complete:
Is there a better implementation for this?
I'm not sure if polling the controller is the right way to go about this.
I could be missing something completely, so any tips are appreciated.
Cheers,
JG
I am working on upgrading our custom manufacturing control systems to use the UC100 controller.
So far, the API has been great and we've been able to upgrade all of our systems to use the UC100.
A typical work-flow looks like this:
- Code: Select all
/*
Move the X table in inches
*/
int ret = AddLinearMoveRel(0, steps, 1, speed, dir);
if (ret != (int)ReturnVal.UC100_OK)
{
MessageBox.Show(SomeHelpStr);
return;
}
// more machine code, drive a blade down, etc..
It seems the AddLinearMoveRel functions does not block and will return control to the callee.
This work great for most of our use cases, but other times I need to know when the movement is complete.
I have used this method below to wait for the desired movement to complete:
- Code: Select all
private bool IsMotorRunning()
{
Stat s = new Stat { };
int ret = GetStatus(ref s);
return s.Idle == false;
}
private void ExampleMove(double steps, double speed, bool dir)
{
int ret = AddLinearMoveRel(0, steps, 1, speed, dir);
if (ret != (int)ReturnVal.UC100_OK)
{
MessageBox.Show(SomeHelpStr);
return;
}
while (IsMotorRunning());
}
Is there a better implementation for this?
I'm not sure if polling the controller is the right way to go about this.
I could be missing something completely, so any tips are appreciated.
Cheers,
JG