User guide

81
VTB USER GUIDE
NG_ENC - ENCODER INPUTS
This function allows to read the quadrature encoder input of each channel equipped on the expansion card NGMsX. 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 5, each expansion manages two channels:
Channel Index
Expansion Number
0
Board 0 ( nearest NGMEVO)
1
2
Board 1
3
4
Board 2
5
Syntax
NG_ENC(Char Chan, Long *Val)
Parameters
Chan Number of channel (from 0 to 5)
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
NG-T0 - ZERO INDEX OF ENCODER NGMsX
This function allows to read the state of the zero index input of each encoder channel equipped in the expansion card
NGMsX. The channel selection is made as for the reading of encoders.
Syntax
NG_T0(Char Chan) as char
Parameters
Chan Number of channel (from 0 to 5)
Return value:
State of the index input: