Siemens Function Block troubles...

DanJack

Member
Join Date
Feb 2010
Location
Norway
Posts
16
Hi!

I'm having a weird issue with programming my own function blocks. For some reason unknown to me, I can not set any of my boolean outputs in my function blocks?

Even though all conditions have been met to set a "1" on the block output, this simply does not happen. I've opend up the instance data block in a VAT, and seen that if the address 20.3 is high then the output 4.3 should be high, however this does not happen.

The only thing that apparently "fixes" the issue, is to delete the output and create a new one with a new symbolic name at a different address. This "fix" only lasts until i turn of the PLC and disconnect STEP 7. If i re-upload the block to the PLC the same fault appears again.

In the same block i have outputs of other types, like INT. These work perfectly everytime. If I cant solve this issue I'll have to scrap all of my custom function blocks and re-write most of my program.

The PLC in question is a Siemens S7-300 series with a 315-2 DP CPU. STEP 7 is Ver 5.4.

If anyone has any ideas on how to solve this, then any help would be highly appreciated.

DanJack.
 
Last edited:
Create a library, copy the relevant blocks to the library, archive the library and then post as an attachment.
 
You need to put together a minimum set of blocks that we can run that demonstrate the problem. You need to call your blocks from OB1 and assign outputs etc. FC105 is required as well.
 
On another note, FB needs redesign as you have multiple rungs assigning coils - the last one will win.
If you going to call these blocks more than once then you need to replace the S5 timers with instances of SFB4 instead.

vvv.jpg
 
Last edited:
Rest of the program.

Here is all the blocks I have in my program. The general idea of the block is to have different "states". As such only one rung will be active at any given time. Or at least that is what I am trying to do, anyway.

So I need to use SFB4 in stead of the S5 timers if I am going to use several instances of the same block? You'll probably find more odd stuff in there. First attempt a making my own function blocks. The idea was to have re-usable blocks representing real world objects, so I would not have to write the same code over again and again.
 
Last edited:
Hmm, I'm not entirely sure that I am following you here. You are saying that if I make the #V_COIL in the last rung of my state scheme TRUE, it will work? How? Or better, Why? As I've imagined the internal block state logic, #V_COIL should only be TRUE or FALSE based on being in a specific state, there being only one state allowed at any given time and the logic that is to be checked and executed only in that particular state.
 
Hmm, I'm not entirely sure that I am following you here. You are saying that if I make the #V_COIL in the last rung of my state scheme TRUE, it will work? How? Or better, Why? As I've imagined the internal block state logic, #V_COIL should only be TRUE or FALSE based on being in a specific state, there being only one state allowed at any given time and the logic that is to be checked and executed only in that particular state.

Am I right that you only have experience in other programming languages?

Network 27 is translated as:
IF #ValveStateFault == TRUE AND #ConstLow == TRUE THEN
#V_COIL = TRUE
ELSE
#V_COIL = FALSE
END_IF
 
DanJack said:
Hmm, I'm not entirely sure that I am following you here. You are saying that if I make the #V_COIL in the last rung of my state scheme TRUE, it will work?

No, he's just proving that the coil is controlled by it's last solved occurrence.

(As Pego also states with his pseudo-code)
 
For Network 27 would be translated as:

IF #ValveStateFault == TRUE AND #ConstLow == FALSE THEN
#V_COIL = FALSE
ELSE
#V_COIL = FALSE
END_IF

This should be the correct behavior, and as far as I can tell, this works. However, in any of the states where #V_COIL should be TRUE, #V_COIL is never set to true. Example:

In the 'OPEN_1' state, one the actions are;
IF #ValveStateOpen == TRUE THEN
#V_COIL = TRUE

If I delete #V_COIL and replace it with for example #V_SET with a different address, it will work, until I power down the PLC and at a later time download the block again. Then I'm right back at the beginning with the same issue. It has happened three times now...
 
Last edited:
nw23 & nw27(

v_coil := valvesStateOpen_1;

v_coil := ValveStateFault && ConstLow;

)

See, first you assign boolean state of valveStateOpen_1 to v_coil, it might be true at this point. But then you proceed to assign state of ValveStateFault && ConstLow to it. Its always false if ValveStateFault and ConstLow both are not true.
 
See post #11

I would understand it if there were multiple rungs setting the state of #V_COIL at the same time. Or is it so, that if #V_COIL is addressed i 5 different rungs, the last rung which addresses #V_COIL will ALWAYS determine the state, no matter what the preceding code says?

If so, it would only be possible to set #V_COIL in one rung only?
Then how would it be possible to implement a state based system where i would turn #V_COIL = TRUE in one step, the set #V_COIL = FALSE in another?
 

Similar Topics

Hello, We have a startup valve, that has to open on startup etc. We also want to know the flowrate throughe valve. They told me that in previous...
Replies
17
Views
2,736
I am working with a Siemens 1515 CPU and I have created a ladder function block to use like an AB Add-On Instruction to control a Danfoss VFD. I...
Replies
6
Views
1,723
Hello all, Newbie in Siemens, I want to ask if there will be any issue when I download the instance datablock of a certain Function block? Also...
Replies
6
Views
4,405
Siemens S7-1500 I am trying to write some logic I just can't quite wrap my head around the cleanest way to write it, and was hoping for some...
Replies
5
Views
2,423
If we need to modify a FB which has already been used/called in various FCs , what is the best way to do it? Example : A FB , with three inputs...
Replies
30
Views
12,553
Back
Top Bottom