User guide

84
VTB USER GUIDE
11.12 Functions for NGQx Analog Outputs and encoder inputs
Functions for NGQx Analog Outputs and encoder inputs
Hardware NGQx
NG_DAC – Analog Outputs NGQx
This function allows to update the analog outputs of each channel equipped in the NGQx This expansions have 2 digital
to analog converter at 12 bit, with a range of +/-10V. Therefore a value of +2047 corresponds to 10V in output, a value
of -2047 corresponds to -10V.
The selection of the channel is made by an index from 0 to 1.
WARNING: For enable the analog outputs on NGQx, is necessary set the following property
ENCODER ENABLE=true on NGQ INIT Object
Syntax
NG_DAC(Char Chan, Long Val)
Parameters
Chan Number of channel (from 0 to 1)
val Value of the output
Example
Used variables:
val LONG
channel CHAR
channel = 0
val = 1024
ng_dac(channel, val) ' write 1024 (~5V) to analog channel 0
ng_dac(1,512) ‘ write 512 (~2,5V ) to analog channel 1
NG_DAC_CAL - CALIBRATION OF THE ANALOG OUTPUT OFFSET NGQx
This function allows to calibrate the OFFSET of the analog outputs. Usually it can be occur that the analog output has a
little value of voltage (OFFSET) in the order of mV also if zero has been set. With ng_dac_cal we can null this voltage
setting a value opposite to the offset one. Remind that for each unit the output value will be about 4mV.
Syntax
NG_DAC_CAL(Char Ch,Long Offset)
Parameters
Chan Number of channel (from 0 to 1)
Offset OFFSET value
WARNING: THE OFFSET VALUE ISN'T SAVED AND IT MUST BE SET AT EACH TURN-ON.
NG_ENC - ENCODER INPUTS
This function allows to read the quadrature encoder input of each channel equipped on the expansion card NGQx 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 1
WARNING: For enable the encoder inputs on NGQx, is necessary set the following property