×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 38726591, Entry date: 08/23/2010
(11)
Rate

How do you simulate communication between two CPU modules?

  • Entry
  • Associated product(s)

Instructions:
As from S7-PLCSIM V5.4 + SP3 you can use S7-PLCSIM to simulate multiple CPU modules simultaneously in a STEP 7 project and establish communication between the CPU modules. The following communication blocks are supported for communication:

  • SFB8 "USEND"
  • SFB9 "URCV"
  • SFB12 "BSEND"
  • SFB13 "BRCV"
  • SFB15 "PUT"
  • SFB14 "GET"
  • SFB19 "START"
  • SFB 20 "STOP"
  • SFB 22 "STATUS"
  • SFB 23 "USTATUS"

During communication, there might be time restrictions because S7-PLCSIM does not support real time.

Please also refer to the information in the S7-PLCSIM readme file, section 7.3. If, when running a large number of Windows programs, you cannot start any more programs or you cannot open any more windows, then you must change the operating system property "desktop heap memory" of your PC. One remedy is described in Table 02.

You cannot test a program of your STEP 7 project with a real CPU (PLC) at the same time as a program with S7-PLCSIM. If you wish to simulate your CPUs with S7-PLCSIM, you must first disconnect all connections to the real CPU.

Proceed as described in Table 01 below to simulate multiple CPU modules simultaneously.
 

No. Procedure:
1 Open S7-PLCSIM in the SIMATIC Manager, either via the menu command "Options> Simulate Modules" or from the menu bar with the "Simulation on/off" icon. The dialog with the instance number "S7-PLCSIM1" with the first simulated CPU opens.
2 In the "S7-PLCSIM1" dialog, you select the configured interface parameterization from the drop-down list box for the PG/PC interface. The MPI interface is preset by default. Later, S7-PLCSIM starts with the interface last used. However, depending on your hardware configuration, you can also set the "PROFIBUS", "TCP/IP" (via the IP address), "ISO" (via the MAC address) or "Local" (via the virtual backplane bus) interface.

Note:
You must not use the addresses more than once in the same subnetwork. If you load all your programs via the MPI interface, for example, then the different MPI addresses might look like this:

  • Station 1: MPI address: 2
  • Station 2: MPI address: 3
  • etc.
3 In the SIMATIC Manager, mark the block folder of your first S7 station and load your blocks in S7-PLCSIM1 via the menu command "PLC > Upload".
4 In the "CPU" subwindow in S7-PLCSIM, change the operating mode from "STOP" to "RUN-P". Via the "Add" menu, you can upload the subwindows for the inputs, outputs, markers... in order to monitor and control the program.
5 To simulate another CPU, you execute the menu command "Simulation > New PLC" in S7-PLCSIM. The "S7-PLCSIM2" dialog opens.
6 For the second CPU to be simulated, you select the interface parameterization (PG/PC interface) configured in the hardware configuration. Fig. 01 shows an example of communication between two S7-400 CPU modules. In S7-PLCSIM1 (simulation for Station 1), EB1 controls counter Z1 and transfers the counter value to the AW1 in S7-PLCSIM2 (simulation for Station 2).


Fig. 01

Note:
If you use the same address of the same interface for both CPUs, the item in the drop-down list is grayed. The S7-PLCSIM instance is not accessible via this interface. Select the interface from the drop-down list box for the PG/PC interface even if it is already set. Then the color changes from gray to black and the S7-PLCSIM instance is accessible via this interface.

7 In the SIMATIC Manager, mark the block folder of your second CPU and load all the blocks into the instance "S7-PLCSIM2". You must select the instance "S7-PLCSIM2" before loading. Here, too, you add the subwindows required for the inputs, outputs, markers... .

Note:
Execute the download only when the color of the interface is black (as described in Step 6 above). More information is available in the S7-PLCSIM readme in section 7.3.2.

Repeat steps 4 to 7 for every other CPU to be simulated.

Table 01

Changing the operating system property "desktop heap memory"
Even if you have sufficient main memory and export memory in your PC, you might get the error message "Not enough main memory" or the program might crash when running a large number of Windows programs. One remedy is described in Table 02.
 

No. Procedure:
1 Start the registry editor via "Start > Run..." and by entering "Regedt32.exe" in the command line.
2 Open the path:
  • HKEY_LOCAL_Machine\System\CurrentControlSet\Control\Session Manager\SubSystems
3 Right-click on "Windows" and select the "Change" function in the pop-up menu. The "Edit String" dialog opens.
4 The "SharedSection" parameter has the values 1024 (maximum size of the system-wide heap) and 3072 (size of the heap per desktop). Increase the desktop heap memory by 512 KB by adding the value 512 to the "SharedSection" parameter as shown in Fig. 02. Then click "OK" to save the settings.


Fig. 02

With the additional SharedSection value of 512 KB, the size of the desktop heap is defined for each desktop that is connected to a "non-interactive" workstation. Display of the above-mentioned error message or program crashes should now no longer occur.

5 You must reboot your PC to make the changes to the desktop heap memory effective.

Note:
More information is available in the Internet on the Microsoft Help and Support page under article ID: KB126962.

Table 02

Download:
The attached download "S7_PLCSIM_CPU_Communication" contains a STEP 7 V5.4 project with the communication program described above. Copy the "S7_PLCSIM_CPU_Communication.zip" file into a separate directory and then start the file with a double-click. The STEP 7 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 to open and process the extracted project.

S7_PLCSIM_CPU_Communication.zip ( 431 KB )  

Creation environment
Table 03 lists the components that have been used to create this entry and verify the function described.
 

Test environment Version
PC platform Intel(R) Core(TM)2 Duo CPU P8700 2.53 GHz
PC operating system MS Windows XP SP3
STEP 7 V5.4+SP5
S7 PLCSIM V5.4+SP3
Table 03

Keywords:
Out of memory, Multi-instance

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.