Compile and run-time errors are non-fatal errors. Non-fatal errors can degrade some aspect of the
performance of your PLC, but do not render the PLC incapable of executing the user program or updating the I/O.
Run-time errors are non-fatal errors detected in RUN mode, and reflected in special memory (SM) bits that your program can monitor and evaluate. At startup, the PLC reads the I/O configuration and stores this information in the SM memory. During normal operation, the I/O status is periodically updated and stored in the SM memory. If the PLC detects a difference in the I/O configuration, it sets the configuration-changed bit of the module-error byte; the I/O module will not be updated until this bit is reset. For the PLC to reset this bit, the module I/O must once again match the I/O configuration stored in the system data memory.
Run-time programming errors are non-fatal error conditions created by you or your program while the program is being executed. An example of this is an indirect-address pointer, which was valid when the program compiled, modified by program execution to point to an out-of-range address. Use the PLC > Information… command to determine what type of error has occurred.
You can correct run-time programming errors only by modifying the user program. The run-time programming errors are cleared at the next transition from STOP to RUN mode.
Compile errors (or program-compile errors) are detected at download as the PLC compiles the program. If there is a compile error, the compile halts, and the previous program (which is known to be valid since it previously compiled) is retrieved. All of these steps occur while the PLC is in STOP mode. Compile errors can be displayed using the PLC > Information… command.
To enable Write and Force functions while in STOP mode, choose the Debug > Write-Force
Outputs in STOP menu command.
The S7-200 PLCs support writing and forcing outputs (both analog and digital) while the PLC is in STOP mode. As a safety precaution, you must specifically request this functionality to be enabled in STEP 7-Micro/WIN 32. The menu option Debug>Write-Force Outputs in STOP enables you to Write or Force outputs while the PLC is in STOP mode.
Warning If the S7-200 PLC is connected to equipment when you write or force an output, these changes may be transmitted to the equipment. This could result in unanticipated activity in the equipment, which could also cause death or serious injury to personnel, and/ or damage to equipment.
Each time STEP 7-Micro/WIN 32 is opened, the menu option defaults to unchecked, and you are prevented from writing or forcing outputs while the PLC is in STOP mode. Checking the menu option enables writing and forcing for the current editing session with the current project. When a different project is opened, the menu option returns to its default state and you are prevented from either writing or forcing output addresses while the PLC is in STOP mode.
The example program below shows formatting in the STL editor according to the guidelines given in How to Enter a Statement in STL. You might want to set up your program similarly, by having the network comments give a general overview of the function of the network and the statement comments identify the function of the statement. Note that the sample is written with symbolic addresses.
If you would like to see this program (in either STL or LAD) in STEP 7-Micro/WIN 32, select File>Open, browse to the STEP 7-MicroWIN\Samples\English directory, highlight the sample program and click the Open button.
Sample Program for a Paint Mixer
NETWORK 1 //Fill the tank with ingredient 1 and monitor tank level.
//Maintain Pump Status if Start Switch Opens.
LD Start_1 //Load value of Start_1 I0.0.
O Pump_1 //Or with Pump_1 Q0.0 value. A Stop_1 //And with Stop_1 I0.2.
AN High_Level //And Not with High_Level I0.4.
= Pump_1 //Assign result to Pump_1 Q0.0.
NETWORK 2 //Fill the tank with paint ingredient 2 and monitor tank.
//level. Maintain Pump Status if Start Switch Opens.
LD Start_2 //Load value of Start_2 I0.1.
O Pump_2 //Or with Pump_2 Q0.1 value. A Stop_2 //And with Stop_2 I0.3.
AN High_Level //And Not with High_Level I0.4.
= Pump_2 //Assign result to Pump_2 Q0.1.
NETWORK 3 //Set memory bit if High Level is reached.
LD High_Level //Load value of High_Level I0.4.
S High_Lev_Reached, 1 //Set High_Lev_Reached M0.1 to 1 (on).
NETWORK 4 //Start Timer if High Level is reached.
LD High_Lev_Reached //Load value of High_Level_Reached M0.1.
TON Mix_Timer, +100 //Timer 37, Preset = 100 (@0.1 s).
NETWORK 5 //Turn on Mixer Motor.
LDN Mix_Timer //Load Not value of Mix_Timer T37.
A High_Lev_Reached //And with High_Lev_Reached M0.1.
= Mixer_Motor //Assign result to Mixer_Motor Q0.2.
= Steam_Valve //Assign result to Steam_Valve Q0.3.
NETWORK 6 //Drain mixing tank.
LD Mix_Timer //Load value of Mix_Timer T37.
AN Low_Level //And Not with Low_Level I0.5.
= Drain_Valve //Assign result to Drain_Valve Q0.4.
= Drian_Pump //Assign result to Drain_Pump Q0.5.
NETWORK 7 //Count each cycle.
LD Low_Level //Load value of Low_Level I0.5.
A Mix_Timer //And value of Mix_Timer T37.
LD Reset //Load value of Reset I0.7.
CTU Cycle_Counter, +12 //Counter 30, Preset = 12.
NETWORK 8 //Reset memory bit if Low Level reached and Timer //timed out.
LD Low_Level //Load value of Low_Level I0.5.
A Mix_Timer //And value of Mix_Timer T37.
R High_Lev_Reached, 1 //Reset value of High_Lev_Reached M0.1 to 0.
A. Protocol used in the in S7-200 PLC is PPI Protocol
B. 32 station Can Be Possible in the S7-200 Network
In a STEP 7 program you work with addresses such as I/O signals, bit memory, counters, timers, data blocks, and function blocks. You can access these addresses in your program absolutely, but your programs will be much easier to read if you use symbols for the addresses (for example, Motor_A_On, or other identifiers according to the code system used within your company or industry). An address in your user program can then be accessed via this symbol.
Absolute Addresses
An absolute address comprises an address identifier and a memory location (for example, Q 4.0, I 1.1, M 2.0,FB21).
Symbolic Addresses
You can make your program easier to read and simplify troubleshooting if you assign symbolic names to the absolute addresses.
STEP 7 can translate the symbolic names into the required absolute addresses automatically. If you would prefer to access ARRAYs, STRUCTs, data blocks, local data, logic blocks, and user-defined data types using symbolic names, you must first assign symbolic names to the absolute addresses before you can address the data symbolically.
You can, for example, assign the symbolic name MOTOR_ON to the address Q 4.0 and then use MOTOR_ON as an address in a program statement. Using symbolic addresses it is easier to recognize to what extent the elements in the program match the components of your process control project.
An instance data block is assigned to every function block call that transfers parameters. The actual parameters and the static data of the FB are saved in the instance DB. The variables declared in the FB determine the structure of the instance data block. Instance means a function block call. If,
for example, a function block is called five times in the S7 user program, there are five instances of
this block.
Creating an Instance DB
Before you create an instance data block, the corresponding FB must already exist. You specify the number of the FB when you create the instance data block.
One Instance DB for Each Separate Instance
If you assign several instance data blocks to a function block (FB) that controls a motor, you can use this FB to control different motors.
The data for each specific motor (for example, speed, runup time, total operating time) are saved in
different data blocks. The DB associated with the FB when it is called determines which motor is
controlled. With this technique, only one function block is necessary for several motors
System Functions
A system function is a preprogrammed function that is integrated on the S7 CPU. You can call the SFC in your program. SFCs are part of the operating system and are not loaded as part of the program. Like FCs, SFCs are blocks â€without memory.â€
S7 CPUs provide SFCs for the following functions:
Copying and block functions
Checking the program
Handling the clock and runtime meters
Transferring data sets
Transferring events from a CPU to all other CPUs in multicomputing mode
Handling timeofday and timedelay interrupts
Handling synchronous errors, interrupts, and asynchronous errors
Information on static and dynamic system data, for example, diagnostics
Process image updating and bit field processing
Addressing modules
Distributed I/O
Global data communication
Communication via nonconfigured connections
Generating blockrelated messages
A shared data block is not assigned to a logic block. It contains values required by the plant or
machine and can be called directly at any point in the program.
An instance data block is a block that is assigned directly to a logic block, such as a function block. The instance data block contains the data that were stored in a function block in the variable declaration table.
If you using HW Config to revise a station configuration and you want to exchange a module for
one with a new order number for example, proceed as follows:
1. Use a drag-and-drop operation to drag the module from the Hardware Catalog window over the old module that is already placed.
2. Drop the new module. To the extent possible, the new module assumes the parameters of the one that was already inserted.
This procedure is faster than exchanging modules by deleting the old module and then inserting the new one and assigning parameters to it.
You can turn this function on or off in HW Config by means of the menu command Options > Settings
Complex data types define data groups that are larger than 32 bits or data groups consisting of other data types.