At your service locally, around the globe: Partner for consulting, sales, training, service, support, spare parts.... covering the entire rage of Siemens for industry. You will find your personal contact person in our

How can you address I/O bytes and individual bits via the I/O?

Entry

Associated product(s)

Instructions:
If the bits are to be updated faster than through the process image, you can implement your program with the direct commands PQB, PQW and PQD in the STL editor of STEP 7. However, with these statements you cannot address individual bits via the I/O. For addressing individual bits you must write at least the complete byte to the I/O. If the other bits of the byte are not be to changed, then you must program relevant logical operations according to the change of the bit (TRUE/FALSE). Then you can write the complete byte to the I/O via direct command.

The table below contains examples for addressing a bit field and setting an individual bit in the I/O.

No.

Examples for I/O addressing:

1

Setting the bit field in the I/O area
By calling and parameterizing SFC 79 "SET" you can set a selected bit field in the I/O area. The parameters must be assigned as shown in the following example (Fig. 01). In this example PQB 4 is set.

Fig. 01

Please pay attention to the syntax of the pointer on the "SA" parameter - here there must be the statement "P#Px.y" (pointer to the first bit to be set). If you specify a different area ID or an incorrect address here, STEP 7 doesn't report an error. Upon implementation at runtime however the CPU reports an "area error when writing a parameter".

More information on the system function SFC 79 is also available in the STEP 7 Online Help or in the manual "System Software for S7-300/400 System and Standard Functions", Entry ID: 44240604.

2

Setting individual bits via the I/O
The STEP 7 project contains the function FC4, which you use to change a bit and write it directly to the I/O without affecting the other bits. Specifying the output address and the bit to be changed changes the status of that bit according to your specification. Through logic operations in the function only that specific bit is changed. The function then transfers the complete byte to the I/O via direct command.

Fig. 02

Download:
The attached download "Di_Com.zip" contains a STEP 7 project with the block described above. Open and copy the "Di_Com.zip" file into a separate directory. The STEP 7 V5.4 project then unpacks automatically with all the associated subdirectories. You can use the SIMATIC Manager to open and process the extracted project.

Runnability and test environment:
The examples can be used on all the CPU types of SIMATIC S7-300, S7-400, C7 and WinAC. The following table lists the components that have been used to create this entry and verify the functions described.

Test environment:

Version:

PC platform

Intel(R) Pentium(R) M processor 1.73 GHz, 1.49 GB RAM

PC operating system

MS Windows XP SP2

STEP 7

V5.4

Options package S7 PLCSIM

V5.3

Keywords:
Direct command access

Security information

In order to protect plants, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about industrial security, please visit