APIs, concepts, guides, and more

◆ SoftwarePosLimitTriggerSampleGet()

int32_t SoftwarePosLimitTriggerSampleGet ( )
Description:
SoftwarePosLimitTriggerSampleGet returns the MotionController::SampleCounterGet() value the firmware captured when the Software Positive Limit condition (the position is beyond SoftwarePosLimitTriggerValueGet()) last changed from false to true. It marks the axis entering the limit: it does not change while the axis stays in the limit and it is not changed by polling or by ClearFaults(). Travel limits are direction sensitive so that recovery is possible: moving away from the limit clears its status, but a new sample is captured only after the axis has actually left the limit and entered it again, not when it turns back toward a limit it never left. Writing any of this limit's configuration (Action, TriggerState, TriggerValue, Duration) also restarts the episode: if the condition is still true afterwards, a new sample is captured. If the limit has a Duration, the sample is captured when the Duration is satisfied.

Use it to tell a new fault from one already handled, to compute how long ago the limit triggered, or to compare with the other limits' TriggerSample values to see which one triggered first. Elapsed seconds are ((uint32_t)SampleCounterGet() - (uint32_t)sample) / (double)SampleRateGet(). Subtract as uint32_t: the counter wraps, and in C++ a signed subtraction can overflow. The result is correct for elapsed times under 2^32 samples.

Returns
(int32_t) Sample counter value, or 0 if the condition has not triggered since the controller started. The sample counter wraps, so compare samples by subtraction, not with less-than. (A limit that triggers exactly on sample 0 also reads 0; the counter passes 0 only at start and at the wrap.)

Part of the Limits and Action Configuration method group.

See also
MotionController::SampleCounterGet(), MotionController::SampleRateGet(), StatusBitGet(), SourceNameGet()