Upload
wellington-dias
View
208
Download
2
Embed Size (px)
DESCRIPTION
manual de utilizacao do plc siemens s7
Citation preview
S7 for Windows®
SoftPLC PLC416, PLC315
SimPLC
User's Guide Version 2.x
A PLC INSIDE A PC
S7 for Windows SoftPLC
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 für Automatisierungstechnik mbH Turmstraße 77 D - 64743 Beerfelden / Odw. Germany Telefon 0 60 68 / 30 01 Telefax 0 60 68 / 30 74 Internet: www.IBHsoftec.de E-Mail: [email protected]
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, München and Berlin.
Contents Page I
S7 for Windows SoftPLC
Contents
Contents ................................................................................................ I
1 Introduction................................................................................... 1
2 SoftPLC Installation...................................................................... 2
2.1 The Installation Program...................................................................... 2 2.2 Online Functions .................................................................................. 2
2.2.1 Direct access to the SoftPLC with S7 for Windows ........................................ 2
3 SoftPLC Fundamentals................................................................. 3
3.1 Response Time ..................................................................................... 3 3.2 Retentivity ............................................................................................. 3
Load at Start.................................................................................................... 3 Save at Termination ........................................................................................ 3 Save M, T, C at Termination ........................................................................... 4
3.3 Locking the Settings ............................................................................ 4 3.4 Setting the Task Interval ...................................................................... 4
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
4.1.2 Cycle ............................................................................................................... 6 4.1.3 Cycle Time ...................................................................................................... 6 4.1.4 I/O Ports .......................................................................................................... 7 4.1.5 Jitter................................................................................................................. 7 4.1.6 The SoftPLC Serial Number and Version ....................................................... 7 4.1.7 Options ............................................................................................................ 8
Locked............................................................................................................. 8 Unlocked ......................................................................................................... 8 Modify Password ............................................................................................. 8
4.1.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
4.1.9 Serial Communication ................................................................................... 10 4.1.10 PLC Memory ................................................................................................. 10
Page II SoftPLC
S7 for Windows SoftPLC
4.1.11 Exit PLC.........................................................................................................10
5 SoftPLC Instruction Set ..............................................................11
5.1 Bit Logic Instructions ......................................................................... 11 5.1.1 Other Boolean Logic Instructions ..................................................................12 5.1.2 Set / Reset and Edge Triggered Instructions ................................................12 5.1.3 Master Control Relay (MCR) Instructions .....................................................12
5.2 Load and Transfer Instructions ......................................................... 13 5.3 Peripheral Access Instructions ......................................................... 14 5.4 Accumulator Instructions................................................................... 14 5.5 Shift and Rotation Instructions.......................................................... 14 5.6 Timer Instructions............................................................................... 15 5.7 Counter Instructions........................................................................... 15 5.8 Word Instructions ............................................................................... 16 5.9 Arithmetic Instructions....................................................................... 16 5.10 Data Type Conversion Instructions................................................... 17 5.11 Jump Instructions............................................................................... 18 5.12 Block Call Instructions ....................................................................... 19 5.13 Indirect Addressing Instructions....................................................... 19 5.14 Program Display and Null Operation Instructions ........................... 20 5.15 PLC Memory Allocation...................................................................... 20 5.16 System Data Area Allocation ............................................................. 20 5.17 Organization Blocks (OBxx) integrated ............................................ 21 5.18 Integrated System Functions............................................................. 21 5.19 Integrated System Function Blocks .................................................. 22
6 Direct Access Data Interface ......................................................23
6.1 Data Transfer and Conversion Functions......................................... 23 6.1.1 Read Value....................................................................................................23 6.1.2 Write Value ....................................................................................................24 6.1.3 Read Several Values.....................................................................................24 6.1.4 Write Several Values.....................................................................................25 6.1.5 Read Data Block............................................................................................26 6.1.6 Write Data Block............................................................................................26 6.1.7 FloatToMC5...................................................................................................27 6.1.8 MC5ToFloat...................................................................................................27
6.2 Example ............................................................................................... 28 6.2.1 PLC Program.................................................................................................28 6.2.2 Visualization ..................................................................................................28 6.2.3 Source Code..................................................................................................29
Contents Page III
S7 for Windows SoftPLC
7 DDE Manager .............................................................................. 30
7.1 Example............................................................................................... 31 Reading a Memory Byte................................................................................ 31 Writing into a Memory Byte ........................................................................... 31
8 Functions not Incorporated in the SoftPLC .............................. 32
9 SoftPLC Configuration ............................................................... 33 Section [PLC] ................................................................................................ 33 Section [COM] ............................................................................................... 33 Section [COM2] ............................................................................................. 33 Section [OEM] ............................................................................................... 33
10 CIF30X - Driver ............................................................................ 34
10.1 Installation........................................................................................... 34 10.2 System Function Blocks .................................................................... 35
10.2.1 CIF Status Request ....................................................................................... 35 10.2.2 CIF Control System Function Block .............................................................. 35
10.3 Control SFB252 Functions................................................................. 36 10.3.1 FCT 102 Setting the Number of the Digital Inputs and Outputs ................... 36 10.3.2 FCT 125 Reading the Process Inputs (Peripheral Inputs) ............................ 37 10.3.3 FCT 126 Writing to the Process Outputs (Peripheral Outputs)..................... 37 10.3.4 FCT 130 Reading the Global Diagnostic Bits ............................................... 38 10.3.5 FCT 131 Reading the Bus Status ................................................................. 38 10.3.6 FCT 132 Reading an Illegal Bus Address..................................................... 39 10.3.7 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
10.3.8 FCT 134 Reading the Status Bits.................................................................. 42 10.3.9 FCT 135 Reading the Diagnostic Bits ........................................................... 42 10.3.10 FCT 136 Reading the Dual Port Memory...................................................... 43 10.3.11 FCT 137 Writing to the Dual Port Memory.................................................... 43 10.3.12 FCT 139 Suppressing the Watchdog............................................................ 44 10.3.13 FCT 140 Restarting the Watchdog ............................................................... 44 10.3.14 FCT 141 Reading the "HostFlags"................................................................ 45 10.3.15 FCT 142 Reading the "DevFlags"................................................................. 45 10.3.16 FCT 143 Writing to the "DevFlags" ............................................................... 46
10.4 CIF System Configuration.................................................................. 47 10.5 Special Settings .................................................................................. 47 10.6 Technical Data .................................................................................... 48
11 Appendix ..................................................................................... 49 Null Modem Cable......................................................................................... 49
Page IV SoftPLC
S7 for Windows SoftPLC
12 Index.............................................................................................51
Chapter 1 Introduction Page 1
S7 for Windows SoftPLC
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. CIF-Driver) 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 PLC’s 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 SoftPLC PLC315
Load Memory limited by the PC Memory, adjustable 80kByte, fixed value
Memory Bit Area M0.0 up to M16383.7 M0.0 up to M255.7
Timer T0 up to T511 T0 up to T127
Counter C0 up to C511 C0 up to C63
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.
Page 2 SoftPLC Chapter 2
S7 for Windows SoftPLC
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.
Chapter 3 SoftPLC Fundamentals Page 3
S7 for Windows SoftPLC
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
Page 4 SoftPLC Chapter 3
S7 for Windows SoftPLC
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.
Chapter 4 SoftPLC Dialog Box Page 5
S7 for Windows SoftPLC
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:
Page 6 SoftPLC Chapter 4
S7 for Windows SoftPLC
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.
Chapter 4 SoftPLC Dialog Box Page 7
S7 for Windows SoftPLC
OB 1/LW6: Currently actual cycle time in ms (OB1_PREV_CYCLE)
OB 1/LW8: Maximum cycle time in ms (OB1_MIN_CYCLE)
OB 1/LW10: Minimum cycle time in ms (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 PLC’s.
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.
Page 8 SoftPLC Chapter 4
S7 for Windows SoftPLC
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.
Chapter 4 SoftPLC Dialog Box Page 9
S7 for Windows SoftPLC
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.
Page 10 SoftPLC Chapter 4
S7 for Windows SoftPLC
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.
Chapter 5 SoftPLC Instruction Set Page 11
S7 for Windows SoftPLC
5 SoftPLC Instruction Set
The Software PLC has the complete instruction set of the Simatic® S7-416 CPU.
5.1 Bit Logic Instructions
Instruction Address ID Description
U AND with a scan to "1"
UN AND NOT with a scan to "0"
O OR with a scan to "1"
ON OR NOT with a scan to "0"
X Exclusive OR with a scan to "1"
XN Exclusive OR NOT with a scan to "0"
E Input
A Output
M Bit Memory
L Local Data Bit
T Timer
Z Counter
DBX Data Bit
DIX Instance Data Bit
==0 Result equal to Zero ( = 0) (CC1 = 0 and CC0 = 0)
<>0 Result not equal to Zero ( ≠ 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 1 and CC0 = 0))
>0 Result greater than Zero ( > 0) (CC1 = 0 and CC0 = 0)
>=0 Result greater or equal to Zero ( >= 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 0 and CC0 = 0))
<0 Result less than Zero ( < 0) (CC1 = 0 and CC0 = 0)
<=0 Result less or equal to Zero ( <= 0) ((CC1 = 0 and CC0 = 1) or (CC1 = 0 and CC0 = 0))
UO Unordered Math Instruction (CC1 = 1 and CC0 = 1)
OV Overflow
OS Stored Overflow
BR Binary Result
Page 12 SoftPLC Chapter 5
S7 for Windows SoftPLC
5.1.1 Other Boolean Logic Instructions
Instruction Address ID Description
A( AND left Parenthesis (seven nesting levels possible)
AN( AND NOT left Parenthesis
O( OR left Parenthesis
ON( OR NOT left Parenthesis
X( Exclusive OR left Parenthesis
XN( Exclusive OR NOT left Parenthesis
) Right Parenthesis, removing an entry from the nesting stack
O OR-ing AND Operations (AND before OR)
NOT Negate RLO
SET Set RLO to " 1 "
CLR Set RLO to " 0 "
SAVE Save RLO to the BR Bit
5.1.2 Set / Reset and Edge Triggered Instructions
Instruction Address ID Description
= Assign Value of RLO (Result of Logic Operation)
S Set addressed Bit to " 1 "
R Set addressed Bit to " 0 "e
FP Positive Edge detection
FN Negative Edge detection
E Input
A Output
M Bit Memory
L Local Data bit
DBX Data Bit
DIX Instance Data Bit
5.1.3 Master Control Relay (MCR) Instructions
Instruction Address ID Description
MCRA Activate the MCR
MCRD Deactivate the MCR
MCR( Open the MCR Zone
)MCR Close the MCR Zone
Chapter 5 SoftPLC Instruction Set Page 13
S7 for Windows SoftPLC
5.2 Load and Transfer Instructions
Instruction Address ID Description
L Load into ACCU1
T Transfer Contents of ACCU1 to…
IB Input Byte
IW Input Word
ID Input Double Word
QB Output Byte
QW Output Word
QD Output Double Word
MB Bit Memory Byte
MW Bit Memory Word
MD Bit Memory Double Word
LB Local Data Byte
LW Local Data Word
LD Local Data Double Word
DBB Data Byte
DBW Data Word
DBD Data Double Word
DIB Instance Data Byte
DIW Instance Data Word
DID Instance Data Double Word
STW Status Word
L Const Constant Value
L #Pointer Pointer
L T Timer
LC T Time Value (BCD coded)
L C Counter
LC C Count Value (BCD coded)
L DBNO Data Block Number
L DBLG Data Block Length
L DINO Data Block Number (Instance Data Block)
L DILG Data Block Length (Instance Data Block)
Page 14 SoftPLC Chapter 5
S7 for Windows SoftPLC
5.3 Peripheral Access Instructions
Instruction Address ID Description
L PIB Load Peripheral Input Byte into ACCU1
L PIW Load Peripheral Input Word into ACCU1
L PID Load Peripheral Input Double Word into ACCU1
T PQB Transfer Contents of ACCU1 to Peripheral Output Byte
T PQW Transfer Contents of ACCU1 to Peripheral Output Word
T PQD Transfer Contents of ACCU1 to Peripheral Output Double Word
5.4 Accumulator Instructions
Instruction Address ID Description
PUSH The contents of ACCU1, ACCU2, and ACCU3 are transferred to ACCU2, ACCU3, and ACCU4
POP The contents of ACCU2 and ACCU3 are transferred to ACCU3 and ACCU4
ENT The contents of ACCU2, ACCU3, and ACCU4 are transferred to ACCU2 and ACCU3
LEAVE The contents of ACCU3 and ACCU4 are transferred to ACCU1, ACCU2, and ACCU3
TAK The contents of ACCU1 and ACCU2 are swapped
CAW The Order of the Bytes in ACCU1-L (Byte 0 and 1) is reversed.
CAD The Order of all Bytes in ACCU1 is reversed.
5.5 Shift and Rotation Instructions
Instruction Address ID Description
SLW Shift the contents of ACCU1-L to the left (Word shift)
SLD Shift the contents of ACCU1 to the left (Double Word shift)
SRW Shift the contents of ACCU1-L to the right (Word shift)
SRD Shift the contents of ACCU1 to the right (Double Word shift)
SSI Shift ACCU1-L contents to the right (Word shift – with sign)
SSD Shift ACCU1contents to the right (Double Word shift – with sign)
Chapter 5 SoftPLC Instruction Set Page 15
S7 for Windows SoftPLC
Shift and Rotation Instructions (continued)
Instruction Address ID Description
RLD Rotate the contents of ACCU1 to the left (Double Word)
RLDA Rotate the contents of ACCU1 one bit to the left through CC1
RRDA Rotate the contents of ACCU1 one bit to the right through CC1
RRD Rotate the contents of ACCU1 to the right (Double Word)
constant Number of places to Shift / Rotate
- Number of places to Shift / Rotate located in ACCU2
5.6 Timer Instructions
Instruction Address ID Description
SP T Start Timer as Pulse on Positive Edge (from "0" to "1")
SE T Start Timer as Extended Pulse on Positive Edge
SD T Start Timer as ON Delay on Positive Edge
SS T Start Timer as Retentive ON Delay on Positive Edge
SF T Start Timer as OFF Delay on Negative Edge (from "0" to "1")
R T Reset Timer
FR T Enable Timer for Restarting on Positive Edge (from "0" to "1")
5.7 Counter Instructions
Instruction Address ID Description
CU C Increment Counter by "1" on Positive Edge (from "0" to "1")
CD C Decrement Counter by "1" on Positive Edge (from "0" to "1")
S C Preset Counter on Positive Edge (from "0" to "1")
R C Reset Counter on Positive Edge (from "0" to "1")
FR C Enable Counter for counting on Positive Edge (from "0" to "1")
Page 16 SoftPLC Chapter 5
S7 for Windows SoftPLC
5.8 Word Instructions
Instruction Address ID Description
AW AND contents of ACCU1-L (AND Word)
AD AND contents of ACCU1 (AND Double Word)
OW OR contents of ACCU1-L (OR Word)
OD OR contents of ACCU1 (OR Double Word)
XOW Exclusive OR contents of ACCU1-L (XOR Word)
XOD Exclusive OR contents of ACCU1 (XOR Double Word)
constant With a Word or Double Word constant
- With the contents of ACCU2
5.9 Arithmetic Instructions
Instruction Address ID Description
==I Compare two Integer Values for Equal
<>I Compare two Integer Values for NOT Equal
>I Compare two Integer Values for Greater
>=I Compare two Integer Values for Greater or Equal
<I Compare two Integer Values for Less
<=I Compare two Integer Values for Less or Equal
==D Compare two Double Integer Values for Equal
<>D Compare two Double Integer Values for NOT Equal
>D Compare two Double Integer Values for Greater
>=D Compare two Double Integer Values for Greater or Equal
<D Compare two Double Integer Values for Less
<=D Compare two Double Integer Values for Less or Equal
==R Compare two Real Numbers for Equal
<>R Compare two Real Numbers for NOT Equal
>R Compare two Real Numbers for Greater
>=R Compare two Real Numbers for Greater or Equal
<R Compare two Real Numbers for Less
<=R Compare two Real Numbers for Less or Equal
SIN Calculate the Sine of a Real Number
COS Calculate the Cosine of a Real Number
TAN Calculate the Tangent of a Real Number
Chapter 5 SoftPLC Instruction Set Page 17
S7 for Windows SoftPLC
Arithmetic Instructions (continued)
Instruction Address ID Description
ASIN Calculate the Arcsine of a Real Number
ACOS Calculate the Arccosine of a Real Number
ATAN Calculate the Arctangent of a Real Number
SQR Calculate the Square of a Real Number
SQRT Calculate the Square Root of a Real Number
EXP Calculate the Exponential Value of a Real Number (Base "e")
LN Calculate the Natural Logarithm of a Real Number
+I Add two Integer Values
-I Subtract one Integer Value from another
*I Multiply one Integer Value with another
/I Divide one Integer Value by another
+D Add two Double Integer Values
-D Subtract one Double Integer Value from another
*D Multiply one Double Integer Value with another
/D Divide one Double Integer Value by another
+R Add two Real Numbers
-R Subtract one Real Number from another
*R Multiply one Real Number with another
/R Divide one Real Number by another
MOD Divide one Double Integer Value by another (with Remainder)
+ constant Add a Constant
+P# constant Add a Pointer
DEC Decrement ACCU1-LL (one Byte)
INC Increment ACCU1-LL (one Byte)
5.10 Data Type Conversion Instructions
Instruction Address ID Description
ITD Convert from Integer to Double Integer
ITB Convert from Integer to BCD
DTB Convert from Double Integer to BCD
DTR Convert from Double Integer to Real Number
BTI Convert from BCD to Integer
BTD Convert from BCD to Double Integer
RND Convert a Real Number to a Double Integer Value
Page 18 SoftPLC Chapter 5
S7 for Windows SoftPLC
Data Type Conversion Instructions (continued)
Instruction Address ID Description
RND+ Convert a Real Number to a Double Integer Value (rounded UP to the next whole number)
RND- Convert a Real Number to a Double Integer Value (rounded DOWN to the next whole number)
TRUNC Convert a Real Number to a Double Integer Value (the places after the decimal point are truncated)
INVI Form the Ones Complement of ACCU1-L (Integer)
INVD Form the Ones Complement of ACCU1-L (Double Integer)
NEGI Form the Twos Complement of ACCU1-L (Integer)
NEGD Form the Twos Complement of ACCU1-L (Double Integer)
NEOR Negate the Real Number in ACCU1
ABS Form the Absolute Value of the Real Number in ACCU1
5.11 Jump Instructions
Instruction Address ID Description
JU Label Jump unconditional
JC Label Jump if RLO = “1”
JCB Label Jump if RLO = “1”, save the RLO in the BR Bit
JCN Label Jump if RLO = “0”
JNB Label Jump if RLO = “0”, save the RLO in the BR Bit
JBI Label Jump if BR = “1”
JNBI Label Jump if BR = “0”
JZ Label Jump if Result equal to Zero ( = 0) (CC1 = 0 and CC0 = 0)
JN Label Jump if Result not equal to Zero ( ≠ 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 1 and CC0 = 0))
JP Label Jump if Result greater than Zero ( > 0) (CC1 = 0 and CC0 = 0)
JPZ Label Jump if Result greater or equal to Zero ( >= 0) ((CC1 = 1 and CC0 = 0) or (CC1 = 0 and CC0 = 0))
JM Label Jump if Result less than Zero ( < 0) (CC1 = 0 and CC0 = 0)
JMZ Label Jump if Result less or equal to Zero ( <= 0) ((CC1 = 0 and CC0 = 1) or (CC1 = 0 and CC0 = 0))
JUO Label Jump if “Unordered Math Instruction” (CC1 = 1 and CC0 = 1)
JO Label Jump on Overflow (OV = “1”)
JOS Label Jump on Stored Overflow (OS = “1”)
JL Label Jump distributor
LOOP Label Loop programming (decrement ACCU1-L and jump if ≠ 0)
Chapter 5 SoftPLC Instruction Set Page 19
S7 for Windows SoftPLC
5.12 Block Call Instructions
Instruction Address ID Description
CALL FB Unconditional Call of an FB with Parameter Transfer
CALL FC Unconditional Call of an FC with Parameter Transfer
CALL SFB Unconditional Call of an SFB with Parameter Transfer
CALL SFC Unconditional Call of an SFC with Parameter Transfer
UC FB Unconditional Call of a Function Block (without Parameter)
CC FB Conditional Call of a Function Block (without Parameter)
UC FC Unconditional Call of a Function (without Parameter)
CC FC Conditional Call of a Function (without Parameter)
BEU End Block Unconditionally
BEC End Block Conditionally if RLO = "1"
BE End Block
OPN
DB Open Data Block
DI Open Instance Data Block
TDB Exchange Data Block Registers
5.13 Indirect Addressing Instructions
Instruction Address ID Description
LAR1 Load Address Register 1 (AR1)
LAR2 Load Address Register 2 (AR2)
MD LD DBD DID
with Bit Memory Double Word with Local Data Double Word with Data Block Double Word with Instance Data Block Double Word
LAR1 - Load Address Register 1 (AR1) with Contents of ACCU1
LAR2 - Load Address Register 2 (AR2) with Contents of ACCU1
LAR1 AR2 Load Address Register 1 (AR1) with Contents of Address Register 2 (AR2)
LAR1 P# Load Address Register 1 (AR1) with Pointer
LAR2 P# Load Address Register 2 (AR2) with Pointer
Page 20 SoftPLC Chapter 5
S7 for Windows SoftPLC
Indirect Addressing Instructions (continued)
Instruction Address ID Description TAR1 Transfer Contents of Address Register 1 (AR1) in… TAR2 Transfer Contents of Address Register 2 (AR2) in…
MD LD DBD DID
Bit Memory Double Word Local Data Double Word Data Block Double Word Instance Data Block Double Word
TAR1 - Transfer Contents from Address Register 1 (AR1) in ACCU1
TAR2 - Transfer Contents from Address Register 2 (AR2) in ACCU1
TAR1 AR2 Transfer Contents from Address Register 1 (AR1) in Address Register 2 (AR2)
TAR P# Swap Contents of Address Register 1 (AR1) with Contents of Address Register 2 (AR2)
+AR1 Add Contents from ACCU1 to Address Register 1 (AR1) +AR2 Add Contents from ACCU1 to Address Register 2 (AR2)
+AR1 P# Add Pointer to Address Register 1 (AR1)
+AR2 P# Add Pointer to Address Register 2 (AR2)
5.14 Program Display and Null Operation Instructions
Instruction Address ID Description
NOP 0 Null Operation Instruction
NOP 1 Null Operation Instruction
BLD constant 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.
Chapter 5 SoftPLC Instruction Set Page 21
S7 for Windows SoftPLC
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 Description
OB1 Free Cycle (Main Program)
OB10 – OB17 Time of Day Interrupts
OB20 – OB23 Time Delay Interrupts
OB30 – OB38 Timed Interrupts (cyclic calls)
OB80 – OB87 Asynchronous Error Interrupts
OB90 Background Execution
OB100/OB101 Complete Restart / Warm Restart
OB121/OB122 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. SFC Name Function
SFC0 SET_CLK Set clock
SFC1 READ_CLK Read clock
SFC20 BLKMOV Copy variable (n = number of bytes to be copied)
Page 22 SoftPLC Chapter 5
S7 for Windows SoftPLC
Integrated System Functions (SFC) (continued)
SFC No. SFC Name Function
SFC21 FILL Set array default variables
SFC22 CREAT_DB Create Data Block
SFC23 DEL_DB Delete Data Block
SFC24 TEST_DB Test Data Block
SFC25 COMPRESS Compress Memory (user memory)
SFC28 SET_TINT Set Time-of-Day interrupt
SFC29 CAN_TINT Cancel Time-of-Day interrupt
SFC30 ACT_TINT Activate Time-of-Day interrupt
SFC31 QRY_TINT Query Time-of-Day interrupt
SFC32 SRT_DINT Start Time-Delay interrupt
SFC33 CAN_DINT Cancel Time-Delay interrupt
SFC34 QRY_DINT Query Time-Delay interrupt
SFC39 DIS_IRT Discard new events
SFC40 EN_IRT Stop discarding events
SFC41 DIS_AIRT Delay interrupt events
SFC42 EN_AIRT Stop delaying interrupt events
SFC43 RE_TRIGR Retrigger watchdog monitoring
SFC51 RDSYST "Module ID" partial list
SFC64 TIME_TCK 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. SFB Name Function
SFB0 CTU Count up
SFB1 CTD Count down
SFB2 CTUD Count up and down
SFB3 TP Generate pulse
SFB4 TON Generate On-Delay
SFB5 TOF Generate Off-Delay
SFB32 DRUM Implement sequencer
Chapter 6 Direct Access Data Interface Page 23
S7 for Windows SoftPLC
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);
Parameter Description Comment
typ PLC Operand
'E' 'A' 'M' 'Z' 'T' 'D'
Input Output Memory Bit (Flag) Counter Value Timer Value Data Word or Data Double Word
'I' 'Q' 'M' 'C' 'T' 'D'
16 Bit access only 16 Bit access only (Number of Bits depends on Parameter size )
nr Address Byte address of the Operand to transfer
DBNr Data Block Number 1 - 4095
size Number of Bits
0..7 = Bit No. 0 7 only 'E', 'A', 'M'
8 = 1 Byte
16 = 1 Word
32 = 1 Double Word
ok 0: Error Error message
Page 24 SoftPLC Chapter 6
S7 for Windows SoftPLC
6.1.2 Write Value
The "Write Value" function transfers the assigned data from your application to the Software PLC.
void DLLexport wrVal (unsigned char far* typ, unsigned long nr, int DBNr, unsigned size, unsigned long val, int far* ok);
Parameter Description Comment
typ PLC Operand
'E' 'A' 'M' 'Z' 'T' 'D'
Input Output Memory Bit (Flag) Counter Value Timer Value Data Word or Data Double Word
'I' 'Q' 'M' 'C' 'T' 'D'
16 Bit access only 16 Bit access only (Number of Bits depends on Parameter size )
nr Address Byte address of the Operand to transfer
DBNr Data Block Number 1 - 4095
size Number of Bits
0..7 = Bit No. 0 7 only 'E', 'A', 'M'
8 = 1 Byte
16 = 1 Word
32 = 1 Double Word
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 char far* typ,
unsigned long nr, int DBNr, unsigned size, unsigned char far* vals, int far* ok);
Parameter Description Comment
typ PLC Operand
'E' 'A' 'M' 'D'
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
Chapter 6 Direct Access Data Interface Page 25
S7 for Windows SoftPLC
Read several values (continued)
Parameter Description Comment
nr Address
DBNr Data Block Number 1 - 4095
size Number of Bytes or Words
Vals Byte Values
ok 0: Error 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 char far* typ,
unsigned long nr, int DBNr, unsigned size, unsigned char far* vals, int far* ok);
Parameter Description Comment
typ PLC Operand
'E' 'A' 'M' 'D'
Input Output Memory Bit (Flag) Data Word
'I' 'Q' 'M' 'D'
nr Address
DBNr Data Block Number 1 - 4095
size Number of Bytes or Words
PLC Operand
'E' 'A' 'M' 'D'
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
Vals Byte Values Attention! Field size must be set to hold all requested bytes.
ok 0: Error Error message
Page 26 SoftPLC Chapter 6
S7 for Windows SoftPLC
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 short int nr,
unsigned short int* Baustein, unsigned int* Anzahl, unsigned char Synchron, int far* ok);
Parameter Description Comment
nr Data Block Number 1 - 4095
Baustein Pointer to the Data Block contents Baustein " "Block"
Anzahl Number of words to be read from the Data Block
Anzahl " "Number" If the Data Block has less words than requested, the "Number (Anzahl)" is automatically adjusted.
Synchron No Function Synchron " "synchronous" The parameter is inserted for compatibility reasons.
ok 0: Error Error message
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 short int nr,
unsigned short int* Baustein, unsigned int* Anzahl, unsigned char Synchron, int far* ok);
Parameter Description Comment
nr Data Block Number 1 - 4095
Baustein Pointer to the new Data Block Baustein " "Block" The Buffer from which the DB will be copied from.
Anzahl Number of words to be written into the Data Block
Anzahl " "Number" If the Data Block has less words than requested, the "Number (Anzahl)" is automatically adjusted.
Chapter 6 Direct Access Data Interface Page 27
S7 for Windows SoftPLC
Write Data Block (continued)
Parameter Description Comment
Synchron No Function Synchron " "synchronous" The parameter is inserted for compatibility reasons.
ok 0: Error Error message
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 Description
FloatVal Floating-point value in the IEEE format or INTEL format respectively
MC5Val 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 Description
MC5Val Floating-point value in the Siemens S7 format
FloatVal Floating-point value in the IEEE format or INTEL format respectively
Page 28 SoftPLC Chapter 6
S7 for Windows SoftPLC
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): MB10 Value Tank Level = Pump Rotation Angle: QW12 Value Pump Rotation Text: DB4095 String
Chapter 6 Direct Access Data Interface Page 29
S7 for Windows SoftPLC
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); // Write to Memory(Byte) } 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'; // Modify Output Value val = rdVal (&typ,12,0,16,&ok); // Read QW12 AW12->Text = val; Pie1->Angles->StartAngle = val; Pie1->Angles->EndAngle = val + 10; ProgressBar->Position = val; typ = 'M'; // Modify Memory (Byte) val = rdVal (&typ,10,0,8,&ok); // Read MB10 MB10->Text = val; // Display Value if (rdVal (&typ,6,0,0,&ok)) // Read Memory Bit M6.0 m6pkt0->Text = "true"; // Display Value in dialog box else m6pkt0->Text = "false"; // Display Value in dialog box typ = 'T'; // Modify Timer val = rdVal (&typ,99,0,16,&ok); // Read Value of Timer T99 val &= 0x07ff; // Mask Control Bits T99->Text = val; // Display Value in dialog box 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
Page 30 SoftPLC Chapter 7
S7 for Windows SoftPLC
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 Name Format Range Example
Input Bit (In.m) En.m n: 0..511, m: 0..7 E10.1
Input Byte (IBn) Ebn n: 0..511 EB10
Input Word (IWn) Ewn n: 0..510 EW10
Output Bit (Qn.m) An.m n: 0..511, m: 0..7 A12.1
Output Byte (QBn) Abn n: 0..511 AB12
Output Word (QWn) Awn n: 0..510 AW12
Memory Bit (Mn.m) Mn.m n: 0..4095, m: 0..7 M14.1
Memory Byte (MBn) Mbn n: 0..4095 MB14
Memory Word (MWn) Mwn n: 0..4094 MW14
Data Byte (DBn,dbm) DBn,dbm n: 0..1023, dbm: 0..4095 DB9,16 (DB9 of DB16) DBn – Data Byte number dbm – Data Block number
Data Word (DWn,dbm) DWn,dbm n: 0..1022, dbm: 0..4095 DW3,16 (DW3 of DB16) DWn – Data Word number dbm – Data Block number
Timer (Tn Tn n: 0..511 T20
Counter (Cn) Zn n: 0..511 Z3
Chapter 7 DDE Manager Page 31
S7 for Windows SoftPLC
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 DDE Manager Server Name PLCS7 DDE Manager Topic Name MB10 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
Page 32 SoftPLC Chapter 8
S7 for Windows SoftPLC
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 Multi-Computing Interrupts
• OB40 – OB47 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 Transfer substitute value to ACCU1
• SFC46 Force CPU into STOP mode
• SFB33 – SFB37 Generate block-related messages
Chapter 9 SoftPLC Configuration Page 33
S7 for Windows SoftPLC
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 Area Default Value Description
S7_STORE 50000..... End of PC Memory
500000 Size of "Load Memory" (SoftPLC 416) The "Load Memory" of the SoftPLC 315 is fixed
REM 0 / 1 0 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).
Section [COM] In the section [COM] the parameter of the serial port COM1 are set.
Key Name Area Default Value Description
BAUD 2400 .. 115000 38400 Baud rate of the serial port
INT PC depending 3 / 4 Interrupt number of the serial port
PORT PC depending 2F8 / 3F8 Port address of the serial port
Section [COM2] In the section [COM2] the parameter of the serial port COM2 are set.
Key Name Area Default Value Description
BAUD 2400 .. 115000 38400 Baud rate of the serial port
INT PC depending 3 / 4 Interrupt number of the serial port
PORT PC depending 2F8 / 3F8 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 Area Default Value Description
DLLn File_Name.DLL --- User DLL (e.g. CIF driver – CIF30X.DLL
Page 34 SoftPLC Chapter 10
S7 for Windows SoftPLC
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: (Jumper Field J7) Default = CA00:0000
No IRQ: (Jumper at J5) The Software PLC doesn’t 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 ;Dual port address of the CIF30 board
StatusFB=252 ;Number of the Status SFB
ControlOB=210 ;Number of the Control SFB
DP_Size=1 ;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 ;CIF30 board number (n=0 up to n=3)
StatusFB=252 ;Number of the Status SFB
ControlOB=210 ;Number of the Control SFB
DP_Size=1 ;CIF board with additional dual port memory (1=8KB, 2=16KB)
Chapter 10 CIF30X - Driver Page 35
S7 for Windows SoftPLC
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 Control System Function Block
SFB252 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 Area Type Function
RDY OUT BOOL CIF board ready
RUN OUT BOOL 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 //RDY OUT1: = M10.1 //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 DB <Control Data Block> // Not required with all functions L <Parameter> // ACCU2, not required with all functions L <Function Number> // ACCU1, see the following chapters for explanations UC SFB 210 // 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.
Page 36 SoftPLC Chapter 10
S7 for Windows SoftPLC
10.3 Control SFB252 Functions
The following functions are implemented in the SFB252
FCT No.: Function
102 Setting the Number of the Digital Inputs and Outputs
125 Reading the Process Inputs (Peripheral Inputs)
126 Writing to the Process Outputs (Peripheral Outputs)
130 Reading the Global Diagnostic Bits
131 Reading the Bus Status
132 Reading an Illegal Bus Address
133 Reading the Error Number
134 Reading the Status-Bits
135 Reading the Diagnostic Bits
136 Reading the Dual Port Memory
137 Writing to the Dual Port Memory
139 Suppressing the Watchdog
140 Restarting the Watchdog
141 Reading the "HostFlags"
142 Reading the "DevFlags"
143 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 50 // 50 I/O Bytes are required
L 102 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 102)
Returned Values
ACCU1 Irrelevant
ACCU2 = 0 = no error Error Code: 1 = to many digital I / O bytes
RLO = 1 = no error = 0 = error (error code in ACCU2)
Chapter 10 CIF30X - Driver Page 37
S7 for Windows SoftPLC
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 // The DB70 will receive the data from the Peripheral Inputs
L W#16#0100 // Starting address of the Process Inputs (Peripheral Inputs) (100hex)
L 125 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 125)
Returned Values
ACCU1 = 0 = no error (ACCU2 must also be "0")
ACCU2 = 0 = no error Error Code 1 = Data Block non existing 2 = Data Block size not equal Peripheral Input area
RLO = 1 = no error = 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 // The data from the DB70 is written into the Peripheral Output area
L W#16#0100 // Starting address of the Process Outputs (Peripheral Outputs) (100hex)
L 126 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 126)
Returned Values
ACCU1 = 0 = no error (ACCU2 must also be "0")
ACCU2 = 0 = no error Error Code 1 = Data Block non existing 2 = Data Block size not equal Peripheral Output area
RLO = 1 = no error = 0= error (error code in ACCU2)
Page 38 SoftPLC Chapter 10
S7 for Windows SoftPLC
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 Profi-Bus Error Message
0 Invalid Parameter
1 Branched into the Auto_Clear_Mode due to Module Bus failure
2 At least one Slave is not in the Data Transfer Mode or indicates a serious failure
3 Serious Bus Failure, no further data transfer possible
4 Short circuit on the Bus
5 Host not ready
6 reserved
7 reserved
Global Diagnostic Bits of the CIF30/5060 InterBus board:
Bit InterBus Error Message
0 Invalid Parameter
1 System failure occurred
2 At least one Slave indicates Module failure
3 At least one W1 Interface failure
4 At least one W2 Interface failure
5 reserved
6 reserved
7 reserved
Example:
L 130 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 130)
T MB 0 // 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 Profi-Bus Error Message
0 Bus segment not turned off
1 to 7 reserved
Chapter 10 CIF30X - Driver Page 39
S7 for Windows SoftPLC
Example:
L 131 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 131)
T MB 2 // 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 132 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 132)
T MB 4 // 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 133 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 133)
T MB 5 // Transferring the Error Number into Memory Byte MB5
Returned Values
ACCU1 = Error Number
InterBus Error Numbers
Error No.: Description Error Source Possible Cure
0 no mistakes appear
50 IBS task not found device technical support
51 no global data-field device technical support
53 PLC task not found device technical support
54 Non-existing master parameters device execute download of data base again
55 error in reading the master parameters project planning execute download of data base again
Page 40 SoftPLC Chapter 10
S7 for Windows SoftPLC
InterBus Error Numbers (continued)
Error No.: Description Error Source Possible Cure
56 Non-existing project parameters project planning execute download of data base again
57 network data base includes no parameters
project planning execute download of data base again
59 The projected send process data offset address of a participant, is outside the allowable border of 0- 255
project planning check projected addresses
60 The projected receive process data offset address of a participant, is outside the allowable border of 0- 255
project planning check projected addresses
61 Data-area of slaves are overlapping in the send process data
project planning
63 no segment in the init phase device technical support
64 no program code for the external processor
device execute download of the SCA *.img firmware
65 hardware or software error in the external processor
external field bus processor
technical support
66 no project information database execute download of data base again
67 illegal installation depth of a slave module project planning check installation depths of the configured slaves
69 illegal length code project planning check configuration in special slave length codes
213 structure surrender to operating system faulty
device contact Hilscher company
101 the network configuration differs from configured configuration
bus compare the ID and length codes of the slaves with the master configuration
102 the configuration exceeds the maximum allowed configuration
bus reduce the connected modules
103 the configuration has changed during running state
bus check the bus segments and voltage break-ins
104 multiple data cycle error bus start the diagnostic function
105 time out bus check the bus segments and start the diagnostic function
106 network error could not be localized bus run the bus segments separately with the system configurator
108 no connection to a network bus check the cable connection between DEVICE and first slave module
220 the user program stops to handle the dual-port watchdog location in time
user program increment the supervision time or check the user program if running
221 user program does not acknowledge the process data indication in time (mode 0)
user program
Chapter 10 CIF30X - Driver Page 41
S7 for Windows SoftPLC
InterBus Error Numbers (continued)
Error No.: Description Error Source Possible Cure
222 the configured network is different than the connected network
bus and data base
compare bus configuration list with ID and length codes of the slaves
223 different count of modules was detected during identification cycles
bus technical support
224 error in external processor communication
device technical support
Profi Bus Error Numbers Error No.: Description Error Source Possible Cure 0 no mistakes appear
50 USR_INTF-Task not found device contact technical support
51 no global data-field device contact technical support
52 FDL-Task not found device contact technical support
53 PLC-Task not found device contact technical support
54 non existing master parameters device execute download of data base again
55 faulty parameter-value in the master parameters
project planning contact technical support
56 non existing slave parameters project planning execute download of data base again
57 faulty parameter-value in a slave parameters data file
project planning contact technical support
58 double slave address project planning check projected addresses
59 projected send process data offset address of a participant outside the allowable border of 0- 255
project planning check projected addresses
60 projected receive process data offset address, of a participant, is outside the allowable border of 0- 255
project planning check projected addresses
61 Data-areas of slaves are overlapping in the send process data
project planning check projected addresses
62 Data-areas of slaves are overlapping in the receive process data
project planning check projected addresses
63 unknown process data handshake warm start check warm start parameters
64 free RAM exceeded device contact technical support
65 faulty slave parameter data sets project planning contact technical support
202 no segment for the treatment free device contact technical support
212 faulty reading of a data base device execute download of data base again
213 structure-surrender to operating system faulty
device contact technical support
2 station reports overflow master telegram check length of configured slave configuration or parameter data.
Page 42 SoftPLC Chapter 10
S7 for Windows SoftPLC
Profi Bus Error Numbers (continued)
Error No.: Description Error Source Possible Cure 3 request function of master is not activated
in the station master telegram check slave if PROFIBUS-
DP norm compatible
9 no answer-data, although the slave must respond with data
slave check configuration data of the station and compare it with the physical I/O data length
17 no response of the station slave check bus cable, check bus address of slave
18 master not into the logical token ring device check FDL-Address of master or highest-station-Address of other master systems. examine bus cabling to bus short circuits.
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 Lower-Byte of ACCU1. The value of a single Status bit indicates if the Slave is active or inactive.
Example:
L W#16#03 // Byte number 3 selected (03 hex)
L 134 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 134)
T MB 6 // 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 W#16#03 // Byte number 3 selected (03 hex)
L 135 // Load Function Number into ACCU1
Chapter 10 CIF30X - Driver Page 43
S7 for Windows SoftPLC
UC SFB 210 // Calling the function (FCT 135)
T MB 7 // 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 // The DB60 will receive the contents of the Dual Port Memory
L W#16#0100 000A // 10 Bytes starting at the relative address 100hex
L 136 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 136)
Returned Values
ACCU1 = 0 = no error (ACCU2 must also be "0")
ACCU2 = 0 = no error Error Code 1 = Data Block non existing 2 = Number of requested Bytes exceeds the Dual Port Memory limit 3 = Number of requested Bytes exceeds the Data Block limit (not enough bytes in DB)
RLO = 1 = no error = 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.
Page 44 SoftPLC Chapter 10
S7 for Windows SoftPLC
Example:
OPN DB60 // The DB60 will receive the contents of the Dual Port Memory
L W#16#0100 000A // 10 Bytes starting at the relative address 100hex
L 137 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 137)
Returned Values
ACCU1 = 0 = no error (ACCU2 must also be "0")
ACCU2 = 0 = no error Error Code 1 = Data Block non existing 2 = 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 139 // Load Function Number into ACCU1
UC SFB 210 // 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 140 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 140)
Returned Values
RLO = 1 = no error = 0= function not executed
Chapter 10 CIF30X - Driver Page 45
S7 for Windows SoftPLC
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 HostFlag Messages
0 HostCom: HostMailBox command bit
1 DevAck: DevMailBox acknowledge bit
2 PdAck: Host I/O data synchronization acknowledge bit
3 reserved
4 reserved
5 Com: User data transfer phase from at least one module active
6 Run: Parameter data valid, CIF ready for communication
7 Ready: Module ready, no basic initialization error present
Example:
L 141 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 141)
T MB 8 // 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 DevFlag Messages
0 HostAck: HostMailBox acknowledge bit
1 DevCom: DevMailBox command bit
2 PdCom: Dev I/O data synchronization command bit
3 reserved
4 reserved
5 NotReady: Terminate bus transfer or deactivate module. At least one module is in the reset mode
6 Init: Reset the CIF and transfer the parameters from the DPM
7 Reset: Reset the CIF
Example:
L 142 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 141)
Page 46 SoftPLC Chapter 10
S7 for Windows SoftPLC
T 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 DevFlag Messages
0 HostAck: HostMailBox acknowledge bit
1 DevCom: DevMailBox command bit
2 PdCom: Dev I/O data synchronization command bit
3 reserved
4 reserved
5 NotReady: Terminate bus transfer or deactivate module. At least one module is in the reset mode
6 Init: Reset the CIF and transfer the parameters from the DPM
7 Reset: Reset the CIF
Example:
L W#16#40 // DevFlag 7 (Reset the CIF and transfer the parameters from the DPM)
L 143 // Load Function Number into ACCU1
UC SFB 210 // Calling the function (FCT 143)
Returned Values
RLO = 1 = no error = 0= function not executed
Chapter 10 CIF30X - Driver Page 47
S7 for Windows SoftPLC
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 0…511.
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 ; Start address of the digital Inputs and Outputs (PEB0 … 511)
BitEnd = 127 ; End address of the digital Inputs and Outputs (PEB0 … 511)
BitIn = 0 ; Start address of the digital Inputs and Outputs (PEB0 … 511) in the Dual Port Memory of the CIF board
BitOut = 0 ; Start address of the digital Inputs and Outputs (PEB0 … 511) in the Dual Port Memory of the CIF board
DP_Size = 1 ; CIF board with extended Dual Port Memory (1 = 8Kbyte; 2 = 16Kbyte)
Page 48 SoftPLC Chapter 10
S7 for Windows SoftPLC
10.6 Technical Data
SoftPLC PLC416 Load Memory Size Limited by the amount of RAM installed in the PC Serial Ports COM1.. COM4, adjustable with the initialization file PLC43.INI Baud Rate 9600 – 115000 Baud Operands Area Inputs (I) 0.0 … 511.7
Outputs (Q) 0.0 … 511.7 Memory (M) 0.0 … 16.383.7 Timer (T) 0 ... 511 Counter (C) 0 ... 511
Data Blocks 0 ... 4095 Data Block Size 65.534 Bytes SFC: Integrated, see chapter 5.18 of this manual t SFB: Integrated, see chapter 5.19 of this manual Retentivity Adjustable M, T, C via the initialization file PLC43.INI Cycle Time 1ms – 150ms (up to 2000ms adjustable)
DDE Access to all operands via PLC32.DLL Network Connections TCP/IP via INAT driver OEM Drivers 10, (DLL0 – DLL9, initialization file PLC43.INI) Task 20 – 80%, initialization file PLC43.INI Dual Processor Board Yes Key Board Access Yes
SoftPLC PLC315 Load Memory Size 80kByte, fixed value Serial Ports COM1.. COM4, adjustable with the initialization file PLC43.INI Baud Rate 9600 – 115000 Baud Operands Area Inputs (I) 0.0 … 511.7
Outputs (Q) 0.0 … 511.7 Memory (M) 0.0 … 255.7 Timer (T) 0 ... 127 Counter (C) 0 ... 63
Data Blocks 0 ... 4095 Data Block Size 65.534 Bytes SFC: Integrated, see chapter 5.18 of this manual SFB: Integrated, see chapter 5.19 of this manual Retentivity Adjustable M, T, C via the initialization file PLC43.INI Cycle Time 1ms – 150ms (up to 2000ms adjustable)
DDE Access to all operands via PLC32.DLL Network Connections TCP/IP via INAT driver OEM Drivers 10, (DLL0 – DLL9, initialization file PLC43.INI) Task 20 – 80%, initialization file PLC43.INI Dual Processor Board Yes Key Board Access Yes
Chapter 11 Appendix Page 49
S7 for Windows SoftPLC
11 Appendix
Null Modem Cable
Sub.-D Connector Sub.-D Connector Female Female
9 Pin 25 Pin 9 Pin 25 Pin
1 ------ Not Connected 1 ------
2 3 ------------------------------- 3 2
3 2 ------------------------------- 2 3
4 20 ------------------------------- 6 6
5 7 ------------------------------- 5 7
6 6 ------------------------------- 4 20
7 4 ------------------------------- 8 5
8 5 ------------------------------- 7 4
9 ------ ---- Not Connected ---- 9 ------
Shell Shell ---------- Shield -------- Shell Shell
Page 50 SoftPLC Chapter 11
S7 for Windows SoftPLC
Chapter 12 Index Page 51
S7 for Windows SoftPLC
12 Index
A Access Data Interface......................................23 Accumulator Instructions..................................14 Addressing Instructions....................................19 Advise ..............................................................30 AND..................................................................11 Arithmetic Instructions......................................16
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
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
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
Direct Access Data Interface ........................... 23 Dual Port Memory............................................ 43 Dual Processor Board ..................................... 48 Dynamic Data Exchange (DDE) ...................... 30
E Edge Triggered Instructions ............................ 12 Error Number ................................................... 39 Example..................................................... 28, 31 Exclusive OR ................................................... 11 Exit PLC........................................................... 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
G Global Diagnostic Bits ..................................... 38
H HostFlag .......................................................... 45 Hotlink.............................................................. 30
I I/O Ports............................................................. 7 Illegal Bus Address.......................................... 39 Indirect Addressing Instructions ...................... 19 Input ................................................................. 11 Installation.................................................... 2, 34 Instance Data Bit ............................................. 11
Page 52 SoftPLC Chapter 12
S7 for Windows SoftPLC
Instruction Set ..................................................11 Integrated System Function Blocks .................22 Integrated System Functions ...........................21 InterBus............................................................34
J Jitter ...................................................................7 Jump Instructions .............................................18
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
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
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
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
Chapter 12 Index Page 53
S7 for Windows SoftPLC
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
T Task Interval ......................................................4 Technical Data .................................................48 Termination ..................................................4, 10 Timer................................................................11 Timer Instructions ............................................15
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
Page 54 SoftPLC Chapter 12
S7 for Windows SoftPLC
SoftPLC a Software PLC The SoftPLC has two different Software PLC configurations.
• Compatible with Step® 5 programming • Compatible with Step® 7 programming
The differences between the versions are listed in the table below
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 NT 4.x Windows 3.1x / 95 /98
Compatible with Step® 5 Compatible with Step® 7 Compatible with Step® 5
PLC S5-943 PLC S5-945 PLC S7-315 PLC S7-416 PLC S5-943 PLC S5-945
Load Memory ----- ----- 100 kByte adjustable
Working Memory 48 kByte 720 kByte 100 kByte adjustable 48 KByte 720 KByte
Memory (Flags) 2 048 2 048 2 048 16 348 2 048 2 048
S- Flags 32 768 32 768 ----- ----- 32 768 32 768
Timer 256 256 128 512 256 256
Counter 256 256 64 512 256 256
Digital I/O 1024 1024 1024 32 768 1024 1024
Analog I(O 256 256 64 2048 256 256
Processing time *)
Pentium II 300 **) 560 µs 560 µs 300 µs 300 µs 560 µs 560 µs
2 x Pentium II 300 MHz Double Processor Board
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, München and Berlin.