Beckhoff Automation GmbH & Co. KG TwinCAT 2 | ADS-Script-DLL — 4.2 Reading and writing of PLC variables

Examples WScript.echo("VarInt8 = ", VarInt8); VarInt16 = TcClientSync.ReadVar(".PLCIntVar"); WScript.echo("VarInt16 = ", VarInt16); VarInt32 = TcClientSync.ReadVar(".PLCDIntVar"); WScript.echo("VarInt32 = ", VarInt32); VarReal32 = TcClientSync.ReadVar(".PLCRealVar"); WScript.echo("VarReal32 = ", VarReal32); VarReal64 = TcClientSync.ReadVar(".PLCLRealVar"); WScript.echo("VarReal64 = ", VarReal64); if (TcClientSync.ReadAdsState() == 5) { WScript.echo("PLC is running!\nStop PLC."); TcClientSync.WriteAdsState(6); } Unpack the example program https://infosys.beckhoff.com/content/1033/ tcscriptdll/Resources/ 12459716107/.zip 'Windows Scripting Host'.

4.2 Reading and writing of PLC variables As mentioned in the introduction, the ADS Script DLL is primarily designed for scripting languages. Nevertheless, at this point is a Visual Basic program. It only serves to better demonstrate the capabilities of the ADS Script DLL. For applications that are to be created with Visual Basic, the ADS-OCX is better suited. First load the PLC program into the local PLC (runtime system 1) on your PC. Then start the Visual Basic program: Unless you provide some other indication, a communication channel is created to your local PLC. By entering a different AdsAmsNetId and port number, you can connect to a different runtime system on another PC.

The above-mentioned PLC program, however, must still be active on that other runtime system. It is also necessary that a remote computer, if selected, is entered into the TwinCAT System Control. You can either read the PLC variables by address (IndexGroup and IndexOffset), or by variable name. The same applies to writing new values. This has no meaning for the operator. It is only to list the two possibilities. In the upper right corner the state of the PLC can be read and changed. A 5 corresponds to the RUN state, while a 6 corresponds to STOP. TX1000 30 Version: 1.0