AdsRead[Datatype]VarConnect

AdsReadBoolVarConnect

AdsReadIntegerVarConnect

AdsReadLongVarConnect

AdsReadSingleVarConnect

AdsReadDoubleVarConnect

AdsReadStringVarConnect

Creates a fixed connection between a Visual Basic variable of type boolean, integer, long, single, double or string and a data item from an ADS device.

object.AdsRead[Datatype]VarConnect(
  nIndexOffset As String,
  cbLength As Long,
  nRefreshType As Integer,
  nCycleTime As Integer,
  pData As [Datatype]
) As Long

Parameter

adsVarName

[in] Name of the ADS variable

cbLength

[in] Length of the data in bytes (see VB variable lengths)

nRefreshType

[in] Type of data exchange between VB variable and ADS variable (see the ADSOCXTRANSMODE data type)

nCycleTime

[in] Read cycle in ms

pData

[in] Visual Basic variable into which the data is written from the ADS variable

Return value

See ADS error codes

Comment

When the PLC variable is changed, the event AdsReadConnectUpdate() is triggered.

If the connection to an ADS variable is no longer required, it should be released using the AdsRead[Datentyp]Disconnect() method. If only certain specific values are required in a form, the connection should only be created when the form is loaded, and should be released again when the form is closed.

Only one handle is created per PLC variable, i.e. when connecting several variables to a PLC variable, the event AdsReadConnectUpdate() is called accordingly several times with the same handle when changes are made.

Note on PLC: Ensure that 'Symbol download' is enabled in PLC Control under Project / Options / TwinCAT. You will find more detailed information in the PLC Control manual.

The method's first parameter is composed of the POE name and the PLC variable that is to be addressed. If, for instance, the variable 'SPSVar1' from the function 'Funk1' is to be accessed, then 'Funk1.SPSVar1' must be supplied as the first parameter. When global variables are being accessed, the POE name is omitted, as, for instance, in '.SPSGlobVar'. The parameter 'adsVarName' does not distinguish between upper and lower case letters.

If a variable from the PLC is connected to a Visual Basic variable, you must specify 2 as the length, since Visual Basic manages Boolean variables internally with 2 bytes.
Note on NC: In the System Manager, the symbol download must be activated for each axis. This can be specified in the configuration dialog for the axis under 'General'. The 'Create symbols' box must be checked. See System Manager manual.

The symbolic names of the individual NC parameters have a fixed specification, and can be found in the NC documentation.

This method has been replaced by AdsReadVarConnectEx(). In future, use AdsReadVarConnectEx(), since AdsReadBoolVarConnect() will no longer be maintained, and will only be included for reasons of compatibility.

Example

-