- Description:
- AmpFaultTriggerSampleGet returns the MotionController::SampleCounterGet() value the firmware captured when the Amp Fault condition (the drive reports a fault) last changed from false to true. It identifies one trigger episode: it does not change while the condition stays true, it is not changed by polling or by ClearFaults(), and a new sample is captured when the condition clears and triggers again. 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()