doubt regarding simatic S7

sayahan2003

Member
Join Date
Jun 2006
Location
Calgary
Posts
185
Dear friends
I'm tring simatic s7.So, Would you please explain me what is diffrence between M(memory) and L(local).for example M0.0 and L0.0
and can you tell me the divisions of memory. as you know, we have PII and PIO tables,M,L and ... . So, I want to know which partition of memory is for tables, which for M and etc. for example from byte 0 to 256 is for PII and like this.
 
M = Marker Flag. Depends on PLC, without looking I can't remember how many bytes, possibly 1028 or 2056 bytes in total.

L = Local Flag. Again I believe about the same amount of bytes.

The difference being, M Flags are memory, L Flags are scratch, so you cannot be sure what state the L Flag could be in. If you set one in a block don't expect it to be the same state next scan or anywhere else in the program.

PII and PIO?

P's = Periphery, PIW are input words and PQW are output words, these are only called for direct access to IO or analogues, normally you would use the image bits, I's and Q's.
 
PeterW said:
L Flags are scratch, so you cannot be sure what state the L Flag could be in. If you set one in a block don't expect it to be the same state next scan or anywhere else in the program.

Peter,

I have never used "L flags" if you can't be sure of the state they are what good are they?, or are they temporary flags...set them or not..but use them in that scan, just set them before the logic?
 
M memory are equivelent to the internal coils of most other PLC types. It can also be used by the byte, word or double word. It is global and can be accessed by any part of the code within the PLC.

L memory is local to a particular function. It is equivelent to a local variable as used by C, Pascal or Visual Basic. The L memory variables are created when the function is called, and de-allocated when the function has ended. You can only use the local memory bits within the function that created it. If you want to pass this value to another function, then you have to either save the value to an M memory or DB, or use it as a parameter to call the relevant function.

Hope this helps.

Doug
 
Sorry for my tired effort at 1am after returning from a barmitzvah (groggy eyed).

I stated you can't be sure of its state anywhere else in the code, not quite true, as Doug Adam stated you can in the block that you condition it in, although not before you condition it and not in any other block, not even the block that called the block that you condition it in after you return.

L Flags can be addressed directly at any time in any block (such as = L 0.0), but be aware that if you have assigned TEMP flags in the parameter section at the top, these will automatically assign the first L flag to that TEMP parameter. The addresses shown next the name is the local flag used.

For example if you assign 3 TEMP's as follows

Enable BOOL 0.0
Disable BOOL 0.1
Total INT 1.0

Then L 0.0, L 0.1 and LW 1, will all be used. If you decide to directly use LB 3 directly as the next free byte, without creating a TEMP tag for it and then later someone adds a TEMP tag, the assigned one will automatically select the bnext available TEMP, which in this case would be 3!! This would screw your code.
 
Dear Peter
Thank you but i confused.I can undrestand what you are saying.would you explain more clearly.and dont forget i am new in S7.



PeterW said:
Sorry for my tired effort at 1am after returning from a barmitzvah (groggy eyed).

I stated you can't be sure of its state anywhere else in the code, not quite true, as Doug Adam stated you can in the block that you condition it in, although not before you condition it and not in any other block, not even the block that called the block that you condition it in after you return.

L Flags can be addressed directly at any time in any block (such as = L 0.0), but be aware that if you have assigned TEMP flags in the parameter section at the top, these will automatically assign the first L flag to that TEMP parameter. The addresses shown next the name is the local flag used.

For example if you assign 3 TEMP's as follows

Enable BOOL 0.0
Disable BOOL 0.1
Total INT 1.0

Then L 0.0, L 0.1 and LW 1, will all be used. If you decide to directly use LB 3 directly as the next free byte, without creating a TEMP tag for it and then later someone adds a TEMP tag, the assigned one will automatically select the bnext available TEMP, which in this case would be 3!! This would screw your code.
 
The picture below is an example of a FB call.

TEMP.JPG


The TEMP field has been highlighted and in the TEMP area 5 variables have been assigned.

I have highlighted the address field, these show that each TEMP tag is assigned the number of bytes required, depending on the number of bytes/bits to make up the data type.

The first is a double word, whose address is give as 0.0, the second is also a double word whose address starts at 4.0. It starts at 4.0, because the first TEMP takes 4 bytes, 0, 1, 2 and 3.

The example show that the TEMP tags take up in total 21 bytes, the last starting at 20.0 and this being a word (2 bytes).

Therefore before starting to program the block, the block has already reserved the first 21 local flag bytes for TEMP tags.

These must be assigned a value in the code within the block before they are used, example.

You cannot program L #t_Ret_Val_Int, without first transferring a value into it. It will not remember what was in it after the last scan. As it is a scratch flag, it could be used in other blocks and overwritten with another value.

You could if you wanted address it directly, such as T LW 18, this would be exactly the same as T #t_Ret_Val_Int, because #t_Ret_Val_Int address starts from 18.0.

If you modify the code as below

TEMP_1.JPG


and add a new TEMP flag, in this case a BOOL, it will automatically take 2 bytes and move all the temp flag addresses after it.

#t_Ret_Val_Int is now 20.0, therefore if you used it as T #t_Ret_Val_Int it would be OK, the address is automatically updated, if you addressed it T LW 18, it is now incorrect and is now overwritting the end of an ANY pointer, which could have dire consequences in your code.

If you had directly used LW 22 before the change, which you can, that too would now be incorrectly addressing, in this case #t_RETVAL_word.

If you directly address an L flag, the Step7 editor does automatically warn you to check addresses.
 
Last edited:
Dear Peter
It was excellent.thank you soooooo much my friend.It was a big help.god bless you.




PeterW said:
The picture below is an example of a FB call.

TEMP.JPG


The TEMP field has been highlighted and in the TEMP area 5 variables have been assigned.

I have highlighted the address field, these show that each TEMP tag is assigned the number of bytes required, depending on the number of bytes/bits to make up the data type.

The first is a double word, whose address is give as 0.0, the second is also a double word whose address starts at 4.0. It starts at 4.0, because the first TEMP takes 4 bytes, 0, 1, 2 and 3.

The example show that the TEMP tags take up in total 21 bytes, the last starting at 20.0 and this being a word (2 bytes).

Therefore before starting to program the block, the block has already reserved the first 21 local flag bytes for TEMP tags.

These must be assigned a value in the code within the block before they are used, example.

You cannot program L #t_Ret_Val_Int, without first transferring a value into it. It will not remember what was in it after the last scan. As it is a scratch flag, it could be used in other blocks and overwritten with another value.

You could if you wanted address it directly, such as T LW 18, this would be exactly the same as T #t_Ret_Val_Int, because #t_Ret_Val_Int address starts from 18.0.

If you modify the code as below

TEMP_1.JPG


and add a new TEMP flag, in this case a BOOL, it will automatically take 2 bytes and move all the temp flag addresses after it.

#t_Ret_Val_Int is now 20.0, therefore if you used it as T #t_Ret_Val_Int it would be OK, the address is automatically updated, if you addressed it T LW 18, it is now incorrect and is now overwritting the end of an ANY pointer, which could have dire consequences in your code.

If you had directly used LW 22 before the change, which you can, that too would now be incorrectly addressing, in this case #t_RETVAL_word.

If you directly address an L flag, the Step7 editor does automatically warn you to check addresses.
 

Similar Topics

Dear friends I have 2 questions: 1- When we design a FB and when we create an IDB for this FB, information in IDB will automatically...
Replies
5
Views
3,164
Dear friends I have another doubt in simatic S7.As you know, when we define A function or function block, sometimes we define some Input or output...
Replies
8
Views
3,095
hi.. Iam using GT Designer3 for designing a HMI in Mitsubishi GS Series.How Could I use a dropdown box in that.
Replies
0
Views
1,693
Hello guys, I would like your help confirming the 1761 NETENI function. As in the AB manual 1761 UM006E says: Peer-to-Peer Messaging This...
Replies
0
Views
1,692
Dear friend Can anybody tell me what is the differenc between PLC and DCS(distributed control system).and what is the real meaning of...
Replies
6
Views
4,918
Back
Top Bottom