Encoder Inputs
There are two quadrature encoder inputs. These inputs can detect direction, position and
velocity from a 2 channel pulse train, 90 degree offset form each other. To use the encoder
input, it must be first setup for use as a position counter or as a velocity measurement. After
they are set up, the VCL uses special functions to retrieve the count or velocity (in RPM) of the
incoming pulse train. The setup also allows enabling error detection.
Setup_Encoder(4)
The VCL must set up the encoder channel before it can be used. The Setup_Encoder function
sets the mode, conversion factor and error detection parameters for the encoder VCL functions.
Parameters
ENC# Identifies which Encoder channel is to be read
• can be ENC1 or ENC2
Mode Set the encoder to Velocity or Count mode
• use the predefined constant ENC_COUNT or ENC_VELOCITY
Max_PPR Sets the Pulses Per Revolution or the maximum pulse count error
• If the Mode is ENC_VELOCITY, the value sets the pluses that are
seen in one revolution of the encoder. Used to convert to RPM
• If the Mode is ENC_COUNT, the value sets the number of counts
on channel A that can be tolerated without a count on channel B
before an error is declared. A setting of 0 disables error checking.
Max_Time Used only in ENC_COUNT mode
• Sets the time limit that the count error (in Max_PPR) must be
reached within for an error to be declared. Setting this to 0 means
there is no time limit. Time limit= Max_Time x 16milliseconds
Returns
0 – Setup did not execute.
1 – Setup successful.
Error Codes
Bad_ID = an incorrect ENC ID was used.
Examples
Setup_ENC(ENC1, ENC_VELOCITY , 64,0)
; Velocity mode where 64 pulse = one revolution.
; Note the last parameter is don't care, but MUST be filled with something!
Setup_ENC(ENC2, ENC_COUNT, 10, 10)
; Count mode .
; If we have more that 10 counts on one channel without the other in under 160mS = Error!
1310 Vehicle Control System Users Manual Release Rev B Page 34 of 51