modelAdsCommunicatorExample

Example model to show ADS-Communication

Extends from Internal.AdsCommunicatorBasic (Partial Model of ADS-Interface, minimum code needs additional information).

Information

How to connect to TwinCAT PLC

To connect to a TwinCAT PLC it is necessary to create the route to the remote PLC first. Open a project in TwinCAT 3, and add route be searching for the IP of the remote PLC.

System Requirements

Code tested with Windows 7 64bit, Dymola 2015 32bit, TwinCAT 3.1 Build 4018

Parameters

TypeNameDefaultDescription
SI.TimesamplePeriod (from DiscreteBlock)Sample period of component
SI.TimestartTime (from DiscreteBlock)0First sample time instant
Integernin (from DiscreteMIMO)1Number of inputs
Integernout (from DiscreteMIMO)1Number of outputs
Integer[6]AmsNetId (from AdsCommunicatorBasic){10, 39, 190, 36, 1, 1}AMS Net ID of target PLC
Integerport (from AdsCommunicatorBasic)851Port on server
Modelica.SIunits.TimesamplePeriodExample1Sample period how often a telegram is send
Modelica.SIunits.TimestartTimeExample0Start time when sampling starts
Integer[6]AmsNetIdExample{10, 39, 190, 36, 1, 1}AMS Net ID of PLC
IntegerportExample851Port on PLC to connect to
String[nWrite]varNameToWrite{"MAIN.myInputVar1", "MAIN.myInputVar2"}Names of variables to be written in PLC
String[nRead]varNameToRead{"MAIN.myOutputVar1", "MAIN.myOutputVar2"}Names of variables to be read from PLC
IntegernWrite2Number of datapoints to be written
IntegernRead2Number of datapoints to be read

Connectors

TypeNameDefaultDescription
Modelica.Blocks.Interfaces.RealInput[nin]u (from DiscreteMIMO)Connector of Real input signals
Modelica.Blocks.Interfaces.RealOutput[nout]y (from DiscreteMIMO)Connector of Real output signals

Components

TypeNameDefaultDescription
Integerstate (from AdsCommunicatorBasic)dummy variable to check state of C-function, 0 == OK, 1 == failure
RealReceiveDataReal data to be received
IntegerstateExampledummy variable to check state of function, 0 == OK, 1 == errror

Revisions

  • November 01, 2015  by Georg Ferdinand Schneider:
    Implemented
  • January 30, 2016  by Georg Ferdinand Schneider:
    Revised for publishing