Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Applicom S7 Card

Description

This document explains how to use the Data Interchange Layer (DiL) system to instantiate an Applicom S7 card client to monitor and control configured data points of different type with a PLC server (Snap7 server tool to emulates the PLC server) using S7 communication protocol. S7comm (S7 Communication) is a Siemens proprietary protocol that runs between programmable logic controllers (PLCs) of the Siemens S7-300/400 family. The protocol is client/server-based and relies on TCP/IP over Ethernet.

To connect with the Applicom card client, the Snap7 server must only know the IP address of PLC defined in the .ply file (which correspond to host IP Address). After the connection, the server will automatically retrieve the information on the data points written by the client on the PLC database.

By adding an Applicom card client to the simulation, the user can use any S7 server to monitor simulation points of the Simulink model and is also able to control the simulation by writing data on PLC database. To do that, the user must configure the points to be initialized in the Applicom card database and that will be transferred to PLC server using cyclic functions, and perform the appropriate connection on these points in the Simulink model. The configuration is explained in this document.

The Applicom card client runs asynchronously on the core 0 of the simulation target. No specific hardware is required.

A S7 server software is required to communicate with the driver. The user must use its own S7 server to connect with the client running on the simulation target

The screenshots of the Snap7 server that are present in this documentation have been taken from the Snap7 open source project. It is possible to download this software from Snap7 website.

.ply File Configuration

A .ply file is necessary before running the model, without the ply file, the card can not be initialized. For this, the software Applicom console is required, it is possible to download it from the molex website.

Generate the ply Configuration File:

Install the software, then open the Applicom console:

Right-click Boards Configuration, select Configuration manager then click New and check Without under the Board Connection panel.

Choose a name for your new configuration and write a short description.

Click OK. You might have to relaunch the software for the new configuration to be taken into account. Right-click Boards Configuration and select Add board. Choose your board and set the EPROM Version to one of your Applicom cards. 



Double-click Channel 0 and select TCP/IP and ISO, Client/Server




Select Industrial Ethernet Siemens


Configure parameters of the Applicom card, IP address, Gateway IP address and Sub-Network mask



Insert a new Equipment which is the PLC (make sure you select Server Equipment under TCP/IP)


Configure its IP address (you may have to deselect "Link Parameters") which is IP of the PC, make sure to keep in mind the "Number" of the PLC which will be used in the configuration



Then generate file, go under "File" then "Board Initialization", you will find your .ply file on the location (Configuration path) specified (second screenshot)

Driver Configuration

A configuration file is required for two major reasons:

  • server configuration in itself
  • various data to be monitored and controlled

Server Configuration

By default, if the user does not modify any parameters in the configuration, the client will use a default configuration in which the some cycles have already been set to standard values.

If the user needs to change a parameter value, the configuration file must be edited. It is important to understand that the manual modification of this configuration file is temporary. In future RT-LAB releases, this file will be replaced by a nice configuration panel. The following lines show how to modify parameters for cycles:

OPAL-1.0 Object
Applicom::Configuration {
	plyFile=applicom.ply
	cycles {
		item {
			card=1
			channel=0
			dataCount=8
			databaseAddrOffset=0
			id=10
			period_ms=200
			plcAddrOffset=524288
			plcId=1
			rw_mode=WRITE_BIT
			stateAfterStart=1
			statusAddrOffset=1001
		}
		item {
			card=1
			channel=0
			dataCount=8
			databaseAddrOffset=50
			id=20
			period_ms=500
			plcAddrOffset=524288
			plcId=1
			rw_mode=READ_BIT
			stateAfterStart=1
			statusAddrOffset=1002
		}
	}
}

plyFile is the .ply file generated using applicom console (see section above)

Data Configuration

The cycles that control data points to be monitored must be specified in the configuration file.

Each cycle has a card ID, a channel ID, ...etc

Card

Card number (between 1 and 8)

Channel

Channel number on the card (between 0 and 31)

DataCountData to read or write (should be between 1 and 1024)
DatabaseAddrOffsetOffset address in card database to read or write
IdIdentification number of Cycle (between 1 and 255)
Period_msPeriod of the cyclic function, should be multiple of 100ms (if 0, no delay)
plcAddrOffsetOffset address in PLC to read or write
plcIdID of PLC defined in *.ply (between 0 and 255)
rw_modeType of read or write to execute.


Possible values are:

WRITE_BIT, READ_BIT, WRITE_BYTE, READ_BYTE, WRITE_WORD, READ_WORD, WRITE_BCD_WORD, READ_BCD_WORD, WRITE_DWORD, READ_DWORD, WRITE_FLOAT, READ_FLOAT

  • stateAfterStart is the state of the cycle after starting the model (0=stopped, 1=started)
  • statusAddrOffset is the offset address in card database storing cycle status

Configuration File Example

You can find a configuration file example named "Applicom_cfg.opal" in the following directory:

YOUR_RT_LAB_INSTALLATION_FOLDER/Examples/IO/_Generic_/Applicom/Siemens S7/simulink

RT-LAB Usage

In RT-LAB, a file named 'connections.opal' must also be written by the user and transferred to the target in ASCII mode. The same has to be done for the configuration file "Applicom_cfg.opal". The .ply file needs also to be transferred in BINARY mode.


The screenshot above shows how to configure the files to be transmitted to the Opal-RT simulator when the model is loaded.The 'connections.opal' file is required to bind the model signals to the driver variables. This is how all drivers implemented with the Data Interchange Layer work for the moment. In the future, the user will not have to deal with this file anymore since the connections will be handled through a special RT-LAB panel.

Here is what a typical connection file looks like for the Applicom S7 driver:

OPAL-1.0 Object
List {
  item {
    configFile=Applicom_cfg.opal
    id {
      Applicom
    }
    outputs {
      item {
        dataInExchanger=S7_Cycle_10_DatabaseToWrite[0:7]
        dataInProcess=OpOutput:S7_Cycle_10_DatabaseToWrite[0:7]
      }
	  item {
        dataInExchanger=S7_Cycle_30_DatabaseToWrite[0]
        dataInProcess=OpOutput:S7_Cycle_30_DatabaseToWrite[0]
      }
	  item {
        dataInExchanger=S7_Cycle_50_DatabaseToWrite[0]
        dataInProcess=OpOutput:S7_Cycle_50_DatabaseToWrite[0]
      }
	  item {
        dataInExchanger=S7_Cycle_70_DatabaseToWrite[0]
        dataInProcess=OpOutput:S7_Cycle_70_DatabaseToWrite[0]
      }
	  item {
        dataInExchanger=S7_Cycle_90_DatabaseToWrite[0]
        dataInProcess=OpOutput:S7_Cycle_90_DatabaseToWrite[0]
      }
	  item {
        dataInExchanger=S7_Cycle_110_DatabaseToWrite[0:3]
        dataInProcess=OpOutput:S7_Cycle_110_DatabaseToWrite[0:3]
      }
	  item {
        dataInExchanger=S7_Cycle_110_Enable[0]
        dataInProcess=OpOutput:S7_Cycle_110_Enable[0]
      }
	  item {
        dataInExchanger=S7_Cycle_110_Trigger[0]
        dataInProcess=OpOutput:S7_Cycle_110_Trigger[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_Enable[0]
        dataInProcess=OpOutput:S7_Cycle_120_Enable[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_Trigger[0]
        dataInProcess=OpOutput:S7_Cycle_120_Trigger[0]
      }
    }
    inputs {
      item {
        dataInExchanger=S7_Cycle_20_DatabaseToRead[0:7]
        dataInProcess=OpInput:S7_Cycle_20_DatabaseToRead[0:7]
      }
	  item {
        dataInExchanger=S7_Cycle_40_DatabaseToRead[0]
        dataInProcess=OpInput:S7_Cycle_40_DatabaseToRead[0]
      }
	  item {
        dataInExchanger=S7_Cycle_60_DatabaseToRead[0]
        dataInProcess=OpInput:S7_Cycle_60_DatabaseToRead[0]
      }
	  item {
        dataInExchanger=S7_Cycle_80_DatabaseToRead[0]
        dataInProcess=OpInput:S7_Cycle_80_DatabaseToRead[0]
      }
	  item {
        dataInExchanger=S7_Cycle_100_DatabaseToRead[0]
        dataInProcess=OpInput:S7_Cycle_100_DatabaseToRead[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_DatabaseToRead[0:3]
        dataInProcess=OpInput:S7_Cycle_120_DatabaseToRead[0:3]
      }
	  item {
        dataInExchanger=S7_Cycle_110_ErrorStatus[0]
        dataInProcess=OpInput:S7_Cycle_110_ErrorStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_110_DataCountStatus[0]
        dataInProcess=OpInput:S7_Cycle_110_DataCountStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_110_DataTypeStatus[0]
        dataInProcess=OpInput:S7_Cycle_110_DataTypeStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_110_DataExchanged[0:3]
        dataInProcess=OpInput:S7_Cycle_110_DataExchanged[0:3]
      }
	  item {
        dataInExchanger=S7_Cycle_120_ErrorStatus[0]
        dataInProcess=OpInput:S7_Cycle_120_ErrorStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_DataCountStatus[0]
        dataInProcess=OpInput:S7_Cycle_120_DataCountStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_DataTypeStatus[0]
        dataInProcess=OpInput:S7_Cycle_120_DataTypeStatus[0]
      }
	  item {
        dataInExchanger=S7_Cycle_120_DataExchanged[0:3]
        dataInProcess=OpInput:S7_Cycle_120_DataExchanged[0:3]
      }
    }
  }
}

In this file, it is important to note that signal names used in the 'dataInExchanger' section match the cycle is specified in the configuration file. Their format should be S7_Cycle_$id$_$parameter$[0:$vectorSize$].


Possible parameter values are:

DatabaseToWriteFor a 'write' cycle, this connection contains the element to write in the card database.
DatabaseToReadFor a 'read' cycle, this connection contains the element to read from the card database.
EnableThis connection is used to activate or deactivate a cycle. If the cycle is set to be launched at the load of the model, this signal will be bypassed until be put to true then false again.
TriggerThis connection is used to activate a single event of the cycle. If the cycle is enabled, putting this signal to true won't have any impact.
ErrorStatusThis connection provides a status code for the cycle. Code 0 means no issue, code 35 means no data has been transferred (improper configuration or server not started) and code 65530 means the cycle has been deactivated.
DataCountStatusContains the number of data transferred (written or read) by the cycle.
DataTypeStatus1=bit, 2=byte, 3=word, 4=dword, 5=float.
DataExchangedContains the data transferred during the last execution of the cycle.



The name used in the 'dataInProcess' must match the name of the respective 'OpInput' or 'OpOutput' blocks in the master subsystem of the Simulink model.

The Applicom S7 example model shows how to perform the connections using 'OpInput' and 'OpOutput' blocks and modify the values read by the Snap7 server. It is located in the following directory:

YOUR_RT_LAB_INSTALLATION_FOLDER/Examples/IO/_Generic_/Applicom/Siemens S7/simulink

The example model is also accessible from the New Project wizard in RT-LAB. Select the applicom_s7 template under IO/_Generic_/Applicom/S7.
In the Simulink master sub-system, model signals that will be written in the PLC server (from Applicom card to PLC so read by Snap7 server) have to be connected to 'OpOutput' blocks.
Data that are written in the database of the card (from PLC to Applicom card) have to be connected to 'OpInput' blocks.

Here is a screenshot showing the master subsystem of the example model. OpOutput blocks are used to modify values of 'enable' and 'trigger' connections and to send data to the PLC emulated by Snap7 Server, that will be accessible to be read by Applicom card in its own database. OpInput blocks are used to retrieve the signal status of cycles and to get data from the PLC emulated by Snap7 Server and have it accessible into the master subsystem of the Simulink model.

The example model documentation shows how to interact with a Snap7 server by modifying and by monitoring data values of all the supported types.

Connection with the Snap7 Server

Connecting using Snap7 Server

To connect with the Applicom card (Client) running on the simulator using a Snap7 Server, the user only have to fill the IP address of his PLC in the .ply file which correspond to his own PC IP address: 

xxx.xxx.xxx.xxx is the IP address of the host PC user.

Download the Snap7 Server from Snap7 website. Extract the archive and go to location : snap7-full-1.x.0\rich-demos\x86_64-win64\bin\ and open serverdemo.exe

By running the model, Write Request and Read Request will display in the log, you can filter these requests deselecting corresponding logs in the "Log Mask" tab.

Limitations

The current version of the Applicom S7 driver has the following limitations:

  • Data types: bits, bytes, BCD, double, float
  • Maximum array length: depending the PLC (S7-300 or S7-400)




OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323