Step7 - Peculiar behaviour when viewing Block online

In FC, all the in and in_out parameters are "move" into the stack memory. The logic is then executed in reference to # symbols which we define in the interface (in, out, in_out, temp). After which, in_out and out parameter is "move" out. This stack memory is of random value if it's not initialize. I'm not sure exactly if L or B stack memory is used in FC for this.

In contrast to FC, FB "moved" the parameter into a DB, or which Step7 call it as DI (instance DB). This is why FB is called as "blocks with memory".

Try changing the original code to a FB instead and see if it’s work the way it’s intended to be.

Cheers
 
Hi SimonGoldsworthy,

What about FC3?


FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
iBert : INT ;
END_VAR
BEGIN
NETWORK
TITLE =
L #iBert;
+ 1;
T #iBert;
END_FUNCTION​
 
Hi,

FUNCTION FC 3 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
iBert : INT ;
END_VAR
BEGIN
NETWORK
TITLE =
L #iBert;
+ 1;
T #iBert;
END_FUNCTION

In this case, the formal parameter is “move” into ibert, incremented, but the incremented is not “move” back to the formal parameter as ibert an Input. The formal parameter will not increment.

Where else, the case of FB, if assign a formal parameter to the parameter ibert, the same result will happen like in the case of FC as the formal parameter does not get the incremented result. But, if we do not assign anything, u will see the incremented result in the DI (instance data block).ibert.
 
Hi,

..and like Simon mentioned, the FC 413 seems to work
as expected, and if the parameter are correct and not
corrupted elsewhere in the program I would look
wherefrom the function is called.
enableFC.jpg


This looks a bit weird (at least to me :)). Since the function is triggered by input 'EIN', it should always enable
to 'see' the oneshot 'TAKT' , or at least in auto- and manual mode.
I would check this signal first.

regards
Rolf
 
Well, there's is some difference between FC and FB and effect of Input, Output and In_out.

In the case of FC, MW200 will not increment.
 
bebecall said:
Well, there's is some difference between FC and FB and effect of Input, Output and In_out.

In the case of FC, MW200 will not increment.

:D :D He won't try it will he....


I believe you Simon Goldsworthy...... (y)


It would also explain why the customer insists it works, they have probably only ever run it with elementry data types.

I also had experience with a sub contractor who was resistant to changing an OUT to an IN_OUT on my instruction after inspecting their code, it works was their reaction, I had no idea this was why, but I made them change it.

As you said, if this is to be a standard piece of code, you don't know how its to be used in the future, it may work now but not later, as has been found here.

bebecall, have you not read the reason why the above actually does work, have you not tested it, don't be so stubborn, open your mind .. :geek:
 
I have tried it out, to my surprise, MW200 does increment. But when I changed it to a DB, eg (DB1.DBW0 declare as a global DB) it doesn’t increment.

I believe that it’s due to way how S7 implements moving of parameters. Markers are fix memory are in the CPU where size is dependent on the exact CPU model while DB is not.
 

Similar Topics

This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
3
Views
157
When you download a DB, the values get overwritten by what is in the "actual" column in offline DB. Does this happen at the start of the PLC...
Replies
6
Views
152
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
144
Hi all, I am trying to convert RSLogix 5000 program to Step7. I need to bit shift left my array of double integers for tracking the product on...
Replies
2
Views
528
I have a word in some DB which I want to load to AR1 and use as a pointer. In order to do this I need to write L DBxy.DBW xy SLD 3 LAR1 I...
Replies
3
Views
544
Back
Top Bottom