User guide

77
VTB USER GUIDE
NG_ENC - ENCODER INPUTS
This function allows to read the quadrature encoder input of each channel equipped on the expansion card NG-IO. The
resolution is 32 bits. This function read only the increment which will be added to a variable passed by its pointer.
Therefore the real encoder counter will be contained in a variable defined in the application and it will can be zeroed in
any time. For a correct processing of the encoders we recommend to use this function only in TASK PLC and then use it
at the occurrence.
The selection of the channel is made by an index from 0 to 15, each expansion manages two channels:
Channel Index
Expansion number
0
Card 0 (nearest NG35)
1
2
Card 1
3
...
...
...
14
Card 7
15
Syntax
NG_ENC(Char Chan, Long *Val)
Parameters
Chan Number of channel (from 0 to 15)
val Pointer to a long variable where will be contained the counter
Example
Used variables:
posx LONG ' Counter encoder channel 0
posy LONG ' Counter encoder channel 1
In TASK PLC:
ng_enc(0,posx())
ng_enc(1,posy())
EVERYWHERE:
if posx>25000 ' Read encoder channel 0
. . .
posx=0 ' Reset counter channel 0
endif
if posy>200000 ' Read encoder channel 1
. . .
posy=1000 ' Preset counter channel 1
endif