This function is used to perform the calculation of the difference between two integer units, properly handling the "unwrapping" of data whenever the value of an incoming parameter has exceeded the range of the unit used.
Syntax |
real delta_enc16 (real actEnc, real oldEnc) |
---|---|
actEnc |
Contains the first unit (current value). (16-bit int format: range -32768-:-32767) |
oldEnc |
Contains the unit to be subtracted from the first (previous value). (16-bit int format: range -32768-:-32767) |
Result |
Returns the difference actEnc - oldEnc, modulated as if it were a 16-bit integer type variable |
Validity |
Rule, Task |
Note |
A typical example of the function's use is to construct a real quota based on an incremental encoder reading.
In the case of encoders, if actEnc is the current encoder reading and oldEnc is the reading taken in the previous sampling, the function returns the number of bits to which the encoder has moved in the period between the two readings.
Example of use:
|