4 Programming the Application
This chapter deals with the steps to creating a working program from both the Siemens and A-B platform. In the last chapter, we dealt with linking the computer to the PLC and establishing the project or file for the PLC to begin programming. This chapter deals with the creation of programs for the PLC.
Background Program
Allen-Bradley and Siemens go about storing programs in a main file that runs continuously in the background of the processor. Allen-Bradley refers to this program as Main while Siemens refers to it as OB1 (Object Block 1). The method of storing logic looks slightly different for the two. At the left is Allen-Bradley’s program format. It resembles a scroll. At right is the Siemens approach. Siemens allows the programmer to use one line or rung of logic per Network or place multiple lines of logic in the same network. An advantage of placing more than one line in the same network is that the logic is not as spread out and can be more easily read.
The following shows the path logic is solved by both manufacturers’ PLC. The logic solves left to right, up to down and down to up. Never does the logic flow right to left. There may be a circuit that, if copied as is, would require right to left logic but this logic must be modified to not allow the flow right to left.
Discussion of entry of the logic for both processors is given.
First with Siemens
Organizing the Program in S7
The S7 PLC uses “program containers” called Organization Blocks to separate programs into areas of execution.
OBs are numbered and divided into different classes based on function. The quantity of OBs of a particular class vary by CPU model. OBs are added by the application programmer as desired. OB1 contains the main application program for the PLC. Other OBs can be thought of as interrupt handlers or subroutines (function blocks).
What Are Organization Blocks?
Organization Blocks (OBs) are the interface between the operating system of the CPU and the user program. OBs are used to execute specific program sections:
- At the startup of the CPU
- In a cyclic or clocked execution
- Whenever errors occur
- Whenever hardware interrupts occur
During a warm restart, the first step carried out by the operating system is to delete the non- retentive bit memories, timers, counters, interrupt stack, and block stack; to reset all stored hardware interrupts and diagnostic interrupts; to write the status of the outputs to the PIQ table (Process Image of Outputs); and to start the scan cycle monitoring time. In the second step, the operating system writes the values from the process-image output table into the output modules. In the third step, it then reads the status of the inputs and writes them to the PII Table (Process Image of Inputs). In the fourth step, it then executes the user program with the respective instruction. The operating system starts the cyclic operation again and continually monitors for interrupts.
Startup
A startup program is