Siemens STEP-7_confused

Step7_aby

Member
Join Date
Feb 2008
Location
Abu Dhabi
Posts
22
Hi Guys,

I am new to Step-7 Programming i don't know where to start and all. I am very much confused with OB's, FB,s and FC,s that we have here, i have to do the STL programming please help me out with this!!!!!!!!!!

Why do we have these many OB's and FB,s there Significance, how to define the inputs and outputs for the FB,s and FC,s
 
What experience do you have with other PLC's?

What literature do you have on Step 7?

Why do you HAVE to program in STL? Ladder would be better to learn and get used to the PLC, STL is only necessary for certain things, most things can be accomplished with ladder.

OB = Organisation Block, these are for specific things, you don't need to use them all.

OB1 is the only necessary one, as this is the base distribution block, this block is run after the inputs are updated and before the outputs are updated. All FB and FC paths originate from here.

OB100 to OB102 = start up blocks, depending on the type of start one of these will run, once only, on start up. Good for presetting things in the program. These like all OB's (except OB1) are not compulsary to program.

FB's (Function Blocks) and FC's (Functions) are where the main code will reside, these enable the code to be compartmented into smaller parts, each should be specific for a small section of the total code.


Try reading some of these manuals
 
Last edited:
I do have experience in Triconex TMR PLC, ABB AC-450 controllers and many others apart from Siemens systems and i am working on them for the first time, i know some basics of siemens product but i am not proficient with them.
I have to code in STL as it is the requirement,thanks for the info about OB1, could you expain me how FB and FC works i mean the concept for the same and also i would like to know when to use "interface" with IN,OUT, IN-OUT,TEMP,STAT.

i am sending you one small code could you expain me step by step working

L #START_ADDR
T #SRCADDR
L 0
ADD: L W#16#1002
T LW 0
L #NO_BYTES
T LW 2
L #SRC_DB
T LW 4
L #SRCADDR
SLD 3
OD DW#16#84000000
T LD 6
L W#16#1002
T LW 10
L #NO_BYTES
T LW 12
L #DEST_DB
T LW 14
L #DEST_START_ADDR
SLD 3
OD DW#16#84000000
T LD 16
CALL "BLKMOV"
SRCBLK :=#SANY
RET_VAL:=#RET_VAL
DSTBLK :=#DANY

CALL FC 2
NM_BREAKER_1:="DEVICE".NM_breaker

CALL "BLKMOV"
SRCBLK :=#DANY
RET_VAL:=#RET_VAL
DSTBLK :=#SANY

L #SRCADDR
L #NO_BYTES
+I
T #SRCADDR
L #DEV_CNT
L 1
+I
T #DEV_CNT
L #NODEV
>=I
JC A001
JU ADD
A001: BLD 130


Thanks in Advance

please try to explain me clearly i mean what each step is suppose to do
 
FC's and FB's are similar, the only difference really is the fact that FB's are linked to a Datablock and can store the status of the last scan, whereas FC's cannot.

So an FC is a block that only knows the status of data that you send in via the Input parameters.

IN - Is data passed into the block.
OUT - Is result data passed out.
IN_OUT - Is data you pass in, is updated and passes out again.

These are the basic block parameters.

As a general rule, in the FC you cannot use an output contact until you have processed the output in the block, as until you have turned it on or off, it could be any state. If you want to do that then you must use an IN_OUT, as this is an output that is updated on the block call.

FB's don't have this problem as they remember the state of the OUT from the last call in the instance DB.

TEMP - Both FC's and FB's have TEMP's, these are scratch flags that you can give a name to and use in the block, scratch flag memory area is shared throughout the code, so they could be any state before you use it, so ensure you never try to use a TEMP unless you have pre-conditioned it.

STAT - Only found in FB's, this is a memory area that is stored in the instance DB, therefore the unique conditions for a single block call can be remembered for the next scan.
 
The code you have put in is a block move where the data parameters are sent in via the I/O parameters. It uses SCF20, a system Function for moving blocks of data.


L #START_ADDR
// Probably an integer or word, this will be an IN, START_ADDR value is stored into ACCU1 (accumulator) and is pointing to the first word that is required to be moved.

T #SRCADDR
// A Temp int or word, so ACCU1 is transferred into SCRADDR (basically START_ADD is transferred into SRCADDR via the accumulator), later code looks like a loop so perhaps this will change as the program loops.

L 0 // 0 is loaded into the accumulator

ADD: L W#16#1002 // ADD: is a jump label, 1002 HEX is added to the contents of the accumulator. NOTE 1002 is usually the first word of an ANY parameter (block address pointer), which stipulates Step 7 format (10) and the data is in Bytes (02).

T LW 0 // the contents of the accumulator are loaded into LW0 (LW0 is the first TEMP word directly addressed, this is usually seen as bad programming because if a modification is done where a new TEMP is put in before the curremt first TEMP, then this will then be a program error). I presume the first TEMP is in ANY format.

L #NO_BYTES //This will be another IN, which stipulates how many bytes will be moved.

T LW 2
// 2nd TEMP word, which is the second word in the ANY parameter (ANY = 10 bytes, or 5 words). This is the length field of the ANY.

L #SRC_DB
// This is another IN, stipulating the Data block address.

T LW 4 // 3rd TEMP word, or 3rd word in the ANY parameter, which is Data Block Address.

L #SRCADDR // IN parameter, stipulating the start address of the block move

SLD 3 //The right hand 3 bits of the last two words in the ANY parameter are the bit address (000=bit 0 through to 111=bit 7), so this shilft left double is placing the byte address into the correct position in double word.

OD DW#16#84000000 // The first byte of the last two words in the ANY parameter is the data type, 84=data block. This OR's the value with the current conents of the accumulator, making ithe first byte 84.

T LD 6 // the result of the last few instructions is loaded into local double 6, which is the last two words of the ANY parameter, block type and start address.

The bold below is then repeating the same for the second ANY parameter, which is the second TEMP parameter defined.

L W#16#1002
T LW 10
L #NO_BYTES
T LW 12
L #DEST_DB
T LW 14
L #DEST_START_ADDR
SLD 3
OD DW#16#84000000
T LD 16


Below
BLKMOV = SFC20, system FC20 = Block Move.
SRCBLK = ANY parameter pointing to the start address to move and the length of data to move. Seen above that SANY is the first TEMP.
DSTBLK = ANY parameter pointing to the start address to receive and the length of data to receive. Seen above that DANY is the second TEMP.

CALL "BLKMOV"
SRCBLK :=#SANY
RET_VAL:=#RET_VAL
DSTBLK :=#DANY


Calls an FC, presume NM_BREAKER_1 is an IN?? "DEVICE" = DB in symbol format, NM_breaker is probably a bit in the DB, in symbol format.

CALL FC 2
NM_BREAKER_1:="DEVICE".NM_breaker


The data moved before is now transferred back

CALL "BLKMOV"
SRCBLK :=#DANY
RET_VAL:=#RET_VAL
DSTBLK :=#SANY


Below offsets the start address by the number of bytes moved.
L #SRCADDR
L #NO_BYTES
+I
T #SRCADDR

Below, increments device count, don't like this as I cannot see where device count was preset to zero before the start.
L #DEV_CNT
L 1
+I
T #DEV_CNT

Below, jump back to the label ADD: if all the devices have not been processed. If they have then jump to end. Not sure why they put the BLD there, normally for display purposes for ladder.
L #NODEV
>=I
JC A001
JU ADD
A001: BLD 130
 
If you search in the help files of step7, index, search for ANY then look at the Format of the Data Parameter Any - it does a good job of explaining what each of the 10 bytes of data means....
 
Thanks Peter

It was really vey helpful for me peter i am grateful to you, I would like to know do you know about the FB65 i.e "Alrm7PB" block used for time stamping.

Please do provide me some help on "FB65"

Tons of thanks
 

Similar Topics

Good Morning, Hoping someone with some Siemens experience can give me a hand with this one. Customer has a S7-200 cpu, which has a 6GK7...
Replies
0
Views
235
I'm just trying to figure out the right method of adding a DO card to an existing rack. It's not the *next* open slot, but I have to move the AO...
Replies
5
Views
540
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
638
Hello, We monitor the temperature of a pipe via a 4-20mA temperature transducer. This goes into DB135(Read Analog Inputs). The issue I have is the...
Replies
0
Views
621
Please excuse the basic question, but I've never worked on Step 7 before (until now, only dealt with Mitsubishi Q-series PLCs)... What is the...
Replies
16
Views
3,316
Back
Top Bottom