PRO2 07E IndirectAddressing PDF

September 15, 2022 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download PRO2 07E IndirectAddressing PDF...

Description

 

Indirect Addr essing (1) (1)

?

  r   t  e    i  n   o    P   #

?

#Ini_Value

? #Counter 

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

18.09.2009 PRO2_07E.1

Co n t en t s Object Obj ective ives s

SITRAIN Training for   Automation and Industrial Industrial Solutions

Pag e ...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... .....

2

 Addressing Possibilities with with STEP 7 ........................................................................................ ................................................................................................ ........ Direct Dir ect Add Addres ressin sing g of Var Variab iables les ...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...

3 4

Direct Addressing Addressing of Address Address Ident Identifier ifiers s in Data Block Blocks s ............ ................. .......... .......... ........... ........... ........... ........... ........... ........... .......... ........ ...

5

 Analyzing DB Information in the Program

....................................................................................... .........................................................................................

6

...... ........... .......... .......... ........... ............ ........... .......... .......... ........... ........... .......... .......... ........... ............ ........... .......... ........... ........... .......... ....... ..

7

Structure Struct ure of Pointers Pointers with Memo Memory ry Indirect Indirect Addre Addressing ssing ...... ........... ........... ........... ........... ........... .......... ........... ............ ........... .......... ........... ......... ...

8

 Address Areas for Storing 16-Bit and and 32-Bit Pointers ........................................................................ ........................................................................

9

Example of Memory Indirect Addressing ............................................ ....................................................................................... ............................................... ....

10

Testin Tes ting g the Pro Progra gram m Execu Executio tion n usi using ng Break Breakpoi points nts (Pa (Part rt 1) Testing the Program Testing Program Execution Execution using Breakp Breakpoints oints (Part 2)

... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..... ........... ................. ........... ........... ........... .......... ........... ............ ........... .......... ....... ..

11 12

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... .....

13

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...

14

...... ......... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...

15

Memory Memo ry Indirect Indirect Addre Addressing ssing

Task Tas k 1: Storin Storing g Part Weigh Weightt Valu Values es (FC 35) 35) Exerci Exe rcise se 1: Sto Storin ring g Part Part Wei Weight ghts s (FC (FC 35) Task Tas k 2: Displayi Displaying ng Wei Weight ght St Stati atisti stics cs

Exerci Exe rcise se 2: Displa Displayin ying g Weight Weight Stat Statist istics ics (FC3 (FC36) 6) If You Want to Know More

…..... …........ ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ...... ..... ..

16

.......... ................ ........... .......... .......... ........... ............ ........... ........... ........... .......... .......... ........... ............ ............ ............ ............ .......... ......... ....... ..

17

 Area-Internal, Register Indirect Addressing

................................................................................. ...................................................................................... .....

18

 Area-Crossing, Register Indirect Addressing ................................................................................. .................................................................................... ...

19

SITRAIN Training for   Automation and Industrial Solutions

Page 1

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Objectives Upon completion of the chapter the participant will ...

SIMATIC S7 Siemens AG 2008. All rights reserved.

SITRAIN Training for   Automation and Industrial Solutions

...

understand th the ba basics o off m me emory iin ndirect a ad ddressing and be able to apply it



understand and be able to assign parameters of the  ANY type



be familiar with register indirect addressing



be able to use the test function "Breakpoint"

Date: File:

18.09.2009 PRO2_07E.2

Page 2

SITRAIN Training for   Automation a and nd Industrial Solutions

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

 Add  A dd res si n g Po Poss ss i bi l i t i es w it h S STEP TEP 7  Addr  Ad dress essin ing g Pro ced cedur ure e

Di r ec t A d d r es s i n g

ab s o l u t e

In d i r ec t A d d r es s i n g

s y mbol i c

m em o r y i n d i r ec t

r eg i s t er i n d i r ec t

16 16-bit -bit po inter  (DB, T, C)

32-bit p ointer  32-bit area-internal

32-bit 32-bit po inter  area-internal

32-bit 32-bit poi nter  areacrossing

OPN DB[MW10] SP T T[["runtime"]

A I[MD30] L IW["Number"]

A I[AR1,P#0.0] L ID[AR1,P#5.0]

A [AR1,P#0.0] T W[AR1,P#0.0]

Examples:  A I 4.0 L IW10

A "Mot_on" L #Num

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

18.09.2009 PRO2_07E.3

SITRAIN Training for   Automation and Industrial Industrial Solutions

Direct  Ad dress dr essin in g

With direct addressing, the memory location is coded in the instruction. That is, the address identifier specifies the address value the instruction is to process.

Symbolic  Ad dress dr essin in g

In a control program, addresses can have absolute addressing (such as I 1.0) or symbolic ("start signal" for example). The symbolic address uses names instead of the absolute addresses.  A program is easier to read when meaningful meaningful names are used. With symbolic addressing differentiation is is made between local symbols (in the the declaration part of a block) and global symbols (symbol table).

Indirect  Ad dress dr essin in g

With indirect addressing you are able to address address identifiers whose address is determined only at program progra m runtime. With indirect addressing, program parts, for example, can be scanned repeatedly (loop programming), whereby the addresses used are assigned different addresses with every scan. With indirect addressing, differentiation is made between: •

memory memory indirect indirect addre addressing: ssing: A pointer pointer to the the addresse addressed d address address iis s found found in a user memory’s memory cell (such as MD30). With memory indirect addressing, the variables, in the memory in which the pointer of the addressed address identifier is stored, can also be assigned symbolic names.



Caution

register register indirect indirect addres addressing: sing: The p pointer ointer to the addressed addressed address address is loaded loaded in one of the two address registers (AR1 or AR2) of the S7 processor before being accessed. (Is dealt with in the Course ST-PRO3).

Since the addresses are only calculated at run-time with indirect addressing, there is the danger that memory areas are unintentionally overwritten and you can then have an unexpected PLC reaction.

SITRAIN Training for   Automation and Industrial Solutions

Page 3

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Direct Addressing of Varia Variables bles Memory Location (for example)

 Addr  Ad dress ess

 Ad di tion  Addi ti onal al  Access  Ac cess Wid Width ths s

Meaning

I

37.4

Byte, word, double word

Inputs

Q

27.7

Byte, word, double word

Outputs

PIB

655

Byte, word, double word

Peripheral inputs

PQB

653

Byte, word, double word

Peripheral outputs

M

55.0

Byte, word, double word

Bit memories memories

T

114

--

Ti m er s

C

13

--

Co u n t er s

DB X

2001.6

Byte (DBB), word (DBW) (DBW),, Da Data ta addressed vi a double word (DBD) DB register 

DIX

406.1

Byte (DIB), word (DIW), doubl e word (DID (DID))

Da Data ta addressed vi a DI register 

L

88.5

Byte (LB), word (LW), double word (LD)

Local data stack

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Direct Dire ct Addressing of Variables Variables

18.09.2009 PRO2_07E.4

SITRAIN Training for   Automation and Industrial Industrial Solutions

With the help of direct addressing, simple (elementary) variables, that is, variables up to a length of a maxim maximum um of 4 bytes, can be addressed. Simple variables consist of: •

an addre address ss id ident entifi ifier er (su (such ch as: as: "I "IB" B" for for input input byte) byte)



an exact exact addres address s (mem (memory ory locati location) on) (byte (byte or bit address address)) within within the memory memory area, that is determined by the address identifier.

Global, symbolic names (symbol table) can also address addresses or simple variables. Peripherals

Unlike S5, it is now necessary to make a distinction between inputs and outputs when accessing peripherals. However, it is still only possible to have a read-only access (L PIW) of peripheral inputs and a write-only access (T PQW) of peripheral outputs.

Local Data

DBX/DIX

Complex Variables

With STEP 7 it is also possible to have an absolute access of the local data stack’s own blocks, for example: •

A L 12.6 (scan local data bit with address address 12.6 for signal state = 1)



L LW 12 (Loa (Load d loca locall da data ta word word in ACCU ACCU1) 1)

You can also access directly simple variables within data blocks: •

A DBX 12.6

(Scan data bit with address address 12.6 of a DB for signal state = 1, DB must be opened beforehand).



L DB5.DBW10 (Load DW10 in DB5)

You can symbolically access local variables that have a complex data type, such as structures or arrays,.  Absolute access is only possible possible with components of c complex omplex variables that are elementary data types.

SITRAIN Training for   Automation and Industrial Solutions

Page 4

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Direct Addressing of A ddress Identif Identif iers in Da Data ta Blocks Open data blocks

Load and transfer  in data blocks

OPN DB 19 OPN "Values"

L DB B 1 L DB W 2 L5

L o ad d at a b y t e 1 L o ad d at a w o r d 2 (b y t e 2/3) L o ad n u m b er 5

OPN DI 20

T DB W 4 L 'A' L DIB 28

Tr an s f er i n t o w o r d 4 L o ad A SCII c h ar ac t er A L o ad d at a b y t e 28

 A DB X 0.0

Scan bi t 0 fr om by te 0

L DB1 DB19 9.DBW4 BW4

Load Load da data word word 4 from from D DB B 19 19

Combined instruct ion Combined (contains OPN DB..)

L "Value "Values".N s".Numbe umber_ r_1 1

 A DB 10.DBX4.7

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Overview

Symbolic ymbolic acce access ss of variable Number_1. DB19 has the symbol name "Values" Scan bi t 7 fr om by te 4 o f DB 10

SITRAIN Training for   Automation and Industrial Industrial Solutions

18.09.2009 PRO2_07E.5

The CPU makes two data block registers available for data address processing. The numbers of the data blocks blocks currently open are found in these registers. Before you can access a data block, you must first open it u using sing one of the two data block registers. You can open a data block using the following instructions: •

OPN DB DBx or OPN DIx

or by means of a fully-qualified access to a DB variable: •

L DB DBx.DBWy

(L DI DIx.DIWy is n no ot p po ossible!)

In this case DB number x is also loaded in the DB register.  Ad dress dr essin in g

Data blocks are organized byte-by-byte in STEP7. For the direct access of addresses with BIT, BYTE, BYTE, WORD or DWORD length, the byte address address (as for I/Q/M) is indicated in each case.

Symbolic Access

For a symbolic access you enter the data block’s symbol name in the symbol list. You use the DB Editor Editor to assign symbolic nam names es to the data block’s individual variables. Now, a complete symbolic access of a data da ta element is possible with the L "Values"..Number_1 instruction. DB19 now opens ("Values" is the symbol name of DB 19) and DW 2 is loaded (Number_1 is the symbol name of DW2).

SITRAIN Training for   Automation and Industrial Solutions

Page 5

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

 A  Anal nal yzi yzin n g DB In fo rm ati on in th e Pro g ram Instructions w ith DB Registers: Registers: 

CDB: CD B: Exchange DB Regist Regist ers

DB Register 

123

DI Register 

24

24

CDB

after:

before: 



123

Load DB Register i n ACCU1 

L DBNO (load opened DB number in ACCU1)



L DINO (load opened DI number in ACCU1)

Load length of data blocks 

L DBLG (load the length/bytes of the opened DB in ACCU1)



L DILG (load the length/bytes of the opened DI in ACCU1)

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

DB, DI Regist Regist ers

18.09.2009 PRO2_07E.6

SITRAIN Training for   Automation and Industrial Industrial Solutions

These registers contain the current valid numbers of the opened data blocks. You can open two data blocks simultaneously in a call level. STL prefers to use the first DB register for accessing accessing shared (global) DBs and the second DB register for accessing instance DBs. These registers are also called DB register or DI register for this reason . The CPU treats these registers equally. Every data block can be opened with one of these two registers (even with both simultaneously).

CDB

CDB (Exchange DB registers) exchanges exchanges the contents of the DB and and DI registers. The DB register’s contents are transferred into the DI register and vice versa. This instruction affects neither the contents of ACCU1 nor the status bits.

L DBLG, L DILG:

These instructions read out the data length of the currently opened data blocks in number of bytes. With the help of this information, the user program can test if a DB has the necessary length before the DB is accessed.

L DBNO, L DINO:

These instructions read out the numbers of the currently opened data blocks.

SITRAIN Training for   Automation and Industrial Solutions

Page 6

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Memory Me mory Indirect Add ressing





16-bit 16 -bit Pointer in Word Format (Addressi ng o f DBs, T, C) C) Instruction:

executed operation: (examples)

OPN DB [MW 60]

OPN DB 11

if [MW60] = 11

OPN DB 25

if [M [MW60] = 25

32-bit Pointer in Double Word Format (Addressing such as fo r I, 32-bit Q, M,) Instruction:

executed operation: (examples)

L

L IW 24

if [MD 50] = P#24.0

L IW 86

if [MD 50] = P#86.0

IW [MD50]

Instr Instruc uctio tion n Add Addres ress s ID

 Access width

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Overview

Pointer  (Address)

18.09.2009 PRO2_07E.7

SITRAIN Training for   Automation and Industrial Industrial Solutions

With memory indirect addressing, the address of the variable to be accessed is found in an address (memory location). Program statements using memory indirect addressing contain: •

an iins nstr truc ucti tion on (su (such ch a as: s: O OPN PN,, A, L, L, etc.) etc.)



an a addr ddress ess iiden dentif tifier ier (suc (such h as DB, DB, C, C, T, I, I, QW, MD, etc.) etc.)



and a [v [vari ariabl able], e], th that at mu must st be en enclo closed sed wi withi thin n square square bracke brackets. ts. This variable contains contains the address (poin (pointer) ter) of the operand that the instruction accesses.

The instruction will interpret data stored in the specified [variables], as either a word or double word pointer depending on the address identifier used.

Instru Instructions w ith 16-bit ctions Pointers

You FB). use the 16-bit pointer for addressing timers, counters or blocks (DB, FC, You can address all timer timer and counter instructions with indirect addressing. To address timers, counters or blocks, use area identifiers of the form T, C, DB, DI, FB, FC. The address (memory location) of the addressed operand is stored in a word.  A DB or DI register can open a data data block. If a zero is found in the pointer when you indirectly open a data block (DB, DI), then the DB/DI register is loaded with the value "0". An error is not triggered when you load with "0". You can use the UC or CC instructions (not CALL) to address the call of logic blocks indirectly. The blocks, however, may not contain any block parameters or static variables. This pointer in word format is interpreted as an integer number (0 to 65,535). The pointer refers to the number of a timer (T), a counter (C), a data block (DB, DI) or a logic block (FC, FB).

SITRAIN Training for   Automation and Industrial Solutions

Page 7

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Structure of Pointers with Memory Memory Indirect Addr essing 

Structur e of a 16-bit 16-bit Pointer: 15

14

13

12

11 10

9

8

7

6

5

4

3

2

1

0

146

0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 215

27

20

Interpretation as unsigned integer between 0 and 65,535



P#25.3

Struc tur e of a 32-bit 32-bit Poin ter (area-internal): (area-internal): 31

30

29

28

27 26

25

24

23

22

21 20 19

18

17

16 15

14

13

12

11 10

9

8

7

6

5

4

3

2

1

0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 1 20 22

215



Bit address

Byte address (unsigned integer)

not analyzed

20

Loading of 32-bit 32-bit Point er Constants (a (arearea-internal): internal): L P#25.3 (P = Pointer, Byte address= 25, Bit address: 3)

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Instructions Instru ctions w ith 32-bit 32-bit Point ers

18.09.2009 PRO2_07E.8

SITRAIN Training for   Automation and Industrial Industrial Solutions

Memory indirect addressing using 32-bit pointers can access the following addresses: •

Bit Bits s that that a are re addr address essed ed by by bi bitt logic logic operat operation ions. s. I, Q, M, L, DIX or DBX can be used as address identifiers



Byt Bytes, es, wo words rds and and do doubl uble e word words s that that are addre addresse ssed d by load load or transf transfer er instructions. IB, IW, ID, DBB, DBW, DBD, DIB, DIW, DID, PIB, PIW, PID, can be used as address identifiers.

The address of the addressed operand is interpreted as 32-bit pointer. In this double word, the least significant bits (bit 0 to bit 2) are interpreted as bit address. The next 16 bits (bit 3 to bit 18) are interpreted as byte address of the addressed operand. Memory indirect addressing does not analyze bits 19 to 31. Note

If you want to access an address by means of memory indirect addressing and use load or transfer instructions, you must make sure the bit address of the pointer is “0”. If this is not the case, the CPU CPU triggers a runtime error during execution.

Loading of 32 32-bit -bit Pointer Constants

You can use the following syntax to load 32-bit pointer constants into ACCU1: L P#.

Storage Locations Locations for  You must store 16-bit and 32-bit pointers for memory indirect addressing in Pointers one of the following areas: •

M - Bit memory



L - Local data



D - Data ata bl block ((D DB or DI) DI)

SITRAIN Training for   Automation and Industrial Solutions

Page 8

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

 A  Add dd res s A reas fo r St or i n g 16 16-B -Bii t an d 32-B i t Po i nt ers  Ab so lu te o r sy mb ol ic add ressi res si ng (exam pl es): OPN DB[#DB_No]

OPN DB[MW30] Bit memory

Loca Loc al da data ta stack stack

 A I[MD30]

 A I[LD10] I[ LD10] T QD[#Pointer]

T QD[“ QD[“ Speed_1“] Speed_1“]

Only addressa ddressable ble absolute bsolutely; ly; DB or DI must be opene opened d first (example xamples) s):: OPN DB[DBW0] Globall data block Globa

overwrit es DB Register !

 A I[DBD10] I[ DBD10] T QD[DBD22] OPN DI[DIW0] DI[DIW0]

Instan Ins tance ce dat data a block

overwrit es DI Register !

 A I[DID10] I[ DID10] T QD[DID22]

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

 Ad dr ess Ar eas for Pointers

SITRAIN Training for   Automation and Industrial Industrial Solutions

With memory indirect addressing, the address (memory location) is found in a 16-bit or a 32-bit address. This address can be found in one of the following areas: •

Bit m memory: emory: as an operand operand addr addresse essed d absolute absolutely ly or as variable variable addressed addressed symbolically through the symbol table.



Local data stack: as an operand operand addres addressed sed a absolu bsolutely tely or as temporary temporary variable declared in the block’s declaration section.



Globa Globall (S (Shared) hared) data block block:: as an o operan perand d add addresse ressed d absolut absolutely. ely. When you use global (shared) DBs as the storage location location for pointers, make make sure that the DB register (OPN DB n, for example) opens the “correct” data block before accessing.



Insta Instance nce data data block: block: as an operand operand address addressed ed absolut absolutely. ely. When When you you use use



Note

18.09.2009 PRO2_07E.9

instance data observe the following points: OBs a and nd fu functio nctions: ns: Within Within ffuncti unctions ons or or OBs, OBs, a pointer pointer stored in an instance instance data block can be used exactly as if it were stored in a global (shared) DB. Just remember that instead of the DB register, the DI register is now used.



FBs: Within FBs, insta instance nce data, data, that that is, is, paramete parameters rs or static static variables, variables, cannot generally be used symbolically for memory indirect addressing.



Abso Absolute lute access of loc local al dat data a within within an an FB is, in in principle principle,, pos possible sible using the “address” entered in the declaration declaration section. Howe However, ver, when the FB is used as multi instance, it must be noted that this address is not the absolute address specified in the instance DB but is actually the address relative to AR2.

When you pass pointers for memory indirect addressing to blocks or you want to keep the value permanently in in static variables, then you must copy the pointer value from the parameter or static variable into a temporary variable. Then complete the access using this temporary variable.

SITRAIN Training for   Automation and Industrial Solutions

Page 9

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Exampl Exa mpl e of Me Memory mory Indir ect Addressin g

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Description

18.09.2009 PRO2_07E.10

SITRAIN Training for   Automation and Industrial Industrial Solutions

This example shows a function that initializes all bytes, that is, all variables of a data block and overwrites them with the value "0". In Network 1, the number of the data block passed via the input parameter #DBNr is first of all copied onto the the temp variable #Nr, which then serves to indirectly open the data block. It is necessary to recopy onto a temp variable because parameters cannot be used for indirect addressing. In Network 2, the length [in bytes] of the data block is first of all determined and assigned to the temp variable #number, which serves as the loop counter in the subsequent LOOP. Within the LOOP, the temp temp variable #Pointer is used for indirect addressing of the data block byte that is first of all to be overwritten with the value 0. In the first loop pass this is the DBB 0 because #Pointer was already initialized in Network 1 on the value P#0.0. With each loop pass the second #Pointerloop is increased by thepoints value P#1.0 using DINT addition so that in the pass #Pointer to DBB 1, in the third loop pass to DBB 2 etc.. Since the number of loop passes corresponds cor responds exactly to the length of the data block in bytes, all data block bytes are addressed in ascending order via #Pointer and overwritten with the value 0.

Note

The system function SFC 21 (FILL) can also a lso be used to delete or pre-assign a memory area.

SITRAIN Training for   Automation and Industrial Solutions

Page 10

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Testin Te stin g the Program Exe Executi cuti on us ing B rea reakpoi kpoi nts (Part (Part 1)

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Breakpoints

18.09.2009 PRO2_07E.11

SITRAIN Training for   Automation and Industrial Industrial Solutions

With the help of this test function, you can test a program you see in STL in single-step mode and thus follow the sequence of the executed instructions as well as the associated register contents. You can set several breakpoints, depending on the CPU. The number of possible breakpoints depends on the CPU used.

Note

Breakpoint Functions

In order to carry out these test functions, you must have fulfilled the following requirements: •

The "Tes "Testt Operat Operation ion"" mod mode e must must be an assig assigned ned p para aramet meter. er.



The block block tto o be tes tested ted mus mustt be opened opened online online..



The LAD/ST LAD/STL/F L/FBD BD E Edit ditor or mu must st be expl explici icitly tly s set et to View   STL.



The block block mu must st not not be prot protect ected ed (K (Know now_ho _how_p w_prot rotect ect))

You can choose the breakpoint breakpoint functions in the Program Editor Editor by selecting the "Test" menu option or through the Breakpoint Bar. You can activate the breakpoint bar by selecting the View   Breakpoint Bar menu option in the LAD/STL/FBD Editor.

 At ten ti on

If the program execution encounters a breakpoint, the CPU switches from RUN to HOLD mode. In this mode, the STOP LED lights up and at the same time the RUN LED flashes. The outputs are deactivated for safety reasons.

SITRAIN Training for   Automation and Industrial Solutions

Page 11

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Testin Te stin g the Program Exe Executi cuti on us ing B rea reakpoi kpoi nts (Part (Part 2)

Breakpoint

Next statement

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Breakpoint Brea kpoint Bar  Set/Delete Breakpoint

18.09.2009 PRO2_07E.12

SITRAIN Training for   Automation and Industrial Industrial Solutions

Breakpoints Active (on/off) Show Next Breakpoint

Execute Call Dele De lete te All All Break reakpo poiints nts

Res Resum ume e

Nex extt Sta tate tem ment ent

Set/Dele Set/Delete te Breakpoint With "Set Breakpoint" you determine the program p rogram execution is to be halted. The breakpoint‘s statement is where not executed. With "Delete Breakpoint", you can once again delete the breakpoint. Breakpoints Active

With "Breakpoints Active" you activate all breakpoints; not onl only y those already set but also those still to be set.

Show Next Breakpoint

With "Show Next Breakpoint", the Editor jumps to the next selected breakpoint, without executing the program.

Resume

With "Resume", the program execution execution continues at "normal speed" until it reaches the next active breakpoint.

Next Statement

With "(Execute) Next Statement", the program is executed "step by step" in single-step mode. When a block call is reached, the called block is executed at "normal speed" with "(Execute) Next Statement" and the single-step mode is resumed with the statement following the block call.

Execute Call

With "Execute Call", when a block call is reached, the called block is opened in the Editor and the single-step mode is continued. At the end of the block, a jump is made back to the calling block.

SITRAIN Training for   Automation and Industrial Solutions

Page 12

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Task Ta sk 1: Stori ng Part Weig Weight ht Va Values lues (FC 3 35) 5)

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Task

SITRAIN Training for   Automation and Industrial Industrial Solutions

18.09.2009 PRO2_07E.13

In AUTO mode, parts are transported from the light barrier bay to Bays 1 to 3.  Always at the moment moment when the part reaches the first em empty pty bay or when the conveyor is stopped (see slide, FC 35 – call condition), the just set weight value "MW-Weight" (MW36) is to be stored in the data block "DB_Weight". To manage the part weight values, the data block variables "Max_Number" (DBB 0) with the maximum number of storable part weight values and "Act_Number" (DBB 1) with the current number are used. If the maximum number of storable part weights is reached, they are to be overwritten with the new weight values starting from the beginning with PartWeight[1].  An initialization can be triggered triggered via the #Init parameter in which the FC overwrites the "Act_Number" and all elements of "PartWeight" with 0. So that "Act_Number" is inbeline with theunder to tal the total quantity the initialization must triggered samedetermined conditions in asFB18, for resetting the count functions in FB 18:

FC 35 - Interface:



when when switc switchin hing g on tthe he A AUTO UTO mode mode ("L_AU ("L_AUTO" TO",, Q 4. 4.3) 3)



when when FC35 FC35 sign signal als sv via ia #full that the maximum number of part weight values has been reached ("Act_Number" = "MaxNumber") and the transport of another part is started

Input Parameters: "Init Init"" is used to trigger the initialization of the DB "new_Weight new_Weight"" triggers the storing of a new weight "DeBe DeBe"" is the number of the data block in which the weight v values alues are stored "Weight Weight"" is the current weight Output Parameter: "full full"" indicates with Status '1' that the maximum number of part weight values has been reached ("Act_Number" = "MaxNumber")

SITRAIN Training for   Automation and Industrial Solutions

Page 13

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Exercise 1: Stor ing Pa Part rt Weigh Weights ts (FC 35 35))

Indirectly open data block via #DeBe # DeBe "Act_Number" >= "Max_Number" "Max_Number" ? y es

no #full := '1'

#full := '0'

#new_Weight = '1' ? no

y es

yes

#full = '1' ?

"Act_Number" := 1

./.

no

"Act_Number" := "Act_Number" + 1

#Point := " Act " Act _Numb er " * P#2.0 #PartWeight PartWeight[# [#Point Point]] := #Weight #Weight #Init = '1' ?

no

y es Overwrite Ove rwrite " Act_Number" with 0

LOOP: For #looping #looping = 1 to "Max_Number" "Max_Number" do ./. #PartWeight [# [#looping looping]] := 0 #Point := #Point + P#2.0

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Wh at t o Do

18.09.2009 PRO2_07E.14

SITRAIN Training for   Automation and Industrial Industrial Solutions

1. Create the data block "DB_Weight" (DB 35) with the variables shown in the slide. 2. Insert the new block "FC_Weight" (FC 35) and declare the local variables and parameters shown in the slide. s lide. 3. Create the FC 35 program according to the structogram. 4. Program the call of FC 35 in FB 18 as shown before. 5. Download all modified / newly created blocks into the CPU and test your program. Watch the storing of the individual weight values by monitoring the DB 35 online. Tip: To make it easier to monitor whether the data block really overwrites from the beginning when the maximum number is reached, set the maximum number to 5, for example.

SITRAIN Training for   Automation and Industrial Solutions

Page 14

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Task Ta sk 2: Displaying Weight Weight Sta Statist tist ics

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Task:: Task

18.09.2009 PRO2_07E.15

SITRAIN Training for   Automation and Industrial Industrial Solutions

The "FC_Weight" (FC35) block stores the weights of the transported parts one after the other in "DB_Weight" (DB35). In addition to the total quantity already shown on the panel, the following weight values are now also to be displayed: •

curr curren entt weig weight ht ("MW ("MW_W _Wei eigh ght" t",, MW MW36 36))



the total total w weig eight ht of a allll part parts su up pu unti ntill now now



the the low lowes estt w wei eigh ghtt u up pu unt ntil il now now



the the h hig ighe hest st we weig ight ht up until until now now



the averag average ew weig eight ht of all parts parts u up p until until now

SITRAIN Training for   Automation and Industrial Solutions

Page 15

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

Exercise 2: Displaying Weight Statistics (FC 36)

Ind Indire irectly ctly ope open n da data ta block block via # #DeBe DeBe Initialize all OUT param parameters eters (#MinWeight (#MinWeight,, # #MaxWeight #CrossSec #Sum MaxWeight,, # CrossSec,, # Sum :=0)

y es "Act_Number"= '0' ?

no

#MinWeight := 500 500 (largest (largest possible weight) #looping := "Act_Number" #Point := P#2 P#2.0 .0 (Address of PartWe PartWeight[1]) ight[1]) LOOP: For #looping #looping = 1 to "Act_Number" do #PartWeight [#looping [# looping]] < #MinWeight # MinWeight ? y es

no

MinWeight := #PartWeight # PartWeight [#looping [# looping]]

./.

./.

#PartWeight PartWeight[# [#looping looping]] > #MaxWeight # MaxWeight ? y es

no

MaxWeight := #PartWeight # PartWeight [#looping [# looping]]

./.

#Sum := Sum + #PartWeight PartWeight[# [#looping looping]] #Point := #Point #Point + P#2.0 #CrossSec := #Sum / #Act_Number 

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Wh at t o Do

18.09.2009 PRO2_07E.16

SITRAIN Training for   Automation and Industrial Industrial Solutions

1. Insert the new block "FC_WeightStat" (FC 36) and declare the local variables and parameters shown in the slide. 2. Create the FC 36 program according to the structogram. 3. Program the call of FC 36 in FB 18 as shown before. 4. Download all modified / newly created blocks into the CPU and test your program.

SITRAIN Training for   Automation and Industrial Solutions

Page 16

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

If You You Want to Kno w More

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Note

18.09.2009 PRO2_07E.17

SITRAIN Training for   Automation and Industrial Industrial Solutions

The following pages contain either further information or are for reference to complete a topic.

SITRAIN Training for   Automation and Industrial Solutions

Page 17

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

 A  Area-In rea-In ter n al al,, Regi st er In di rec t A dd res si n g 

 Ar ea-int ea-i nt ern al Poin Po in te terr i n AR 1 o r A R2: 31

30

29

28

27 26

25

24

23

22

21 20 19

18

17

16 15

14

13

12

11 10

9

8

7

6

5

4

3

2

1

0

0 0 0 0 0 0 0 0 0 0 0 0 0 B B B B B B B B B B B B B B B B X X X

Bit

Byte address (unsigned integer)

not analyzed

20

20 22

215

address 

Command Syntax: LAR1 P#10.0

// Presetting of 

L

[AR1,

 AR1: 00000 0000000 000 0000 000 0000 0 0000 0000 0000 0000 0101 0101 0000 0000

+ 200

M

 Area

W

Access width

Address Constant register offset

SIMATIC S7

Date: File:

Siemens AG 2008. All rights reserved.

Overview

P#200.0]

Executed: Instruction

L MW 210

18.09.2009 PRO2_07E.18

SITRAIN Training for   Automation and Industrial Industrial Solutions

With register indirect, area-internal addressing, the address (memory location) of the operand to be accessed accessed is found in one of the two address registers (AR1,  AR2). The address registers’ contents are, in this this case, an area-internal 32-bit pointer with the same configuration and the same meaning as with memory indirect addressing.

Syntax

With register indirect, area-internal addressing, the entire instruction consists of: •

an ins instr truc ucti tion on (su (such ch a as: s: A A,, L, T, T, etc. etc.))



an address address identi identifier fier (such (such as I, MB MB,, QD, etc.), etc.), that that is the combina combination tion of of an area identifier (I, Q, M, DB, DI, etc.) and an identifier for the access width (B=Byte, W=WORD, D=DWORD).



and the the de declarat claration ion of an addres address s register, register, which which together together with with a constant constant offset must be enclosed within square brackets. This offset is added to the contents of the specified address register before the instruction is executed. The address register’s contents and the offset have the format of areainternal pointers consisting of byte address and bit address. The offset’s declaration (even P#0.0) in the command syntax is imperative.

Notes



With indirectly indirectly addre addressed ssed byte, word or double double word word a address ddresses, es, the the entire entire offset must have the bit address "0". Otherwise the CPU triggers a runtime error during execution of the instruction.



If the the AR1 AR1 or A AR2 R2 ad address dress register register specifie specified d in the re registe gisterr indirect, indirect, areainternal inter nal addressing addressing contains contains an area-cr area-crossin ossing g pointer (see next page), page), then the pointer’s area identifier is not evaluated during execution of the instruction. The area identifier in the address identifier is valid.

SITRAIN Training for   Automation and Industrial Solutions

Page 18

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

 

 A  Area-Cr rea-Cro o ss i ng , Regi st er In d i rec t A dd res si n g 

 Ar ea-cro ea-c ro s si ng Poin Po in te terr i n A R 1 or o r AR2: AR2 : 31

30

29

28

27 26

25

24

23

22

21 20 19

18

17

16 15

14

13

12

11 10

9

8

7

6

5

4

3

2

1

0

1 0 0 0 0 R R R 0 0 0 0 0 B B B B B B B B B B B B B B B B X X X Bit address

Byte address (unsigned integer)

 Area identifier  identifier  Bit 31=0: area-internal Bit 31=1: area-crossing 



 Ar ea Iden Id enti ti fi ers: er s:

000 010 100 110

I/O Outputs (PIQ) Data in DB R Re egister own local data

001 011 101 111

Inputs (PII) Bit memories Data in DB Re Register 2 (DI) LD of calling block

Command Syntax: LAR1 P#E10.0

// Presetting of 

L

P#200.0]

W

 Access width

[AR1,

 AR1: 10000 0000001 001 0000 000 0000 0 0000 0000 0000 0000 0101 0101 0000 0000

 

Address Constant register offset

SIMATIC S7

Executed: Instruction

Date: File:

Siemens AG 2008. All rights reserved.

18.09.2009 PRO2_07E.19

+ 200

L IW 210

SITRAIN Training for   Automation and Industrial Industrial Solutions

Overview

With register indirect, area-crossing addressing, the area identifier (such as I, Q, M, etc.) and the address (memory location) location) (byte.bit address) of the operand to be accessed is found as area-crossing pointer in one of the two address registers (AR1, AR2).

Syntax

With register indirect, area-crossing addressing, the entire instruction consists of: •

an ins instr truc ucti tion on (su (such ch a as: s: A A,, L, T, T, etc. etc.))



an identi identifier fier for the the ac access cess width (B=BYTE, (B=BYTE, W=WORD, W=WORD, D=DWORD D=DWORD). ).



and the the de declarat claration ion of an addres address s register, register, which which together together with with a constant constant offset must be enclosed within square brackets. The address register’s contents must be an area-crossing pointer with an area identifier and a byte.bit address in this case. The offset has the format of an area-internal pointer consisting of a byte and bit address that is added to the pointer’s byte.bit address in the declared address register before the instruction is executed. The offset’s declaration (even P#0.0) in the command syntax is imperative.

Notes



With indirectly indirectly addre addressed ssed byte, word or double double word word a address ddresses, es, the the entire entire offset must have the bit address "0". Otherwise the CPU triggers a runtime error during execution of the instruction.



For CPUs CPUs tthat hat have have ol older der ffirmwar irmware e versions, versions, access access to their their own local local data data (identifier: 110) is is not possible possible with indirect area-crossing addressing. In these cases, the runtime error "unknown area identifier" is triggered.  Access to their own local data is then only possible with area-internal addressing.

SITRAIN Training for   Automation and Industrial Solutions

Page 19

ST-PRO2 Indire Ind irect ct Addres Addressin sing g (1)

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF