You are on page 1of 62

S7 for Windows

SoftPLC PLC416, PLC315 SimPLC User's Guide


Version 2.x

A PLC INSIDE A PC

Information in this document is subject to change without notice and does not represent a commitment on the part of IBH softec GmbH. The software and/or databases, described in this document, are furnished under a license agreement or non-disclosure agreement. The software and/or databases may be used or copied only in accordance with the terms of the agreement. It is against the law to copy the software on any medium except as specifically allowed in the license or non-disclosure agreement. The purchaser may make one copy of the software for backup purposes. No part of this manual and/or databases may be reproduced or transmitted in any form or by any means, (electronic or mechanical, including photocopying, recording, or information storage and retrieval systems), for any purpose other than the purchaser's personal use, without the express written permission of IBH softec GmbH.

Copyright 1993 - 2000 IBH softec GmbH. All rights reserved.

Gesellschaft fr Automatisierungstechnik mbH Turmstrae 77 D - 64743 Beerfelden / Odw. Germany Telefon 0 60 68 / 30 01 Telefax 0 60 68 / 30 74 Internet: www.IBHsoftec.de E-Mail: info@IBHsoftec.de

Windows, Windows NT, Visual C, Visual Basic, Excel, and Access, are registered trademarks of the Microsoft Corporation. Simatic S5, Step 5, Simatic S7, Step 7, S7-200, S7-300, S7-400, and GRAPH 5 are registered trademarks of Siemens AG, Mnchen and Berlin. S7 for Windows SoftPLC

Contents

Page I

Contents

Contents ................................................................................................ I 1 2 Introduction................................................................................... 1 SoftPLC Installation ...................................................................... 2


2.1 2.2 The Installation Program...................................................................... 2 Online Functions .................................................................................. 2
2.2.1 Direct access to the SoftPLC with S7 for Windows ........................................ 2

SoftPLC Fundamentals................................................................. 3
3.1 3.2 Response Time ..................................................................................... 3 Retentivity ............................................................................................. 3
Load at Start.................................................................................................... 3 Save at Termination ........................................................................................ 3 Save M, T, C at Termination ........................................................................... 4

3.3 3.4

Locking the Settings ............................................................................ 4 Setting the Task Interval ...................................................................... 4

SoftPLC Dialog Box ...................................................................... 5


4.1 Dialog Box Structure ............................................................................ 5
4.1.1 PLC Program................................................................................................... 5 Complete Restart (OB 100)............................................................................. 6 Restart (OB 101) ............................................................................................ 6 Stop ................................................................................................................ 6 Cycle ............................................................................................................... 6 Cycle Time ...................................................................................................... 6 I/O Ports .......................................................................................................... 7 Jitter................................................................................................................. 7 The SoftPLC Serial Number and Version ....................................................... 7 Options ............................................................................................................ 8 Locked............................................................................................................. 8 Unlocked ......................................................................................................... 8 Modify Password ............................................................................................. 8 PLC Program and Data Blocks ....................................................................... 9 Save ................................................................................................................ 9 Save M, T, C at Termination ........................................................................... 9 Load ................................................................................................................ 9 Load at PLC Start............................................................................................ 9 Save at PLC Termination ................................................................................ 9 Save M, T, C at Termination ......................................................................... 10 Serial Communication ................................................................................... 10 PLC Memory ................................................................................................. 10
S7 for Windows SoftPLC

4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7

4.1.8

4.1.9 4.1.10

Page II

SoftPLC

4.1.11

Exit PLC......................................................................................................... 10

SoftPLC Instruction Set ..............................................................11


5.1 Bit Logic Instructions ......................................................................... 11
5.1.1 5.1.2 5.1.3 Other Boolean Logic Instructions .................................................................. 12 Set / Reset and Edge Triggered Instructions ................................................ 12 Master Control Relay (MCR) Instructions ..................................................... 12

5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.10 5.11 5.12 5.13 5.14 5.15 5.16 5.17 5.18 5.19

Load and Transfer Instructions ......................................................... 13 Peripheral Access Instructions ......................................................... 14 Accumulator Instructions................................................................... 14 Shift and Rotation Instructions.......................................................... 14 Timer Instructions............................................................................... 15 Counter Instructions........................................................................... 15 Word Instructions ............................................................................... 16 Arithmetic Instructions....................................................................... 16 Data Type Conversion Instructions................................................... 17 Jump Instructions............................................................................... 18 Block Call Instructions ....................................................................... 19 Indirect Addressing Instructions....................................................... 19 Program Display and Null Operation Instructions ........................... 20 PLC Memory Allocation...................................................................... 20 System Data Area Allocation ............................................................. 20 Organization Blocks (OBxx) integrated ............................................ 21 Integrated System Functions............................................................. 21 Integrated System Function Blocks .................................................. 22

Direct Access Data Interface ......................................................23


6.1 Data Transfer and Conversion Functions......................................... 23
6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 Read Value.................................................................................................... 23 Write Value .................................................................................................... 24 Read Several Values..................................................................................... 24 Write Several Values ..................................................................................... 25 Read Data Block............................................................................................ 26 Write Data Block............................................................................................ 26 FloatToMC5................................................................................................... 27 MC5ToFloat................................................................................................... 27 PLC Program................................................................................................. 28 Visualization .................................................................................................. 28 Source Code.................................................................................................. 29

6.2

Example ............................................................................................... 28
6.2.1 6.2.2 6.2.3

S7 for Windows SoftPLC

Contents

Page III

DDE Manager .............................................................................. 30


7.1 Example ............................................................................................... 31
Reading a Memory Byte................................................................................ 31 Writing into a Memory Byte ........................................................................... 31

8 9

Functions not Incorporated in the SoftPLC .............................. 32 SoftPLC Configuration ............................................................... 33


Section [PLC] ................................................................................................ 33 Section [COM] ............................................................................................... 33 Section [COM2] ............................................................................................. 33 Section [OEM] ............................................................................................... 33

10 CIF30X - Driver ............................................................................ 34


10.1 10.2 Installation........................................................................................... 34 System Function Blocks .................................................................... 35
10.2.1 10.2.2 CIF Status Request ....................................................................................... 35 CIF Control System Function Block .............................................................. 35 FCT 102 Setting the Number of the Digital Inputs and Outputs ................... 36 FCT 125 Reading the Process Inputs (Peripheral Inputs) ............................ 37 FCT 126 Writing to the Process Outputs (Peripheral Outputs)..................... 37 FCT 130 Reading the Global Diagnostic Bits ............................................... 38 FCT 131 Reading the Bus Status ................................................................. 38 FCT 132 Reading an Illegal Bus Address ..................................................... 39 FCT 133 Reading the Error Number ............................................................. 39 InterBus Error Numbers ................................................................................ 39 InterBus Error Numbers (continued)......................................................... 40 InterBus Error Numbers (continued)......................................................... 41 Profi Bus Error Numbers ............................................................................... 41 Profi Bus Error Numbers (continued)......................................................... 42 FCT 134 Reading the Status Bits.................................................................. 42 FCT 135 Reading the Diagnostic Bits ........................................................... 42 FCT 136 Reading the Dual Port Memory...................................................... 43 FCT 137 Writing to the Dual Port Memory.................................................... 43 FCT 139 Suppressing the Watchdog............................................................ 44 FCT 140 Restarting the Watchdog ............................................................... 44 FCT 141 Reading the "HostFlags" ................................................................ 45 FCT 142 Reading the "DevFlags" ................................................................. 45 FCT 143 Writing to the "DevFlags" ............................................................... 46

10.3

Control SFB252 Functions................................................................. 36


10.3.1 10.3.2 10.3.3 10.3.4 10.3.5 10.3.6 10.3.7

10.3.8 10.3.9 10.3.10 10.3.11 10.3.12 10.3.13 10.3.14 10.3.15 10.3.16

10.4 10.5 10.6

CIF System Configuration.................................................................. 47 Special Settings .................................................................................. 47 Technical Data .................................................................................... 48

11 Appendix ..................................................................................... 49
Null Modem Cable......................................................................................... 49
S7 for Windows SoftPLC

Page IV

SoftPLC

12 Index.............................................................................................51

S7 for Windows SoftPLC

Chapter 1

Introduction

Page 1

1 Introduction
This manual will explain how to install and how to use the Software PLC SoftPLC PLC416 and the Simulation PLC SimPLC. Both Software PLC's are compatible with the Siemens PLC S7-416 hardware. Also available is a Software PLC SoftPLC PLC315 which is compatible with the Siemens PLC S7-315 hardware. The Simulation PLC is not a "Real Time" application. Rather the SimPLC is used as a development tool to test PLC programs. As the SimPLC does not have real time capability the Simulation PLC may not be used to control a process. Therefore user DLL's (e.g. CIFDriver) can't be read in. The use of the Simulation PLC cannot be prohibited with a password. The corresponding switch in the dialog box has no function. The Simulation PLC does not support access to I/O ports. The dialog box where you would enter an I/O port address is disabled. The Software PLC requires the Microsoft operating systems Windows NT Version 4.x or Windows 2000. The Simulation PLC ,which does not have real time capability, may also be executed under the Microsoft operating systems Windows 95 or Windows 98. All other functions of the Software PLC SoftPLC and the Simulation PLC SimSPS are identical. In the following chapters all explanations refer to the Software PLC and the Simulation PLC even if only the Software PLC is mentioned. Differences between the Software PLC and the Simulation PLC are mentioned only if they are not mentioned above or are the consequences of the above limitations. Some differences apply to the SoftPLC PLC315. Both Software PLCs use the same instruction set and have the same integrated functions. The limitations of the PLC315 Software PLC versus the PLC416 Software PLC are as follows: SoftPLC PLC416 Load Memory limited by the PC Memory, adjustable SoftPLC PLC315 80kByte, fixed value M0.0 up to M255.7 T0 up to T127 C0 up to C63

Memory Bit Area M0.0 up to M16383.7 Timer Counter T0 up to T511 C0 up to C511

Differences between the PC416 and PC315 Software PLCs are only mentioned if they are not mentioned above or are the consequences of the above limitations.

S7 for Windows SoftPLC

Page 2

SoftPLC

Chapter 2

2 SoftPLC Installation
The Software PLC requires either Windows NT Version 4.x or Windows 2000 Microsoft operating systems. The Simulation PLC may be executed using Windows NT Version 4.x, Windows 2000, Windows 95, or Windows 98 Microsoft operating systems. In General a CD Drive is required to install the software, however the CD provides the software to generate 3.5" installation disks.

2.1

The Installation Program


The Install program performs all the required steps to setup the Software PLC on the hard drive of your PC. Follow the instructions on the screen. You will be prompted to insert the Serial Numbers and PIN Codes at the appropriate time. The PIN code and the serial number can be found on the "Product ID Card" attached to the registration card. Both cards are shipped with the Software PLC CD.

2.2

Online Functions
The Software PLC can be accessed directly from S7 for Windows or via a serial port. The programming device must be connected with the PC running the Software PLC via a Null Modem Cable.

2.2.1 Direct access to the SoftPLC with S7 for Windows


S7 for Windows provides you with direct access to the Software PLC to transfer PLC programs and to display the status. All of the S7 for Windows online functions are directly available with the Software PLC. The data transfer is extremely fast. S7 for Windows versions prior V4.04 require a software update. Please contact your software dealer.

S7 for Windows SoftPLC

Chapter 3

SoftPLC Fundamentals

Page 3

3 SoftPLC Fundamentals
The Software PLC is designed to reproduce a Hardware PLC with Real-Time capability. After downloading the PLC program to the Software PLC, it is executed in the same manner as a Hardware PLC. This ensures the ability to directly monitor the status of the operands without recompiling the executed PLC program. It is therefore possible to determine which PLC instruction is being executed at any time.

3.1 Response Time


The Software PLC uses about 50% of the processing power of the CPU when in the RUN mode. The Response Time of the Software PLC is fixed. Every 2ms the Software PLC is called automatically. If the execution time of the PLC program is less than 1ms, the Software PLC execution time is reduced accordingly and the required processing power will drop below 50%. In this case other Windows applications have the benefit of the additional processing power.

3.2 Retentivity
If a retentivity of the Software PLC is required (as in a Hardware PLC) some settings in the Software PLC dialog field are necessary. With the explanation of the use of these check boxes and an Uninterruptible Power Supply (UPS), it is possible to configure the Software PLC to act the same as a Hardware PLC in case of a power failure (retentive behavior). With an installed UPS and the support of Windows NT, the PLC program resident in the Software PLC and the Memory Bits (M), Timers (T), and Counters (C), with their current conditions, are saved in a binary file (PLC.BIN) on the hard disk. A signal from the UPS (via a COM port) starts the power down procedure in the case of a power failure. The battery of the UPS will ensure that the PC has power until the power down process is completed. When the power returns, the Software PLC program can start-up with the Memory Bits (M), Timers (T), and Counters (C) with same conditions that were saved at power down. To enable the retentivity of the Software PLC the following check boxes must be marked: Load at Start The PLC program stored on the hard disk in the binary file PLC.BIN will be transferred into the SoftPLC during the SoftPLC start up procedure (PC boot up). Save at Termination The PLC program resident in the Software PLC is saved in the PLC.BIN file on the hard disk when the Software PLC application is terminated. In addition, the PLC program is saved in
S7 for Windows SoftPLC

Page 4

SoftPLC

Chapter 3

the PLC.BIN file when Windows NT / 2000 is terminated in a normal manner while the Software PLC is running. Save M, T, C at Termination The current state of the Memory Bits (M), Timers (T), and Counters (C) are saved in the PLC.BIN file along with the PLC program currently resident in the Software PLC, when the program is terminated. In addition, the PLC program is saved in the PLC.BIN file when Windows NT / 2000 is terminated with its normal procedure while the SoftPLC is running.

3.3 Locking the Settings


A password interlock is provided to lock the settings in the Software PLC dialog box. When the password is set the dialog box functions are no longer available.

3.4 Setting the Task Interval


As a default, the task interval of the Software PLC is set to 1ms. Each cycle (every 2ms) the Software PLC is polled and the software is executed for a 1ms. After the 1ms period the CPU returns to the Windows operating system or any other windows application being executed in parallel with the Software PLC. It is possible to reduce the task interval of the Software PLC which will provide additional processing power for the Windows operating system and any other windows application being executed, but will extend the execution time of the PLC Program. The task interval is set in the PLC43.INI file located in the SoftPLC folder. WINTIME = <Time in ms> The default setting is WINTIME = 1 giving a task interval of 1ms.

A polling frequency of 2ms and the task interval setting of 1ms will result in a 50% processing power sharing between the Software PLC and the Windows operating system and any other windows applications.

S7 for Windows SoftPLC

Chapter 4

SoftPLC Dialog Box

Page 5

4 SoftPLC Dialog Box


After starting the Software PLC you can open the dialog box by clicking the SoftPLC icon in the status bar.

4.1 Dialog Box Structure

Figure 4-1

SoftPLC Dialog Box The Software PLC timing is displayed and is constantly updated.

4.1.1 PLC Program


In the PLC Program field the status of the Software PLC CPU is displayed:

S7 for Windows SoftPLC

Page 6

SoftPLC

Chapter 4

The PLC program is executed in the Software PLC CPU (RUN mode) The Software PLC CPU is in its STOP mode. The PLC program is not executed.

Complete Restart (OB 100) Marking the Compl. Rst. (OB 100) button will put the Software PLC CPU is in its RUN mode. First, the Organization Block OB 100 is executed and then the PLC program will start to execute OB 1 and cycle. This program start is the same as the start sequence of a Hardware PLC, when power is restored.

Restart (OB 101) Marking the Restart (OB 101) button will put the Software PLC CPU is in its RUN mode. First, the Organization Block OB 101 is executed and then the PLC program will start to execute OB 1 and cycle. This program start is the same as the start sequence of a Hardware PLC when restarting the CPU with the RUN / STOP switch.

Stop Marking the Stop button will put the Software PLC CPU is in its STOP mode. The execution of the PLC program is terminated. The state of the Process Images, Memory Bits, Timer, and Counters are saved with their actual current status. The watchdog of the interface board must put the output signals into their OFF stage.

4.1.2 Cycle

The number of the cycles the PLC program executes is counted and displayed. The cycle counter is halted with the Stop button. Marking one of the Start (OB10x) buttons resets the cycle counter.

4.1.3 Cycle Time

The execution time of the program is constantly measured and displayed. The minimum, maximum, and current cycle times are displayed. Depending of the PLC program structure, the cycle time of a PLC program may vary greatly. At the end of a cycle, the Software PLC saves the results of the time measurement. The time measured is the time from the call of OB 1 until the next OB 1 call. The cycle times (OB 1 cycle time) can be read by the PLC program.
S7 for Windows SoftPLC

Chapter 4

SoftPLC Dialog Box

Page 7

OB 1/LW6: OB 1/LW8: OB 1/LW10:

Currently actual cycle time in ms Maximum cycle time in ms Minimum cycle time in ms

(OB1_PREV_CYCLE) (OB1_MIN_CYCLE) (OB1_MAX_CYCLE)

4.1.4 I/O Ports


I/O ports can be directly linked to Software PLC for communication via the PC Bus and the related Input and Output Boards. To use I/O ports an SFC or SFB must be written to control the Ports (an example is provided on the Installation CD).

The port address and the number of ports must be entered in the text field. The Software PLC must be restarted to activate the I/O ports.

4.1.5 Jitter
Jitter is the variation in the cycle time of the Software PLC caused by the system itself. If an output pulse from a timer OB (e.g. OB 10, every 10 ms) and measured, differences may be found. Jitter is the variation in time between the current measurement, relative to the previously measured time. You will see jitter with hardware and software PLCs. With software PLC's the jitter may be caused by program interruption within the PLC program and also could occur due to hard disk access, network access, etc (system activities). The Jitter of the Software PLC is constantly measured. The maximum jitter and the actual jitter is displayed.

The jitter value must be added to the reaction time of the Software PLC.

4.1.6 The SoftPLC Serial Number and Version


The Software PLC serial number, its version number, and the users name and company are displayed.

S7 for Windows SoftPLC

Page 8

SoftPLC

Chapter 4

4.1.7 Options
The Software PLC options to be set with the SoftPLC dialog box may be interlocked with a password. The settings in the PLC Program and Data Blocks and the I/O port settings (can only be altered when the options are unlocked with the correct password.

The locking and unlocking of the options is done with the buttons Lock and Unlock. These buttons open a text box to enter the password. Locked The marked field Locked indicates that none of the settings in the Software PLC dialog box may be altered prior to unlocking the options with a password. If Locked is marked, none of the dialog boxes settings can be altered. The operation of the buttons Start, Stop, and Exit PLC are also disabled. The locking option gives you the ability to inhibit any operator invention after setup. To change the dialog box settings a valid password must be entered prior to the intervention. The information in the dialog box is always valid. Unlocked The marked field Unlocked indicates that the option may be altered any time without a password. Modify Password You may also change the password by pressing the Modify Password button. Prior to activating the Software PLC lock protection, you have to define a password to turn the protection on and off. The password may have up to 27 characters. The password may be changed any time as long as you know the old password. As a default no password is assigned. If one of above mentioned buttons is activated, the Enter Password dialog box is opened. Please enter the valid password and confirm with OK button. In the text field Old Password enter the password you defined the last time. If no password has yet to be assigned (default setting) do not enter a password. In the text field New Password enter the password you want to use to turn the Software PLC lock protection on. The same password is needed to turn the PLC lock protection off. To avoid entering a wrong password due to typing errors you have to type the new password again in the text field Reenter Password. The password you entered is not displayed in the text fields. Each star represents one (1) typed character. ! To confirm the password entry, activate the OK button. The Software PLC lock protection may now be turned on and of with the defined password.

If the re-entered password and the new password do not match a warning will be displayed and the new password is ignored. If you have lost the password you have to reinstall the Software PLC.
S7 for Windows SoftPLC

Chapter 4

SoftPLC Dialog Box

Page 9

4.1.8 PLC Program and Data Blocks


Buttons are provided to control the loading and termination of the PLC program.

Save Activating the Save button will save the PLC program currently stored in the Software PLC to the hard disk in the binary file PLC.BIN. Save M, T, C at Termination If the check box Save M, T, C at Termination is activated the Memory Bits (M), Timers (T), and Counters (C) are also saved in the PLC.BIN file. The Software PLC will display the following warning prior to saving the data on disk:

If you encounter problems during the next Software PLC start delete the binary file PLC.BIN. Problems may occur if a corrupted PLC program was saved or the saving process was interrupted. In such cases you must reload the PLC program from the programming system environment. The Memory Bits (M), Timers (T), and Counters (C) will then be in their initial conditions. Load If the Load button is activated, the PLC program, stored on the hard disk in the binary file PLC.BIN, will be transferred into the Software PLC. If the check box Save M, T, C also was activated prior to the last save action, the Memory Bits (M), Timers (T), Counters (C) are reset to the condition they had at that time. The Jitter display is also reset. Load at PLC Start If the Load at PLC Start check box is activated, the PLC program stored on the hard disk in the binary file PLC.BIN will be transferred into the Software PLC during the start up procedure (PC boot up). The start of the Software PLC is exactly the same as if starting a hardware PLC after a power failure (the power to the hardware PLC was switched off). First, the Organization Block OB101 will be executed then the cyclical execution of the Organization Block OB1 will start. If the Memory Bits (M), Timers (T), and Counters (C) have been saved in the PLC.BIN file, the saved data will be transferred into the Software PLC. Save at PLC Termination If the Save at PLC Termination check box is activated, the PLC program resident in the Software PLC is saved in the PLC.BIN file on the hard disk. In addition the PLC program will be saved in the PLC.BIN file when Windows NT / 2000 is terminated in a normal manner while the Software PLC is running.
S7 for Windows SoftPLC

Page 10

SoftPLC

Chapter 4

Save M, T, C at Termination If the Save M, T, C at Termination check box is activated, the current status of the Memory Bits (M), Timers (T), and Counters (C) as well as the PLC program resident in the Software PLC, are saved in the PLC.BIN when the Software PLC is terminated. In addition, the PLC program is saved in the PLC.BIN file when Windows NT / 2000 is terminated in a normal manner while the Software PLC is running.

4.1.9 Serial Communication


Five buttons are provided to select the port for the communication with S7 for Windows or another programming system.

Only S7 for Windows may communicate directly (Internal) with the Software PLC without using a serial port. The port parameters (Baud rate etc.) are defined in the PLC.INI file.

4.1.10 PLC Memory


The total Work Memory available for the Software PLC program and the Work Memory used by the PLC program are displayed.

Also the Load Memory available and the Load Memory used by the PLC program are displayed. The Load Memory size may be adjusted (not in the PLC315 Software PLC) in the field "Bytes Total".

4.1.11 Exit PLC


Marking the Exit PLC button will terminate the Software PLC. You can restart the Software PLC any time.

S7 for Windows SoftPLC

Chapter 5

SoftPLC Instruction Set

Page 11

5 SoftPLC Instruction Set


The Software PLC has the complete instruction set of the Simatic S7-416 CPU.

5.1 Bit Logic Instructions


Instruction U UN O ON X XN E A M L T Z DBX DIX ==0 <>0 >0 >=0 <0 <=0 UO OV OS BR Address ID Description AND with a scan to "1" AND NOT with a scan to "0" OR with a scan to "1" OR NOT with a scan to "0" Exclusive OR with a scan to "1" Exclusive OR NOT with a scan to "0" Input Output Bit Memory Local Data Bit Timer Counter Data Bit Instance Data Bit Result equal to Zero ( = 0) (CC1 = 0 and CC0 = 0) Result not equal to Zero ( 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 1 and CC0 = 0)) Result greater than Zero ( > 0) (CC1 = 0 and CC0 = 0) Result greater or equal to Zero ( >= 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 0 and CC0 = 0)) Result less than Zero ( < 0) (CC1 = 0 and CC0 = 0) Result less or equal to Zero ( <= 0) ((CC1 = 0 and CC0 = 1) or (CC1 = 0 and CC0 = 0)) Unordered Math Instruction Overflow Stored Overflow Binary Result (CC1 = 1 and CC0 = 1)

S7 for Windows SoftPLC

Page 12

SoftPLC

Chapter 5

5.1.1 Other Boolean Logic Instructions


Instruction A( AN( O( ON( X( XN( ) O NOT SET CLR SAVE Address ID Description AND left Parenthesis (seven nesting levels possible) AND NOT left Parenthesis OR left Parenthesis OR NOT left Parenthesis Exclusive OR left Parenthesis Exclusive OR NOT left Parenthesis Right Parenthesis, removing an entry from the nesting stack OR-ing AND Operations (AND before OR) Negate RLO Set RLO to " 1 " Set RLO to " 0 " Save RLO to the BR Bit

5.1.2 Set / Reset and Edge Triggered Instructions


Instruction = S R FP FN E A M L DBX DIX Address ID Description Assign Value of RLO (Result of Logic Operation) Set addressed Bit to " 1 " Set addressed Bit to " 0 "e Positive Edge detection Negative Edge detection Input Output Bit Memory Local Data bit Data Bit Instance Data Bit

5.1.3 Master Control Relay (MCR) Instructions


Instruction MCRA MCRD MCR( )MCR Address ID Description Activate the MCR Deactivate the MCR Open the MCR Zone Close the MCR Zone

S7 for Windows SoftPLC

Chapter 5

SoftPLC Instruction Set

Page 13

5.2 Load and Transfer Instructions


Instruction L T IB IW ID QB QW QD MB MW MD LB LW LD DBB DBW DBD DIB DIW DID STW L L L LC L LC L L L L Const #Pointer T T C C DBNO DBLG DINO DILG Address ID Description Load into ACCU1 Transfer Contents of ACCU1 to Input Byte Input Word Input Double Word Output Byte Output Word Output Double Word Bit Memory Byte Bit Memory Word Bit Memory Double Word Local Data Byte Local Data Word Local Data Double Word Data Byte Data Word Data Double Word Instance Data Byte Instance Data Word Instance Data Double Word Status Word Constant Value Pointer Timer Time Value (BCD coded) Counter Count Value (BCD coded) Data Block Number Data Block Length Data Block Number (Instance Data Block) Data Block Length (Instance Data Block)

S7 for Windows SoftPLC

Page 14

SoftPLC

Chapter 5

5.3 Peripheral Access Instructions


Instruction L L L T T T Address ID PIB PIW PID PQB PQW PQD Description Load Peripheral Input Byte into ACCU1 Load Peripheral Input Word into ACCU1 Load Peripheral Input Double Word into ACCU1 Transfer Contents of ACCU1 to Peripheral Output Byte Transfer Contents of ACCU1 to Peripheral Output Word Transfer Contents of ACCU1 to Peripheral Output Double Word

5.4 Accumulator Instructions


Instruction PUSH POP ENT LEAVE TAK CAW CAD Address ID Description The contents of ACCU1, ACCU2, and ACCU3 are transferred to ACCU2, ACCU3, and ACCU4 The contents of ACCU2 and ACCU3 are transferred to ACCU3 and ACCU4 The contents of ACCU2, ACCU3, and ACCU4 are transferred to ACCU2 and ACCU3 The contents of ACCU3 and ACCU4 are transferred to ACCU1, ACCU2, and ACCU3 The contents of ACCU1 and ACCU2 are swapped The Order of the Bytes in ACCU1-L (Byte 0 and 1) is reversed. The Order of all Bytes in ACCU1 is reversed.

5.5 Shift and Rotation Instructions


Instruction SLW SLD SRW SRD SSI SSD Address ID Description Shift the contents of ACCU1-L to the left (Word shift) Shift the contents of ACCU1 to the left (Double Word shift) Shift the contents of ACCU1-L to the right (Word shift) Shift the contents of ACCU1 to the right (Double Word shift) Shift ACCU1-L contents to the right (Word shift with sign) Shift ACCU1contents to the right (Double Word shift with sign)

S7 for Windows SoftPLC

Chapter 5

SoftPLC Instruction Set

Page 15

Shift and Rotation Instructions Instruction RLD RLDA RRDA RRD constant Address ID

(continued)

Description Rotate the contents of ACCU1 to the left (Double Word) Rotate the contents of ACCU1 one bit to the left through CC1 Rotate the contents of ACCU1 one bit to the right through CC1 Rotate the contents of ACCU1 to the right (Double Word) Number of places to Shift / Rotate Number of places to Shift / Rotate located in ACCU2

5.6 Timer Instructions


Instruction SP SE SD SS SF R FR Address ID T T T T T T T Description Start Timer as Pulse on Positive Edge (from "0" to "1") Start Timer as Extended Pulse on Positive Edge Start Timer as ON Delay on Positive Edge Start Timer as Retentive ON Delay on Positive Edge Start Timer as OFF Delay on Negative Edge (from "0" to "1") Reset Timer Enable Timer for Restarting on Positive Edge (from "0" to "1")

5.7 Counter Instructions


Instruction CU CD S R FR Address ID C C C C C Description Increment Counter by "1" on Positive Edge (from "0" to "1") Decrement Counter by "1" on Positive Edge (from "0" to "1") Preset Counter on Positive Edge (from "0" to "1") Reset Counter on Positive Edge (from "0" to "1") Enable Counter for counting on Positive Edge (from "0" to "1")

S7 for Windows SoftPLC

Page 16

SoftPLC

Chapter 5

5.8 Word Instructions


Instruction AW AD OW OD XOW XOD constant Address ID Description AND contents of ACCU1-L (AND Word) AND contents of ACCU1 (AND Double Word) OR contents of ACCU1-L (OR Word) OR contents of ACCU1 (OR Double Word) Exclusive OR contents of ACCU1-L (XOR Word) Exclusive OR contents of ACCU1 (XOR Double Word) With a Word or Double Word constant With the contents of ACCU2

5.9 Arithmetic Instructions


Instruction ==I <>I >I >=I <I <=I ==D <>D >D >=D <D <=D ==R <>R >R >=R <R <=R SIN COS TAN
S7 for Windows SoftPLC

Address ID

Description Compare two Integer Values for Equal Compare two Integer Values for NOT Equal Compare two Integer Values for Greater Compare two Integer Values for Greater or Equal Compare two Integer Values for Less Compare two Integer Values for Less or Equal Compare two Double Integer Values for Equal Compare two Double Integer Values for NOT Equal Compare two Double Integer Values for Greater Compare two Double Integer Values for Greater or Equal Compare two Double Integer Values for Less Compare two Double Integer Values for Less or Equal Compare two Real Numbers for Equal Compare two Real Numbers for NOT Equal Compare two Real Numbers for Greater Compare two Real Numbers for Greater or Equal Compare two Real Numbers for Less Compare two Real Numbers for Less or Equal Calculate the Sine of a Real Number Calculate the Cosine of a Real Number Calculate the Tangent of a Real Number

Chapter 5

SoftPLC Instruction Set

Page 17

Arithmetic Instructions Instruction ASIN ACOS ATAN SQR SQRT EXP LN +I -I *I /I +D -D *D /D +R -R *R /R MOD + +P# DEC INC constant constant Address ID

(continued) Description Calculate the Arcsine of a Real Number Calculate the Arccosine of a Real Number Calculate the Arctangent of a Real Number Calculate the Square of a Real Number Calculate the Square Root of a Real Number Calculate the Exponential Value of a Real Number (Base "e") Calculate the Natural Logarithm of a Real Number Add two Integer Values Subtract one Integer Value from another Multiply one Integer Value with another Divide one Integer Value by another Add two Double Integer Values Subtract one Double Integer Value from another Multiply one Double Integer Value with another Divide one Double Integer Value by another Add two Real Numbers Subtract one Real Number from another Multiply one Real Number with another Divide one Real Number by another Divide one Double Integer Value by another (with Remainder) Add a Constant Add a Pointer Decrement ACCU1-LL (one Byte) Increment ACCU1-LL (one Byte)

5.10 Data Type Conversion Instructions


Instruction ITD ITB DTB DTR BTI BTD RND Address ID Description Convert from Integer to Double Integer Convert from Integer to BCD Convert from Double Integer to BCD Convert from Double Integer to Real Number Convert from BCD to Integer Convert from BCD to Double Integer Convert a Real Number to a Double Integer Value
S7 for Windows SoftPLC

Page 18

SoftPLC

Chapter 5

Data Type Conversion Instructions Instruction RND+ RNDTRUNC INVI INVD NEGI NEGD NEOR ABS Address ID Description

(continued)

Convert a Real Number to a Double Integer Value (rounded UP to the next whole number) Convert a Real Number to a Double Integer Value (rounded DOWN to the next whole number) Convert a Real Number to a Double Integer Value (the places after the decimal point are truncated) Form the Ones Complement of ACCU1-L (Integer) Form the Ones Complement of ACCU1-L (Double Integer) Form the Twos Complement of ACCU1-L (Integer) Form the Twos Complement of ACCU1-L (Double Integer) Negate the Real Number in ACCU1 Form the Absolute Value of the Real Number in ACCU1

5.11 Jump Instructions


Instruction JU JC JCB JCN JNB JBI JNBI JZ JN JP JPZ JM JMZ JUO JO JOS JL LOOP Address ID Label Label Label Label Label Label Label Label Label Label Label Label Label Label Label Label Label Label Description Jump unconditional Jump if RLO = 1 Jump if RLO = 1, save the RLO in the BR Bit Jump if RLO = 0 Jump if RLO = 0, save the RLO in the BR Bit Jump if BR = 1 Jump if BR = 0 Jump if Result equal to Zero ( = 0) (CC1 = 0 and CC0 = 0) Jump if Result not equal to Zero ( 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 1 and CC0 = 0)) Jump if Result greater than Zero ( > 0) (CC1 = 0 and CC0 = 0) Jump if Result greater or equal to Zero ( >= 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 0 and CC0 = 0)) Jump if Result less than Zero ( < 0) (CC1 = 0 and CC0 = 0) Jump if Result less or equal to Zero ( <= 0) ((CC1 = 0 and CC0 = 1) or (CC1 = 0 and CC0 = 0)) Jump if Unordered Math Instruction Jump on Overflow (OV = 1) Jump on Stored Overflow (OS = 1) Jump distributor Loop programming (decrement ACCU1-L and jump if 0) (CC1 = 1 and CC0 = 1)

S7 for Windows SoftPLC

Chapter 5

SoftPLC Instruction Set

Page 19

5.12 Block Call Instructions


Instruction CALL FB CALL FC CALL SFB CALL SFC UC FB CC FB UC FC CC FC BEU BEC BE OPN DB DI TDB Open Data Block Open Instance Data Block Exchange Data Block Registers Address ID Description Unconditional Call of an FB with Parameter Transfer Unconditional Call of an FC with Parameter Transfer Unconditional Call of an SFB with Parameter Transfer Unconditional Call of an SFC with Parameter Transfer Unconditional Call of a Function Block (without Parameter) Conditional Call of a Function Block (without Parameter) Unconditional Call of a Function (without Parameter) Conditional Call of a Function (without Parameter) End Block Unconditionally End Block Conditionally if RLO = "1" End Block

5.13 Indirect Addressing Instructions


Instruction LAR1 LAR2 MD LD DBD DID LAR1 LAR2 LAR1 LAR1 LAR2 AR2 P# P# Address ID Description Load Address Register 1 (AR1) Load Address Register 2 (AR2) with Bit Memory Double Word with Local Data Double Word with Data Block Double Word with Instance Data Block Double Word Load Address Register 1 (AR1) with Contents of ACCU1 Load Address Register 2 (AR2) with Contents of ACCU1 Load Address Register 1 (AR1) with Contents of Address Register 2 (AR2) Load Address Register 1 (AR1) with Pointer Load Address Register 2 (AR2) with Pointer

S7 for Windows SoftPLC

Page 20

SoftPLC

Chapter 5

Indirect Addressing Instructions Instruction TAR1 TAR2 MD LD DBD DID TAR1 TAR2 TAR1 TAR +AR1 +AR2 +AR1 +AR2 P# P# AR2 P# Address ID

(continued)

Description Transfer Contents of Address Register 1 (AR1) in Transfer Contents of Address Register 2 (AR2) in Bit Memory Double Word Local Data Double Word Data Block Double Word Instance Data Block Double Word Transfer Contents from Address Register 1 (AR1) in ACCU1 Transfer Contents from Address Register 2 (AR2) in ACCU1 Transfer Contents from Address Register 1 (AR1) in Address Register 2 (AR2) Swap Contents of Address Register 1 (AR1) with Contents of Address Register 2 (AR2) Add Contents from ACCU1 to Address Register 1 (AR1) Add Contents from ACCU1 to Address Register 2 (AR2) Add Pointer to Address Register 1 (AR1) Add Pointer to Address Register 2 (AR2)

5.14 Program Display and Null Operation Instructions


Instruction NOP NOP BLD Address ID 0 1 constant Description Null Operation Instruction Null Operation Instruction Program display instruction (treated as a Null Operation)

5.15 PLC Memory Allocation


The PLC memory allocation of the Software PLC, in critical areas, is equal to the PLC memory allocation of the Siemens PLC CPU S7-416. Please note: When accessing the Software PLC memory, via a Windows application, the low byte and the high byte must be exchanged.

5.16 System Data Area Allocation


The allocation of the Software PLC System Data area, in critical areas, is equal to the allocation of the System Data area in a Siemens PLC CPU S7-416.
S7 for Windows SoftPLC

Chapter 5

SoftPLC Instruction Set

Page 21

5.17 Organization Blocks (OBxx) integrated


The Organization Blocks listed in the table below are only executed if the user programs them. The call of these Organization Blocks are integrated in the Software PLC. OB Number OB1 OB10 OB17 OB20 OB23 OB30 OB38 OB80 OB87 OB90 OB100/OB101 OB121/OB122 Description Free Cycle (Main Program) Time of Day Interrupts Time Delay Interrupts Timed Interrupts (cyclic calls) Asynchronous Error Interrupts Background Execution Complete Restart / Warm Restart Synchronous Error Interrupts (Programming Faults)

5.18 Integrated System Functions


All System Functions (SFC) relevant to the Software PLC are integrated. S7 for Windows supports the SFC Calls because the Block Header Declarations are present internally. In the S7 for Windows editor mode, an integrated SFC is called with the menu command " Insert / S7 Block Call". The selected Block, with the Block Parameter names and types, is inserted in the displayed network.

The following Table lists the integrated System Functions (SFC) SFC No. SFC0 SFC1 SFC20 SFC Name SET_CLK READ_CLK BLKMOV Function Set clock Read clock Copy variable (n = number of bytes to be copied)

S7 for Windows SoftPLC

Page 22

SoftPLC

Chapter 5

Integrated System Functions (SFC) SFC No. SFC21 SFC22 SFC23 SFC24 SFC25 SFC28 SFC29 SFC30 SFC31 SFC32 SFC33 SFC34 SFC39 SFC40 SFC41 SFC42 SFC43 SFC51 SFC64 SFC Name FILL CREAT_DB DEL_DB TEST_DB COMPRESS SET_TINT CAN_TINT ACT_TINT QRY_TINT SRT_DINT CAN_DINT QRY_DINT DIS_IRT EN_IRT DIS_AIRT EN_AIRT RE_TRIGR RDSYST TIME_TCK Function

(continued)

Set array default variables Create Data Block Delete Data Block Test Data Block Compress Memory (user memory) Set Time-of-Day interrupt Cancel Time-of-Day interrupt Activate Time-of-Day interrupt Query Time-of-Day interrupt Start Time-Delay interrupt Cancel Time-Delay interrupt Query Time-Delay interrupt Discard new events Stop discarding events Delay interrupt events Stop delaying interrupt events Retrigger watchdog monitoring "Module ID" partial list Display millisecond timer

5.19 Integrated System Function Blocks


All the System Function Blocks (SFB) relevant to the Software PLC are integrated. S7 for Windows supports the SFB calls because the Block Header Declarations are present internally. In the S7 for Windows editor mode an integrated SFB is called with the menu command " Insert / S7 Block Call". The selected Block with the Block Parameter names and types are inserted in the displayed network. The following Table lists the integrated System Function Blocks (SFB) SFB No. SFB0 SFB1 SFB2 SFB3 SFB4 SFB5 SFB32
S7 for Windows SoftPLC

SFB Name CTU CTD CTUD TP TON TOF DRUM

Function Count up Count down Count up and down Generate pulse Generate On-Delay Generate Off-Delay Implement sequencer

Chapter 6

Direct Access Data Interface

Page 23

6 Direct Access Data Interface


With several programming languages (e.g. Visual Basic, Visual C or Borland C++Builder) you can directly access the Software PLC. The required DLL (PLC32.DLL) is part of the Software PLC package. The DLL is a 32 bit application.

6.1 Data Transfer and Conversion Functions


The following chapters describe the functions available to transfer and convert data.

6.1.1 Read Value


The "Read Value" function transfers the requested data from the Software PLC to your application.

unsigned long DLLexport rdVal

(unsigned char far* typ, unsigned long nr, int DBNr, unsigned size, int far* ok);
Comment

Parameter typ 'E' 'A' 'M' 'Z' 'T' 'D' nr DBNr size

Description PLC Operand Input Output Memory Bit (Flag) Counter Value Timer Value Data Word or Data Double Word Address Data Block Number Number of Bits 0..7 8 16 32 = Bit No. 0 7 = 1 Byte = 1 Word = 1 Double Word 'I' 'Q' 'M' 'C' 'T' 'D'

16 Bit access only 16 Bit access only (Number of Bits depends on Parameter size ) Byte address of the Operand to transfer 1 - 4095 only 'E', 'A', 'M'

ok

0: Error

Error message

S7 for Windows SoftPLC

Page 24

SoftPLC

Chapter 6

6.1.2 Write Value


The "Write Value" function transfers the assigned data from your application to the Software PLC.

void DLLexport wrVal

(unsigned unsigned unsigned int far*

char far* typ, long nr, int DBNr, size, unsigned long val, ok);

Parameter typ 'E' 'A' 'M' 'Z' 'T' 'D' nr DBNr size

Description PLC Operand Input Output Memory Bit (Flag) Counter Value Timer Value Data Word or Data Double Word Address Data Block Number Number of Bits 0..7 8 16 32 = Bit No. 0 7 = 1 Byte = 1 Word = 1 Double Word 'I' 'Q' 'M' 'C' 'T' 'D'

Comment

16 Bit access only 16 Bit access only (Number of Bits depends on Parameter size ) Byte address of the Operand to transfer 1 - 4095 only 'E', 'A', 'M'

ok

0: Error

Error message

6.1.3 Read Several Values


The " Read Several Values " function transfers the requested data from the Software PLC to your application.

void DLLexport rdVals

(unsigned unsigned unsigned int far*

char far* typ, long nr, int DBNr, size, unsigned char far* vals, ok);
Comment

Parameter typ 'E' 'A' 'M' 'D'

Description PLC Operand Input Output Memory Bit (Flag) Data Word 'I' 'Q' 'M' 'D'

Parameter "size" determines the number of Bytes Parameter "size" determines the number of Bytes Parameter "size" determines the number of Bytes Parameter "size" determines the number of Words

S7 for Windows SoftPLC

Chapter 6

Direct Access Data Interface

Page 25

Read several values Parameter nr DBNr size Vals ok

(continued) Comment

Description Address Data Block Number Number of Bytes or Words Byte Values 0: Error

1 - 4095

Error message

6.1.4 Write Several Values


The " Write Several Values " function transfers the assigned data from your application to the Software PLC.

void DLLexport wrVals

(unsigned unsigned unsigned int far*

char far* typ, long nr, int DBNr, size, unsigned char far* vals, ok);
Comment

Parameter typ 'E' 'A' 'M' 'D' nr DBNr size 'E' 'A' 'M' 'D' Vals ok

Description PLC Operand Input Output Memory Bit (Flag) Data Word Address Data Block Number Number of Bytes or Words Input Output Memory Bit (Flag) Data Word Byte Values 0: Error PLC Operand 'I' 'Q' 'M' 'D' 'I' 'Q' 'M' 'D'

1 - 4095

Parameter "size" determines the number of Bytes Parameter "size" determines the number of Bytes Parameter "size" determines the number of Bytes Parameter "size" determines the number of Words Attention! Field size must be set to hold all requested bytes. Error message

S7 for Windows SoftPLC

Page 26

SoftPLC

Chapter 6

6.1.5 Read Data Block


The "Read Data Block" function transfers the contents of a Data Block from the SoftPLC to your application.

void DLLexport RdDB

(unsigned unsigned unsigned unsigned

short int nr, short int* Baustein, int* Anzahl, char Synchron, int far* ok);

Parameter nr Baustein Anzahl

Description Data Block Number Pointer to the Data Block contents Number of words to be read from the Data Block No Function 0: Error

Comment 1 - 4095 Baustein " "Block" Anzahl " "Number" If the Data Block has less words than requested, the "Number (Anzahl)" is automatically adjusted. Synchron " "synchronous" The parameter is inserted for compatibility reasons. Error message

Synchron ok

Attention! The information from the Data Block is read in a word orientated format. The Low-Byte and the High-Byte are interchanged.

6.1.6 Write Data Block


The "Write Data Block" function transfers Data from your application into a Data Block of the Software PLC to.

void DLLexport WrDB

(unsigned unsigned unsigned unsigned

short int nr, short int* Baustein, int* Anzahl, char Synchron, int far* ok);
Comment 1 - 4095 Baustein " "Block" The Buffer from which the DB will be copied from. Anzahl " "Number" If the Data Block has less words than requested, the "Number (Anzahl)" is automatically adjusted.

Parameter nr Baustein Anzahl

Description Data Block Number Pointer to the new Data Block Number of words to be written into the Data Block

S7 for Windows SoftPLC

Chapter 6

Direct Access Data Interface

Page 27

Write Data Block Parameter Synchron

(continued) Comment Synchron " "synchronous" The parameter is inserted for compatibility reasons. Error message

Description No Function

ok

0: Error

Attention! The information is written into the Data Block in a word-orientated format. The Low-Byte and the High-Byte are interchanged.

6.1.7 FloatToMC5
The "FloatToMC5" function converts a floating-point value (REAL) from the format used in the IBM PC to the format used in the S7 PLC (Double Word - REAL).

void DLLexport FloatToMC5

(float FloatVal, unsigned long far* MC5Val);

Parameter FloatVal MC5Val

Description Floating-point value in the IEEE format or INTEL format respectively Floating-point value in the Siemens S7 format

6.1.8 MC5ToFloat
The "MC5ToFloat" function converts a floating-point value (REAL) from the format used in the S7 PLC (Double Word - REAL) to the format used in the IBM PC.

void DLLexport MC5ToFloat

(unsigned long MC5Val, float far* FloatVal);

Parameter MC5Val FloatVal

Description Floating-point value in the Siemens S7 format Floating-point value in the IEEE format or INTEL format respectively

S7 for Windows SoftPLC

Page 28

SoftPLC

Chapter 6

6.2 Example
The example shows a data transfer between the Software PLC and a Borland C++ Builder application. More examples can be found on the Software PLC CD.

6.2.1 PLC Program


The example requires the programming of Organization Block OB1 and the Data Block DB4095.

6.2.2 Visualization
The example shows a simple visualization of Software PLC Operands using the Borland C++ compiler.

The example uses the following assignments: Position of the Valve (Speed): Tank Level = Pump Rotation Angle: Pump Rotation Text: MB10 Value QW12 Value DB4095 String

S7 for Windows SoftPLC

Chapter 6

Direct Access Data Interface

Page 29

6.2.3 Source Code


The possibilities for direct access of operands located in the Software PLC are shown (the important parts) in the following listing:

void __fastcall TForm1::TrackBar1Change(TObject *Sender) { int ok; unsigned char typ = 'M'; GlobalPosition = TrackBar1->Position; wrVal (&typ,10,0,8,GlobalPosition,&ok); } void __fastcall TForm1::Timer1Timer(TObject *Sender) { int ok; unsigned char typ; int val; unsigned short int Baustein[64]; unsigned int Anzahl; char Stringtext[128]; unsigned int i; typ = 'A'; val = rdVal (&typ,12,0,16,&ok); AW12->Text = val; Pie1->Angles->StartAngle = val; Pie1->Angles->EndAngle = val + 10; ProgressBar->Position = val; typ = 'M'; val = rdVal (&typ,10,0,8,&ok); MB10->Text = val; if (rdVal (&typ,6,0,0,&ok)) m6pkt0->Text = "true"; else m6pkt0->Text = "false"; typ = 'T'; val = rdVal (&typ,99,0,16,&ok); val &= 0x07ff; T99->Text = val; // Modify Memory (Byte) // Read MB10 // Display Value // Read Memory Bit M6.0 // Display Value in dialog box // Display Value in dialog box // // // // Modify Timer Read Value of Timer T99 Mask Control Bits Display Value in dialog box // Modify Output Value // Read QW12

// Write to Memory(Byte)

Anzahl = 20; // Number of characters to read RdDB (4095,&Baustein[0],&Anzahl,0,&ok); // Transfer String // High- und Lowbyte tauschen for (i = 1; i <= Anzahl; i++) Baustein[i] = ((Baustein[i] & 0xff00)>>8)|((Baustein[i] &

0xff)<<8);

memcpy(Stringtext, &Baustein[1], Anzahl-1); String1->Text = AnsiString(Stringtext); // Dialog box display

S7 for Windows SoftPLC

Page 30

SoftPLC

Chapter 7

7 DDE Manager
The Software PLC supports Dynamic Data Exchange (DDE) for the exchange of data between the Software PLC and other Windows applications. The procedure to exchange data between the Software PLC and your Windows application, via the DDE, depends on your application. Please refer to the user manual for information on how to setup the data exchange with another Windows application (the Software PLC). The DDE Manager is a DDE Server with the following functions: Request () Poke () Advise () Unadvise () Coldlink and Hotlink With the Request function a value may be read from the Software PLC. With the Poke function a value may be written into the Software PLC. To establish a "Hotlink" connection between the Software PLC and your Windows application, the Advice function is used. Unadvise cancels this link. The Server Name of the DDE Manager is 'PLC416'. The Topic Name is 'PLCS7'. Name format of the data to be exchanged with the Software PLC (DDE Item) : Operand Input Bit (In.m) Input Byte (IBn) Input Word (IWn) Output Bit (Qn.m) Output Byte (QBn) Output Word (QWn) Memory Bit (Mn.m) Memory Byte (MBn) Memory Word (MWn) Data Byte (DBn,dbm) Name Format En.m Ebn Ewn An.m Abn Awn Mn.m Mbn Mwn DBn,dbm Range n: 0..511, m: 0..7 n: 0..511 n: 0..510 n: 0..511, m: 0..7 n: 0..511 n: 0..510 n: 0..4095, m: 0..7 n: 0..4095 n: 0..4094 n: 0..1023, dbm: 0..4095 Example E10.1 EB10 EW10 A12.1 AB12 AW12 M14.1 MB14 MW14 DB9,16 (DB9 of DB16) DBn Data Byte number dbm Data Block number DW3,16 (DW3 of DB16) DWn Data Word number dbm Data Block number T20 Z3

Data Word (DWn,dbm)

DWn,dbm

n: 0..1022, dbm: 0..4095

Timer (Tn Counter (Cn)

Tn Zn

n: 0..511 n: 0..511

S7 for Windows SoftPLC

Chapter 7

DDE Manager

Page 31

7.1 Example
Reading a Memory Byte With the Microsoft EXCEL Windows application, the Memory Byte 10 (MB10), from the Software PLC, should be read and displayed. In one of the Cells write the following Instruction: =PLC416|PLCS7!MB10 PLC416 PLCS7 MB10 DDE Manager Server Name DDE Manager Topic Name DDE-Manager Item Name

This instruction is a Remote Reference Formula. This formula automatically establishes a "Hotlink" to the Software PLC. Whenever the value of the Memory Byte MB10 changes, the new value is transmitted and displayed in EXCEL. Because of different versions of Microsoft EXEL it is possible that the Remote Reference Formula (each part must be in ' ' ) must be entered as followed: ='PLC416'|'PLCS7'!'MB10'

Writing into a Memory Byte The Value one ("1") is transferred from Microsoft EXCEL into the Input Byte (IB0) of the Software PLC (Microsoft Excel Visual Basic Macros). The following Visual Basic Macro inserts a "1" into IB0 of the Software PLC: Sub SendeS5W0() Range("B9").Value = 1 The following command opens the DDE Channel to the Software PLC. Only one (1) DDE Channel can be open any time! S5WChannel = DDEInitiate("PLC416"; "PLCS7") The following command fetches the contents of cell C5 and writes the contents into IB0 of the Software PLC: Application.DDEPoke S5WChannel, "EB0", Cells(5, 3) The following command closes the DDE Channel: DDETerminate (S5WChannel) EndSub

S7 for Windows SoftPLC

Page 32

SoftPLC

Chapter 8

8 Functions not Incorporated in the SoftPLC


Due to the physical differences between a hardware PLC and a PC executing a Windows application, not all of the functions in a hardware PLC can be integrated into the Software PLC. However, a program written to be executed on an S7-416 (S7-315) should run on the Software PLC with a minimum of modifications. The following Organization Blocks are not supported by the SoftPLC: OB60 OB40 OB47 Multi-Computing Interrupts Hardware Interrupts

Timer OB's are not interrupted by Windows, therefore these Timer OB's may not have a long execution time (<1ms). The following System Function and System Function Blocks are not integrated in the Software PLC: SFC44 SFC46 SFB33 SFB37 Transfer substitute value to ACCU1 Force CPU into STOP mode Generate block-related messages

S7 for Windows SoftPLC

Chapter 9

SoftPLC Configuration

Page 33

9 SoftPLC Configuration
The parameters required to adjust the operation of the Software PLC are located in the initialization file PLC43.INI. Section [PLC] In this section the basic settings of the Software PLC may be adjusted. Key Name S7_STORE REM Area Default Value Description Size of "Load Memory" (SoftPLC 416) The "Load Memory" of the SoftPLC 315 is fixed If set to "1" the memory for the M, T, and C is retentive. (Byte 0 up to the max setting from the Hardware Configuration).

50000..... 500000 End of PC Memory 0/1 0

Section [COM] In the section [COM] the parameter of the serial port COM1 are set. Key Name BAUD INT PORT Area 2400 .. 115000 PC depending PC depending Default Value Description 38400 3/4 2F8 / 3F8 Baud rate of the serial port Interrupt number of the serial port Port address of the serial port

Section [COM2] In the section [COM2] the parameter of the serial port COM2 are set. Key Name BAUD INT PORT Area 2400 .. 115000 PC depending PC depending Default Value Description 38400 3/4 2F8 / 3F8 Baud rate of the serial port Interrupt number of the serial port Port address of the serial port

Section [OEM] In the section [OEM] the DLL's used by the application are listed. These DLL's are hardware depending. Up to ten (10) DLL's can be incorporated (DLL0 up to DLL9). Key Name DLLn Area File_Name.DLL Default Value Description --User DLL (e.g. CIF driver CIF30X.DLL

S7 for Windows SoftPLC

Page 34

SoftPLC

Chapter 10

10 CIF30X - Driver
The driver, CIF30X (CIF30 eXtended), as a part of the Software PLC package, can be used in conjunction with the Profi-Bus board CIF30/5060 , the InterBus board CIF30/5060 , the CAN-Open board CIF30/5060 , or the DeviceNet board CIF30/5060 . These boards are manufactured by the Hilscher company and may be used to connect the Software PLC with a corresponding bus system.

10.1 Installation
Prior to inserting the CIF30/5060 board into an empty PC slot, make sure that the jumpers are set as follows: Dual Port Address: No IRQ: (Jumper Field J7) (Jumper at J5) Default = CA00:0000 The Software PLC doesnt use an interrupt

Make sure that any other device in the PC does not use the Dual Port Addresses. Usually the addresses D000 up to D400 are a better choice than the default address CA00. Please check the settings in the [CIF30X] section of the PLC43.INI initialization file. [OEM] DLL0=CIF30X.DLL [CIF30X] CIF30DP=CA00 StatusFB=252 ControlOB=210 DP_Size=1 ;Dual port address of the CIF30 board ;Number of the Status SFB ;Number of the Control SFB ;CIF board with additional dual port memory (1=8KB, 2=16KB)

If a Dual Port address other than the default address is used, the address parameter CIF30_DP= xxxx must be set accordingly. After the driver installation, the System Function Blocks SFB210 and SFB252 are listed in the PLC Block List (S7 for Windows). If you want to use a Dual Port address that is above the 1 Megabyte limit (PCI boards only) the following parameter must be inserted in the PLC43.INI file ([CIF30X] section) instead of the CIF30_DP= xxxx . ( CONFUSING) BoardNumber = n (n=0 up to n=3)

When this parameter is set, access to the Dual Port is controlled by an additional DLL which will be supplied by the Hilscher company on request. [CIF30X] BoardNumber = n StatusFB=252 ControlOB=210 DP_Size=1
S7 for Windows SoftPLC

;CIF30 board number (n=0 up to n=3) ;Number of the Status SFB ;Number of the Control SFB ;CIF board with additional dual port memory (1=8KB, 2=16KB)

Chapter 10

CIF30X - Driver

Page 35

10.2 System Function Blocks


The following descriptions assume that the parameters in the PLC43.INI file are set as follows: [CIF30] ControlOB=210 SteuerFB=252 The PLC Block List (S7 for Windows) displays the following System Function Blocks: SFB210 SFB252 Control System Function Block CIF Status request System Function Block

10.2.1 CIF Status Request


To read the CIF status information from the System Function Block SFB252, the Block must be called periodically (e.g. called from OB1). The System Function Block SFB252 has the following parameters: Name RDY RUN Area OUT OUT Type BOOL BOOL Function CIF board ready Communication active

The CIF Status request System Function Block SFB252 must be called with its assigned Instance Data Block: CALL SFB252, DB252 OUT0: = M10.0 OUT1: = M10.1 //RDY //RUN

10.2.2 CIF Control System Function Block


The Control System Function Block SFB210 is provided to execute specific functions available with the CIF board. The Control System Function Block SFB210 may be called as follows: OPN L L UC DB <Control Data Block> <Parameter> <Function Number> SFB 210 // Not required with all functions // ACCU2, not required with all functions // ACCU1, see the following chapters for explanations // Call System Function Block (without parameters) // ACCU1 contains the returned parameters // ACCU2 contains the error code // The ROL is set if the function was executed // successfully

The control SFB252 does not require an Instance Data Block. The parameter transfer is done via ACCU1 and ACCU2. The SFB must be called with the commands UC SFB252 (CC) because no Instance Data Block is required.
S7 for Windows SoftPLC

Page 36

SoftPLC

Chapter 10

10.3 Control SFB252 Functions


The following functions are implemented in the SFB252 FCT No.: 102 125 126 130 131 132 133 134 135 136 137 139 140 141 142 143 Function Setting the Number of the Digital Inputs and Outputs Reading the Process Inputs (Peripheral Inputs) Writing to the Process Outputs (Peripheral Outputs) Reading the Global Diagnostic Bits Reading the Bus Status Reading an Illegal Bus Address Reading the Error Number Reading the Status-Bits Reading the Diagnostic Bits Reading the Dual Port Memory Writing to the Dual Port Memory Suppressing the Watchdog Restarting the Watchdog Reading the "HostFlags" Reading the "DevFlags" Writing to the "DevFlags"

10.3.1 FCT 102 Setting the Number of the Digital Inputs and Outputs
This function defines the number of Inputs and Outputs to be used. The default setting of the Software PLC is 512 Byte digital Inputs / Outputs. You may use this function to reduce the number of digital Inputs / Outputs. A reduced number of digital I / O bytes will decrease the execution time of the Software PLC. Example: L L UC 50 102 SFB 210 // 50 I/O Bytes are required // Load Function Number into ACCU1 // Calling the function (FCT 102)

Returned Values ACCU1 ACCU2 RLO Irrelevant = 0 = no error = 1 = no error Error Code: 1 = to many digital I / O bytes = 0 = error (error code in ACCU2)

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 37

10.3.2 FCT 125 Reading the Process Inputs (Peripheral Inputs)


With this function the Process Inputs (Peripheral Inputs) can be read and are written in the defined Data Block. This function writes unsynchronized. If using word orientated Peripheral Inputs no data consistency is given. This function may only be used with byte orientated Peripheral Inputs. The Data Block must exist prior to using this function. The function reads all the Peripheral Inputs. If the Data Block has less bytes than the number of Peripheral Inputs available, the read process will be terminated as soon as the Data Block limit is reached and an error code is generated. Example: OPN DB70 L L UC 125 SFB 210 // The DB70 will receive the data from the Peripheral Inputs // Load Function Number into ACCU1 // Calling the function (FCT 125) W#16#0100 // Starting address of the Process Inputs (Peripheral Inputs) (100hex)

Returned Values ACCU1 ACCU2 RLO = 0 = no error = 0 = no error = 1 = no error (ACCU2 must also be "0") Error Code 1 = Data Block non existing 2 = Data Block size not equal Peripheral Input area

= 0= error (error code in ACCU2)

10.3.3 FCT 126 Writing to the Process Outputs (Peripheral Outputs)


With this function the contents of the defined Data Block is written to the Process Outputs (Peripheral Outputs). This function writes unsynchronized. If using word orientated Peripheral Outputs no data consistency is given. This function may only be used with byte orientated Peripheral Outputs. This function writes the contents of all the bytes from the defined Data Block to the Peripheral Outputs. If the Data Block has more bytes than the Peripheral Outputs area capacity, the write process will be terminated as soon as the Peripheral Output limit is reached and an error code is generated. Example: OPN DB70 L L UC 126 SFB 210 // The data from the DB70 is written into the Peripheral Output area // Load Function Number into ACCU1 // Calling the function (FCT 126) W#16#0100 // Starting address of the Process Outputs (Peripheral Outputs) (100hex)

Returned Values ACCU1 ACCU2 RLO = 0 = no error = 0 = no error = 1 = no error (ACCU2 must also be "0") Error Code 1 = Data Block non existing 2 = Data Block size not equal Peripheral Output area

= 0= error (error code in ACCU2)


S7 for Windows SoftPLC

Page 38

SoftPLC

Chapter 10

10.3.4 FCT 130 Reading the Global Diagnostic Bits


With this function the Global Diagnostic Bits can be read from the CIF board. Global Diagnostic Bits of the CIF30/5060 Profi-Bus board: Bit 0 1 2 3 4 5 6 7 Profi-Bus Error Message Invalid Parameter Branched into the Auto_Clear_Mode due to Module Bus failure At least one Slave is not in the Data Transfer Mode or indicates a serious failure Serious Bus Failure, no further data transfer possible Short circuit on the Bus Host not ready reserved reserved

Global Diagnostic Bits of the CIF30/5060 InterBus board: Bit 0 1 2 3 4 5 6 7 InterBus Error Message Invalid Parameter System failure occurred At least one Slave indicates Module failure At least one W1 Interface failure At least one W2 Interface failure reserved reserved reserved

Example: L UC T 130 SFB 210 MB 0 // Load Function Number into ACCU1 // Calling the function (FCT 130) // Transferring the Global Diagnostic Bits into Memory Byte MB0

Returned Values ACCU1 = Global Diagnostic Bits

10.3.5 FCT 131 Reading the Bus Status


With this function the Bus Status can be read from the CIF board. Bus Status of the CIF30/5060 InterBus board: Bit 0 1 to 7 Profi-Bus Error Message Bus segment not turned off reserved

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 39

Example: L UC T 131 SFB 210 MB 2 // Load Function Number into ACCU1 // Calling the function (FCT 131) // Transferring the Bus Status Bits into Memory Byte MB2

Returned Values ACCU1 = Bus Status Bits

10.3.6 FCT 132 Reading an Illegal Bus Address


With this function an Illegal Bus Address can be read from the CIF board. Example: L UC T 132 SFB 210 MB 4 // Load Function Number into ACCU1 // Calling the function (FCT 132) // Transferring the illegal bus address into Memory Byte MB4

Returned Values ACCU1 = Illegal bus address

10.3.7 FCT 133 Reading the Error Number


With this function an Error Number can be read from the CIF board. Example: L UC T 133 SFB 210 MB 5 // Load Function Number into ACCU1 // Calling the function (FCT 133) // Transferring the Error Number into Memory Byte MB5

Returned Values ACCU1 = Error Number

InterBus Error Numbers Error No.: 0 50 51 53 54 55 Description no mistakes appear IBS task not found no global data-field PLC task not found Non-existing master parameters error in reading the master parameters device device device device project planning technical support technical support technical support execute download of data base again execute download of data base again Error Source Possible Cure

S7 for Windows SoftPLC

Page 40

SoftPLC

Chapter 10

InterBus Error Numbers Error No.: 56 57 59

(continued) Description Error Source project planning project planning project planning Possible Cure execute download of data base again execute download of data base again check projected addresses

Non-existing project parameters network data base includes no parameters The projected send process data offset address of a participant, is outside the allowable border of 0- 255

60

The projected receive process data offset project planning address of a participant, is outside the allowable border of 0- 255 Data-area of slaves are overlapping in the project planning send process data no segment in the init phase no program code for the external processor device device

check projected addresses

61 63 64 65 66 67 69 213 101

technical support execute download of the SCA *.img firmware

hardware or software error in the external external field bus technical support processor processor no project information database execute download of data base again check installation depths of the configured slaves check configuration in special slave length codes contact Hilscher company compare the ID and length codes of the slaves with the master configuration reduce the connected modules check the bus segments and voltage break-ins start the diagnostic function check the bus segments and start the diagnostic function run the bus segments separately with the system configurator check the cable connection between DEVICE and first slave module increment the supervision time or check the user program if running

illegal installation depth of a slave module project planning illegal length code structure surrender to operating system faulty the network configuration differs from configured configuration the configuration exceeds the maximum allowed configuration the configuration has changed during running state multiple data cycle error time out network error could not be localized project planning device bus

102 103 104 105 106

bus bus bus bus bus

108

no connection to a network

bus

220

the user program stops to handle the dual-port watchdog location in time user program does not acknowledge the process data indication in time (mode 0)

user program

221

user program

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 41

InterBus Error Numbers Error No.: 222

(continued) Description Error Source bus and data base bus device Possible Cure compare bus configuration list with ID and length codes of the slaves technical support technical support

the configured network is different than the connected network different count of modules was detected during identification cycles error in external processor communication

223 224

Profi Bus Error Numbers Error No.: 0 50 51 52 53 54 55 56 57 58 59 Description no mistakes appear USR_INTF-Task not found no global data-field FDL-Task not found PLC-Task not found non existing master parameters faulty parameter-value in the master parameters non existing slave parameters faulty parameter-value in a slave parameters data file double slave address projected send process data offset address of a participant outside the allowable border of 0- 255 projected receive process data offset address, of a participant, is outside the allowable border of 0- 255 Data-areas of slaves are overlapping in the send process data Data-areas of slaves are overlapping in the receive process data unknown process data handshake free RAM exceeded faulty slave parameter data sets no segment for the treatment free faulty reading of a data base structure-surrender to operating system faulty station reports overflow device device device device device project planning project planning project planning project planning project planning contact technical support contact technical support contact technical support contact technical support execute download of data base again contact technical support execute download of data base again contact technical support check projected addresses check projected addresses Error Source Possible Cure

60

project planning

check projected addresses

61 62 63 64 65 202 212 213 2

project planning project planning warm start device project planning device device device master telegram

check projected addresses check projected addresses check warm start parameters contact technical support contact technical support contact technical support execute download of data base again contact technical support check length of configured slave configuration or parameter data.
S7 for Windows SoftPLC

Page 42

SoftPLC

Chapter 10

Profi Bus Error Numbers Error No.: 3 9

(continued) Description Error Source Possible Cure check slave if PROFIBUSDP norm compatible check configuration data of the station and compare it with the physical I/O data length check bus cable, check bus address of slave check FDL-Address of master or highest-stationAddress of other master systems. examine bus cabling to bus short circuits.

request function of master is not activated master telegram in the station no answer-data, although the slave must respond with data slave

17 18

no response of the station master not into the logical token ring

slave device

10.3.8 FCT 134 Reading the Status Bits


This function can read the Status Bits. Prior calling the function the Byte Number (0 .. 15) to be read must be placed in the ACCU2. After executing the function, the Status bits of the selected Byte are located in the LowerByte of ACCU1. The value of a single Status bit indicates if the Slave is active or inactive. Example: L L UC T W#16#03 134 SFB 210 MB 6 // Byte number 3 selected (03 hex) // Load Function Number into ACCU1 // Calling the function (FCT 134) // Transferring the Status bits into Memory Byte MB6

Returned Values ACCU1 Lower Byte / Single bit = 0 = Slave inactive = 1 = Slave active

10.3.9 FCT 135 Reading the Diagnostic Bits


This function can read the Diagnostic Bits. Prior calling the function the Byte Number (0 .. 15) to be read must be placed in the ACCU2. After executing the function, the Diagnostic bits of the selected Byte are located in the Lower-Byte of ACCU1. The value "1" of a single Diagnostic bit indicates that the Slave changed its status from active to inactive or vice versa. Example: L L W#16#03 135 // Byte number 3 selected (03 hex) // Load Function Number into ACCU1

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 43

UC T

SFB 210 MB 7

// Calling the function (FCT 135) // Transferring the Status bits into Memory Byte MB7

Returned Values ACCU1 Lower Byte / Single bit = 0 = No status change = 1 = Slave changed status

10.3.10 FCT 136 Reading the Dual Port Memory


This function reads the content of the Dual Port Memory of the CIF-board and writes the content to the defined Data Block. The content is always placed in the Data Block starting with Byte 0. The Data Block must exist prior to using this function. Prior calling the function the Number of Bytes and the relative address of the Dual Port Memory to be read must be placed in the ACCU2. The Number of Bytes to be read must be placed in the Low-Byte of ACCU2 and relative address in the High-Byte of ACCU2. Example: OPN DB60 L L UC W#16#0100 000A 136 SFB 210 // The DB60 will receive the contents of the Dual Port Memory // 10 Bytes starting at the relative address 100hex // Load Function Number into ACCU1 // Calling the function (FCT 136)

Returned Values ACCU1 ACCU2 = 0 = no error = 0 = no error (ACCU2 must also be "0") Error Code 1= 2= 3= RLO = 1 = no error Data Block non existing Number of requested Bytes exceeds the Dual Port Memory limit Number of requested Bytes exceeds the Data Block limit (not enough bytes in DB)

= 0= error (error code in ACCU2)

10.3.11 FCT 137 Writing to the Dual Port Memory


This function writes the content of a defined Data Block into the Dual Port Memory of the CIF-board. The content to be placed in the Dual Port Memory always starts with Byte 0 of the Data Block. If the Data Block has more bytes than the Dual Port Memory, the write process is terminated as soon as the limit is reached and an error code is generated. Prior calling the function the Number of Bytes and the relative address of the Dual Port Memory to be read must be placed in the ACCU2. The Number of Bytes to be read must be placed in the Low-Byte of ACCU2 and relative address in the High-Byte of ACCU2.

S7 for Windows SoftPLC

Page 44

SoftPLC

Chapter 10

Example: OPN DB60 L L UC W#16#0100 000A 137 SFB 210 // The DB60 will receive the contents of the Dual Port Memory // 10 Bytes starting at the relative address 100hex // Load Function Number into ACCU1 // Calling the function (FCT 137)

Returned Values ACCU1 ACCU2 = 0 = no error = 0 = no error (ACCU2 must also be "0") Error Code 1= 2= Data Block non existing Number of requested Bytes exceeds the Dual Port Memory limit

RLO

= 1 = no error

= 0= error (error code in ACCU2)

10.3.12 FCT 139 Suppressing the Watchdog


With this function the monitoring of the process control of the CIF board is suppressed. Example: L UC 139 SFB 210 // Load Function Number into ACCU1 // Calling the function (FCT 139)

Returned Values RLO = 1 = no error = 0= function not executed

10.3.13 FCT 140 Restarting the Watchdog


With this function the monitoring of the process control of the CIF board is restarted. This function restarts monitoring after suppressing the Watchdog with the function FCT 139. Example: L UC 140 SFB 210 // Load Function Number into ACCU1 // Calling the function (FCT 140)

Returned Values RLO = 1 = no error = 0= function not executed

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 45

10.3.14

FCT 141

Reading the "HostFlags"

With this function the HostFlags (8 Bits) can be read (messages from the host). HostFlag Bits: Bit 0 1 2 3 4 5 6 7 HostFlag Messages HostCom: DevAck: PdAck: reserved reserved Com: Run: Ready: User data transfer phase from at least one module active Parameter data valid, CIF ready for communication Module ready, no basic initialization error present HostMailBox command bit DevMailBox acknowledge bit Host I/O data synchronization acknowledge bit

Example: L UC T 141 SFB 210 MB 8 // Load Function Number into ACCU1 // Calling the function (FCT 141) // Transferring the HostFlags into Memory Byte MB8

Returned Values ACCU1 Lower Byte = HostFlags (8 Bits)

10.3.15

FCT 142

Reading the "DevFlags"

With this function the DevFlags (8 Bits) can be read (messages from the device). DevFlags Bits: Bit 0 1 2 3 4 5 6 7 DevFlag Messages HostAck: DevCom: PdCom: reserved reserved NotReady: Init: Reset: Terminate bus transfer or deactivate module. At least one module is in the reset mode Reset the CIF and transfer the parameters from the DPM Reset the CIF HostMailBox acknowledge bit DevMailBox command bit Dev I/O data synchronization command bit

Example: L UC 142 SFB 210 // Load Function Number into ACCU1 // Calling the function (FCT 141)
S7 for Windows SoftPLC

Page 46

SoftPLC

Chapter 10

MB 9

// Transferring the DevFlags into Memory Byte MB9

Returned Values ACCU1 Lower Byte = DevFlags (8 Bits)

10.3.16 FCT 143 Writing to the "DevFlags"


With this function information can be written into the DevFlags (8 Bits) (messages to the device). Prior calling the function the DevFlags must be placed in the ACCU2 (Lower-Byte). DevFlags Bits: Bit 0 1 2 3 4 5 6 7 DevFlag Messages HostAck: DevCom: PdCom: reserved reserved NotReady: Init: Reset: Terminate bus transfer or deactivate module. At least one module is in the reset mode Reset the CIF and transfer the parameters from the DPM Reset the CIF HostMailBox acknowledge bit DevMailBox command bit Dev I/O data synchronization command bit

Example: L L UC W#16#40 143 SFB 210 // DevFlag 7 (Reset the CIF and transfer the parameters from the DPM) // Load Function Number into ACCU1 // Calling the function (FCT 143)

Returned Values RLO = 1 = no error = 0= function not executed

S7 for Windows SoftPLC

Chapter 10

CIF30X - Driver

Page 47

10.4 CIF System Configuration


Prior to exchanging data between the Software PLC and the Field Bus Devices the CIF board must be configured. The Hilscher company supplies the System Configuration software with the CIF board. If you did not change the default Start Address (to change the default Start Address see chapter 10.5) the following address assignment must be set. Start address of the digital I/O area CIF address area from 0511. The following system parameters must be set in the System Configuration Setup dialog box.

10.5 Special Settings


If you do not want to put all the Inputs and Outputs in the CIF area, the following special settings can be done in the PLC43:INI initialization file. Attention! These settings are overwritten by the Control SFB252 Functions ! [CIF30X] BitStart = 0 BitEnd = 127 BitIn = 0 BitOut = 0 DP_Size = 1 ; Start address of the digital Inputs and Outputs (PEB0 511) ; End address of the digital Inputs and Outputs (PEB0 511) ; Start address of the digital Inputs and Outputs (PEB0 511) in the Dual Port Memory of the CIF board ; Start address of the digital Inputs and Outputs (PEB0 511) in the Dual Port Memory of the CIF board ; CIF board with extended Dual Port Memory (1 = 8Kbyte; 2 = 16Kbyte)

S7 for Windows SoftPLC

Page 48

SoftPLC

Chapter 10

10.6 Technical Data


SoftPLC PLC416 Load Memory Size Serial Ports Baud Rate Operands Area Limited by the amount of RAM installed in the PC COM1.. COM4, adjustable with the initialization file PLC43.INI 9600 115000 Baud Inputs (I) Outputs (Q) Memory (M) Timer (T) Counter (C) 0 ... 4095 65.534 Bytes Integrated, see chapter 5.18 of this manual t Integrated, see chapter 5.19 of this manual Adjustable M, T, C via the initialization file PLC43.INI 1ms 150ms (up to 2000ms adjustable) to all operands via PLC32.DLL TCP/IP via INAT driver 10, (DLL0 DLL9, initialization file PLC43.INI) 20 80%, initialization file PLC43.INI Yes Yes 0.0 511.7 0.0 511.7 0.0 16.383.7 0 ... 511 0 ... 511

Data Blocks Data Block Size SFC: SFB: Retentivity Cycle Time DDE Access Network Connections OEM Drivers Task Dual Processor Board Key Board Access

SoftPLC PLC315 Load Memory Size Serial Ports Baud Rate Operands Area 80kByte, fixed value COM1.. COM4, adjustable with the initialization file PLC43.INI 9600 115000 Baud Inputs (I) Outputs (Q) Memory (M) Timer (T) Counter (C) 0 ... 4095 65.534 Bytes Integrated, see chapter 5.18 of this manual Integrated, see chapter 5.19 of this manual Adjustable M, T, C via the initialization file PLC43.INI 1ms 150ms (up to 2000ms adjustable) to all operands via PLC32.DLL TCP/IP via INAT driver 10, (DLL0 DLL9, initialization file PLC43.INI) 20 80%, initialization file PLC43.INI Yes Yes 0.0 511.7 0.0 511.7 0.0 255.7 0 ... 127 0 ... 63

Data Blocks Data Block Size SFC: SFB: Retentivity Cycle Time DDE Access Network Connections OEM Drivers Task Dual Processor Board Key Board Access

S7 for Windows SoftPLC

Chapter 11

Appendix

Page 49

11 Appendix
Null Modem Cable Sub.-D Connector Female 9 Pin 1 2 3 4 5 6 7 8 9 Shell 25 Pin -----3 2 20 7 6 4 5 -----Shell Not Connected ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Not Connected ------------- Shield -------1 3 2 6 5 4 8 7 9 Shell Sub.-D Connector Female 9 Pin 25 Pin -----2 3 6 7 20 5 4 -----Shell

S7 for Windows SoftPLC

Page 50

SoftPLC

Chapter 11

S7 for Windows SoftPLC

Chapter 12

Index

Page 51

12 Index
Direct Access Data Interface ........................... 23 Dual Port Memory............................................ 43 Dual Processor Board ..................................... 48 Dynamic Data Exchange (DDE) ...................... 30

A
Access Data Interface...................................... 23 Accumulator Instructions.................................. 14 Addressing Instructions.................................... 19 Advise .............................................................. 30 AND.................................................................. 11 Arithmetic Instructions...................................... 16

E
Edge Triggered Instructions ............................ 12 Error Number ................................................... 39 Example..................................................... 28, 31 Exclusive OR ................................................... 11 Exit PLC........................................................... 10

B
Baud rate ......................................................... 10 Binary Result.................................................... 11 Bit Logic Instructions........................................ 11 Bit Memory....................................................... 11 Block Call Instructions...................................... 19 Boolean Logic Instructions............................... 12 Borland C++ Builder ...................................... 28 Bus Status........................................................ 38 Bytes Total ....................................................... 10

F
FCT 102 Setting the Number of the Digital Inputs and Outputs ........................... 36 FCT 125 Reading the Process Inputs (Peripheral Inputs)....................................... 37 FCT 126 Writing to the Process Outputs (Peripheral Outputs) .................................... 37 FCT 130 Reading the Global Diagnostic Bits.. 38 FCT 131 Reading the Bus Status.................... 38 FCT 132 Reading an Illegal Bus Address ....... 39 FCT 133 Reading the Error Number ............... 39 FCT 134 Reading the Status Bits .................... 42 FCT 135 Reading the Diagnostic Bits ............. 42 FCT 136 Reading the Dual Port Memory ........ 43 FCT 137 Writing to the Dual Port Memory ...... 43 FCT 139 Suppressing the Watchdog .............. 44 FCT 140 Restarting the Watchdog .................. 44 FCT 141 Reading the ...................................... 45 FCT 142 Reading the ...................................... 45 FCT 143 Writing to the .................................... 46 FloatToMC5 ..................................................... 27 FN .................................................................... 12 FP .................................................................... 12 Fundamentals .................................................... 3

C
Call Instructions ............................................... 19 CAN-Open ....................................................... 34 CIF Control System Function Block................. 35 CIF Status Request.......................................... 35 CIF System Configuration................................ 47 CIF30 ............................................................... 34 CIF30X ............................................................. 34 CIF30X - Driver ................................................ 34 Coldlink ............................................................ 30 Complete Restart (OB 100) ............................... 6 Configuration.............................................. 33, 47 Control System Function Block........................ 35 Conversion Functions ...................................... 23 Conversion Instructions ................................... 17 Counter ............................................................ 11 Counter Instructions......................................... 15 CPU.................................................................... 5 Current actual cycle time ................................... 7 Cycle .................................................................. 6 Cycle Time ................................................... 6, 48

G
Global Diagnostic Bits ..................................... 38

H
HostFlag .......................................................... 45 Hotlink .............................................................. 30

D
Data Area Allocation ........................................ 20 Data Bit ............................................................ 11 Data Blocks........................................................ 9 Data Transfer and Conversion Functions ........ 23 Data Type Conversion Instructions.................. 17 DDE Manager .................................................. 30 DevFlag............................................................ 45 DeviceNet ........................................................ 34 Diagnostic Bit ................................................... 42 Direct access ..................................................... 2

I
I/O Ports............................................................. 7 Illegal Bus Address .......................................... 39 Indirect Addressing Instructions ...................... 19 Input ................................................................. 11 Installation.................................................... 2, 34 Instance Data Bit ............................................. 11
S7 for Windows SoftPLC

Page 52

SoftPLC

Chapter 12

Instruction Set ..................................................11 Integrated System Function Blocks .................22 Integrated System Functions ...........................21 InterBus ............................................................34

J
Jitter ...................................................................7 Jump Instructions .............................................18

PLC.BIN ............................................................. 3 PLC416 ............................................................ 48 Poke................................................................. 30 Product ID Card ................................................. 2 Profi-Bus .......................................................... 34 Program Display and Null Operation Instructions .................................................. 20

R
Read Data Block .............................................. 26 Read Several Values ....................................... 24 Read Value ...................................................... 23 Reading an Illegal Bus Address....................... 39 Reading the...................................................... 45 Reading the Bus Status ................................... 38 Reading the Diagnostic Bits............................. 42 Reading the Dual Port Memory ....................... 43 Reading the Error Number............................... 39 Reading the Global Diagnostic Bits ................. 38 Reading the Process Inputs (Peripheral Inputs) ....................................... 37 Reading the Status Bits ................................... 42 Request............................................................ 30 Reset................................................................ 12 Response Time.................................................. 3 Restart (OB 101)................................................ 6 Restarting the Watchdog ................................. 44 Retentivity .................................................... 3, 48 Rotation Instructions ........................................ 14 RUN mode ......................................................... 6

L
Load ...................................................................9 Load and Transfer Instructions ........................13 Load at PLC Start...............................................9 Load at Start.......................................................3 Load Memory ...................................................10 Local Data Bit...................................................11 Locked................................................................8 Locking the Software PLC Settings ...................4

M
Master Control Relay (MCR) Instructions ........12 Maximum cycle time...........................................7 MC5ToFloat .....................................................27 Memory Allocation............................................20 Minimum cycle time............................................7 Modify Password................................................8

N
Null Modem Cable............................................49 Null Operation Instructions...............................20

S
S7 Block Call.................................................... 21 S7 for Windows.................................................. 2 Save................................................................... 9 Save at PLC Termination................................... 9 Save at Termination........................................... 3 Save M, T, C at Termination.................... 4, 9, 10 Section [COM].................................................. 33 Section [OEM].................................................. 33 Section [PLC] ................................................... 33 Serial Communication...................................... 10 Serial Number .................................................... 2 Serial Number and Version................................ 7 Set / Reset ....................................................... 12 Setting the Number of the Digital Inputs and Outputs ................................................. 36 SFB .................................................................. 22 SFB210 ............................................................ 35 SFB252 ............................................................ 35 SFB252 Functions ........................................... 36 SFB33 SFB37 ............................................... 32 SFC.................................................................. 21 SFC44.............................................................. 32 SFC46.............................................................. 32 Shift and Rotation Instructions......................... 14 SimPLC.............................................................. 1 Simulation PLC .................................................. 1 SoftPLC.............................................................. 1

O
OB 100 ...............................................................6 OB 101 ...............................................................6 OB40 OB47...................................................32 OB60 ................................................................32 OEM .................................................................34 Online Functions ................................................2 Options ...............................................................8 OR ....................................................................11 Organization Blocks (OBxx) integrated in the Software PLC.....................................21 Output ..............................................................11 Overflow ...........................................................11

P
Password ...........................................................8 Peripheral Access Instructions.........................14 PIN Code............................................................2 PLC Memory ....................................................10 PLC Memory Allocation ...................................20 PLC Program ...............................................5, 28 PLC Program and Data Blocks ..........................9 PLC S7-315........................................................1 PLC S7-416........................................................1 PLC Termination ................................................9
S7 for Windows SoftPLC

Chapter 12

Index

Page 53

SoftPLC Dialog Box ........................................... 5 SoftPLC PLC315................................................ 1 SoftPLC PLC416................................................ 1 Software PLC..................................................... 1 Source Code .................................................... 29 Special Settings ............................................... 47 Status ................................................................. 3 Status Bit.......................................................... 42 Status Request ................................................ 35 StatusFB .......................................................... 34 Stop.................................................................... 6 STOP mode ....................................................... 6 Stored Overflow ............................................... 11 Suppressing the Watchdog.............................. 44 System Configuration....................................... 47 System Data Area Allocation ........................... 20 System Function Blocks............................. 22, 35 System Functions ............................................ 21

ToMC5 ............................................................. 27 Transfer Instructions ........................................ 13

U
Unadvise.......................................................... 30 Uninterruptible Power Supply ............................ 3 Unlocked............................................................ 8

V
Version number ................................................. 7 Visualization..................................................... 28

W
Watchdog......................................................... 44 Word Instructions............................................. 16 Work Memory .................................................. 10 Write Data Block .............................................. 26 Write Several Values ....................................... 25 Write Value ...................................................... 24 Writing to the.................................................... 46 Writing to the Dual Port Memory ..................... 43 Writing to the Process Outputs (Peripheral Outputs) .................................... 37

T
Task Interval ...................................................... 4 Technical Data ................................................. 48 Termination .................................................. 4, 10 Timer ................................................................ 11 Timer Instructions ............................................ 15

S7 for Windows SoftPLC

Page 54

SoftPLC

Chapter 12

S7 for Windows SoftPLC

SoftPLC
The SoftPLC has two different Software PLC configurations.
Compatible with Step 5 programming Compatible with Step 7 programming

a Software PLC
The instruction execution time and the PLC cycle time of course depends on the clock speed of the processor and on the components and features integrated in the PC. The table below is an example of the execution times.
Windows 3.1x / 95 /98 Compatible with Step 5 PLC S5-945

The differences between the versions are listed in the table below
Windows NT 4.x

Compatible with Step 5 Compatible with Step 7

PLC S5-943 PLC S5-945 PLC S7-315 PLC S7-416 PLC S5-943

Load Memory Working Memory Memory (Flags) S- Flags Timer Counter Digital I/O Analog I(O Processing time *) Pentium II 300 **) 2 x Pentium II 300 MHz Double Processor Board

----48 kByte 2 048 32 768 256 256 1024 256

-----

100 kByte adjustable 720 KByte 2 048 32 768 256 256 1024 256

720 kByte 100 kByte adjustable 48 KByte 2 048 32 768 256 256 1024 256 2 048 ----128 64 1024 64 16 348 ----512 512 32 768 2048 2 048 32 768 256 256 1024 256

560 s

560 s

300 s

300 s

560 s

560 s

180 s

180 s

90 s

90 s

560 s

560 s

*) for one (1) instruction **) Time setting: 50% PLC time, 50% Windows time.1 024 mixed instructions (50% Binary, 50% Digital)

Windows, Windows NT, Visual C, Visual Basic, Excel, and Access, are registered trademarks of the Microsoft Corporation. Simatic S5, Step 5, Simatic S7, Step 7, S7-200, S7-300, S7-400, and GRAPH 5 are registered trademarks of Siemens AG, Mnchen and Berlin.

You might also like