The encoder channels can also be used to read a single pulse train. In the Basic Wiring Diagram,
this can be seen on J4-3, encoder 2 channel A. When using the Setup_Encoder, it is important to
turn off any fault checking. The normal ENC#_Count and ENC#_Vel variable will be valid.
Note that ENC#_Dir and ENC#_Error have no meaning in a single pulse train measurement.
Setup_ENC(ENC2, ENC_COUNT, 0, 0)
; Count mode with error checking turned off
Normally, the encoder will be powered off the +5 volt supply on J4-15 (ground is J4-16). The
current leaving this pin is measured and placed in the variable ADC11_Output. The voltage at
this pin is placed in ADC11_Output. Checking the actual values against a known nominal value
will allow the VCL to catch a disconnected encoder/sensor (current is too low on ADC11) or a
short/excessive current (current is too high on ADC11).
if (ADC11_Output < 10)
{
;Error! encoder is disconnected, current draw is too low
}
if (ADC11_Output > 1000)
{
;Error! There is a short dragging down the supply or too much current draw.
}
If the sensor or encoder needs +12V power, that is available at J3-4 and the output current is
sensed at ADC-12.
Arrays
Strings are handled in a unique way in VCL. All the string definitions are taken in order they
appear in VCL and concatenated together into one large string array that is attached to the end
of the VCL program. The array of strings is then indirectly address through there index into the
array. If we know the first message in the array, we can index off it to find the next. In this way,
a one dimensional array of strings can be made and addresses. This can be useful in creating
messages for the Spyglass.
The following example creates a 5 string array and outputs a new message every 500 ms, to the
Spyglass depending on a user variable.
Display_Offset equals User1
MSG_01 string "HELLO"
MSG_02 string "ARRAYS"
MSG_03 string "WITHIN"
MSG_04 string "VCL"
MSG_05 string "STRINGS"
Display_Offset = 0
Main:
Put_Spy_Text(MSG_01 + Display_Offset)
setup_delay(DLY2, 500)
while (DLY2_Output <> 0) {} ; 500 msec
Display_Offset = Display_Offset + 1
If ( Display_Offset = 5)
{
Display_Offset = 0 ; reset the offset if it is past the last message
}
goto Main
1310 Vehicle Control System Users Manual Release Rev B Page 43 of 51