FC vs FB, DB

i didnt ignore it -> i didnt understand it - sorry 🍑

so please if possible can u clearify the difference between:
(a) for simple parameters and
(b) for complex parameters
thank uuuuuuuu
 
For the behaviour I am explaining the following are simple. Each of these variables is uniquely defined by a 32 bit area pointer. At the lowest level, an area pointer is always passed to an FC.

M0.0
MW10
I0.0
Q10.5
DBX10.0
L10.0

A fully defined DB reference cannot be stored in a 32 bit area pointer (it actually requires 48 bits) and so hence the following are complex

DB1.DBX0.0
DB10.DBW10

As these variables cannot be uniquely defined by an area pointer, the editor produces code that copies the variable into an area that can be uniquely defined by an area pointer. The area it uses for this purpose is the L area - the local temp area.

If you want to bottom out what is happening here, you need access to a plc or PLCSim.
 
You can use FC's for more than what you stated, you can create your own 'memory'.

For example, I have used FC's for motor control, I created a single DB to hold the pre-sets and status of all the motors in UDT format, on calling the FC, I pointed to the motors DB data area, within the FC transferred the data to the TEMP at the beginning and backk at the end.

It's up to you how you use them really.
 
Hellooooo,
i come to u again guys seeking wisdom :)

here is an FB that i'm including in my project and i want to clear my doubts once and for all...

Shifter1.GIF



DB200 & DB201 are assigned to FB200, and is been called twice from within an FC ...

my question is: if the TEMP "#X2maskON" is disengaged "ZERO" then the FB outputs:
  1. Q116.4, Q116.5, Q116.6, Q116.7 will be also turned off => YES/NO ???
  2. but the DB200.DBX6.0 (where 6.0 is one of the BOOL Outputs) will also turn to ZERO => YES/NO ???
thankxxxx ...
 
If the EN input to a block is false, the block is not called and hence any input/outputs from the block will not be processed - the same goes for an FC.

Change the view to STL and you will see a jump conditional around the call to the FB.
 
yes i understand, that means that the outputs WILL turn to ZEROs, YES/NO ???? confusioned & dont have means of testing ...

thank uuuu
PLEASEEEEEEEEEEEEEEEEEEEEEE
 
Last edited:
that means the FB & FC once they were called & their outputs status have changed. they will always keep their current state except if they were called again and the state have been changed from within the same FB or FC.

YES/NO ????

+ how to change the DB (variable within) after creation & linking ??? :(
 
Last edited:
mico207 said:
that means the FB & FC once they were called & their outputs status have changed. they will always keep their current state except if they were called again and the state have been changed from within the same FB or FC.

YES/NO ????

Yes all stay as they were expect for TEMPS. Logic in front of Enable is simply a conditional call. You can also control the ENO...but that's another topic.

Nick
 
yes, by the way i think its time has come as long as u mentioned it...

the ENO: when do i use it, & what does it reflects ???

ummm, also in changing the I/O's of an FB after it was made and linked to several DBs (DB instance in creation), also after FB was call from within the code ...
my question is what is the best/easiest way to change the I/O's without re-writting everything :(

thank uuuuuuuuuuu
 
mico207 said:
SUM UP:

------------



Hello, I’d like to put an objective sum up so everyone will benefit easily from this thread.

Properties / Difference – FC vs FB, DB…



  • FC: variables are passed by REF. (Pointers) which means any change of the value the same variable along the program will have an effect on the FC functionality.

  • This is not clear to me. What do you mean by along the program. Do you mean before the FC call? If a parameter is passed by address then what happens to that parameters value when it is changed within the FC?
    1. Can input parameters be changed by the FC so the value is changed when the FC returns?

    [*]FC: which also leads to – HAVE NO MEMORY – as it refers to variables whatever their value
    It would be best to say that FCs don't maintain a state or are stateless.
    Note, as pointed out, one can keep the state externally in a DB and pass a DB to the FC.

    • FB: where as FB is similar in nature but with additional options that give it its power.
    • FB: variables are passed by VALUE, which means whatever changes that happen to that variable in your program the FB will not sense it.

    • Are you sure about this? I don't think this is right. What would be the point of passing variables then.

      [*]FB: ex. same as what Mr. L D said: if u made and FB to add 2 numbers & return the sum (selected mathematical operation for simplicity) and u call it 2 successive time. 1st u passed 5 , 4 then the result is 9. 2nd time u passed only 1 value 6 (in the place of the 1st input) then the result will be 10.
      Can you pass a variable number of parameters? I don't think so.

      [*]FB: also have the amazing STAT variables which are used as memory. Example the M+ button that u find on ur calculator.
      [*]FB: DB, it is just an amazing concept – the DBs they have the inputs, outputs, In/Out, Stat variables stored in it and assigned to the FB.

      Stat variables are local to the FB. The IN and OUTs are not, they are global.

      PLEASE CORRECT ME IF ANY INFORMATION IS WRONG, NOT QUITE CLEAR OR NOT COMPLETE.
      Think about my questions above.

      I have never used multiple instance FBs. I just create duplicate DB and pass the DB number. When I do this I don't really need STAT variables either and can do what I want in a DB but Siemens makes it awkward to load DBs.

      I prefer SCL now. STL is painful. Too much mental energy is spent keeping track of all this ****. Where do you want to spend your mental energy? On using the tool or getting the job done?
 
Back
Top Bottom