Emergency Stop based on external signal
Posted: Sun Jul 01, 2018 7:22 am
Hi,
I would like to implement an Emergency Stop routine based on a signal received from an external device through USB. I know there are delays involved in this problem (because of the operating system, because of the USB and because of different controllers utilized) but I want to do it anyway.
Now, my program has to move a stepper motor with precise position ending so I suppose, CONTROL_MODE_RUN and sslep(certain amount) may not the best solution (am I wrong?). So be it CONTROL_MODE_STEP.
It moves correctly with these instructions:
but I really don't know how to implement this Emergency Stop in Phidget Environment. I have a background on microcontrollers, so there I would implement an Interrupt routine, but here I don't know which route to follow. Does this instruction fullfill my needs? If so, can you explain to me what to insert instead of void (CCONV *asyncHandler)(PhidgetHandle phid, void *ctx, PhidgetReturnCode res)?
Thank you in advance!
I would like to implement an Emergency Stop routine based on a signal received from an external device through USB. I know there are delays involved in this problem (because of the operating system, because of the USB and because of different controllers utilized) but I want to do it anyway.
Now, my program has to move a stepper motor with precise position ending so I suppose, CONTROL_MODE_RUN and sslep(certain amount) may not the best solution (am I wrong?). So be it CONTROL_MODE_STEP.
It moves correctly with these instructions:
Code: Select all
for (int j = 0; j < NumAcquisition1; ++j) {
RotSteps = (TotalSteps1 / (NumAcquisition1 - 1)) * j;
printf("\nSegment: %d\n", j);
PhidgetStepper_setTargetPosition(BedMotor, BedSteps);
ssleep(5);
}
Code: Select all
PhidgetReturnCodePhidgetStepper_setTargetPosition_async(
PhidgetStepperHandle ch,
double targetPosition,
void (CCONV *asyncHandler)(PhidgetHandle phid, void *ctx, PhidgetReturnCode res),
void *ctx
)
Thank you in advance!