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
| Type | Name | Default | Description |
|---|---|---|---|
| SI.Time | samplePeriod (from DiscreteBlock) | Sample period of component | |
| SI.Time | startTime (from DiscreteBlock) | 0 | First sample time instant |
| Integer | nin (from DiscreteMIMO) | 1 | Number of inputs |
| Integer | nout (from DiscreteMIMO) | 1 | Number of outputs |
| Integer[6] | AmsNetId (from AdsCommunicatorBasic) | {10, 39, 190, 36, 1, 1} | AMS Net ID of target PLC |
| Integer | port (from AdsCommunicatorBasic) | 851 | Port on server |
| Modelica.SIunits.Time | samplePeriodExample | 1 | Sample period how often a telegram is send |
| Modelica.SIunits.Time | startTimeExample | 0 | Start time when sampling starts |
| Integer[6] | AmsNetIdExample | {10, 39, 190, 36, 1, 1} | AMS Net ID of PLC |
| Integer | portExample | 851 | Port 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 |
| Integer | nWrite | 2 | Number of datapoints to be written |
| Integer | nRead | 2 | Number of datapoints to be read |
Connectors
| Type | Name | Default | Description |
|---|---|---|---|
| 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
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | state (from AdsCommunicatorBasic) | dummy variable to check state of C-function, 0 == OK, 1 == failure | |
| Real | ReceiveData | Real data to be received | |
| Integer | stateExample | dummy 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