InewtotheboardandCoDeSys, butnottosoftware.
Hadasearchbutdoesn't appear to be anything relating to this.NowmyquestionisregardingFunctionBlocks, whichgenerallyneedaninstanceoftobeused(forreusability), nowcanIinitialisesomeinternalvariables/constantsforaspecificinstance? Andifso, How?
Thanks Anno
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Igor Petrov hat geschrieben:
1) You can do global initialization (for all instances). Example:
FUNCTION_BLOCK SyncSwitch
VAR_INPUT
bSync: BOOL := TRUE;
β¦
2) In the instances you can redefine the initialization:
SyncSwitch_1 : SyncSwitch := (bSync := FALSE);
3) You can use different direct variables in different instances. See in the manual.
Thanks, I assume this also applies to the VAR declaration block and not just VAR_INPUT?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
annodomini2 hat geschrieben:
Thanks, I assume this also applies to the VAR declaration block and not just VAR_INPUT?
IEC programmers are used to concentrate all parameters in inputs. Therefore in LD or FBD they connect external constants with the graphic box (FB instance) and get an easy to review and change diagram.
But if you consider it reasonable⦠Why not:
FUNCTION_BLOCK xz_xz
VAR_INPUT
bIn1:BOOL;
END_VAR
VAR_OUTPUT
bOut1:BOOL;
END_VAR
VAR
byVar1:BYTE:=0;
END_VAR
;
...
Declaration:
xz1 : xz_xz := (byVar1 := 1);
By the way, in CoDeSys you can use 'Actions' in FB = very useful feature. You could use it for a few 'smart initialization'. For example if you need to calculate something during the initialization.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Igor Petrov hat geschrieben:
By the way, in CoDeSys you can use 'Actions' in FB = very useful feature. You could use it for a few 'smart initialization'. For example if you need to calculate something during the initialization.
Sounds interesting, will read up on that, thank you.
So for example if you had an FB that read a specific CAN message from different sources, for a specific instance you could initialise the instance with the Device Id of a specific source and then at initialisation produce and store the entire message Id?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Without actions you need extra inputs for parameters or for change the behavior. As result FB looks like a hedgehog
With actions you can write: MyFB1.Stop(), MyFB1.Set_new_ID(), MyFB1.Run()β¦
Unfortunately FB has no a specialized automatic action for initialization (it is possible in SFC), but you could call any action only once for a special work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can't wait till we get 3.0, The limitaiton of this is that the Actions require the usage of the defined inputs for the type, rather than a 'Class' with methods/functions that operate on the instance data.
Real limitation of the language/system.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Igor can you elaborate slightly on your last post about actions with the example of myFB1.Run().. etc.. It sounds interesting but I am not sure I understand your point. Or we might be thinking of the same thing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
spfeif hat geschrieben:
Igor can you elaborate slightly on your last post about actions with the example of myFB1.Run().. etc.. It sounds interesting but I am not sure I understand your point. Or we might be thinking of the same thing.
Actions are required to use the function interface of the heading block.
In 99% of all other true object orientated languages procedures of the defining class can have a different function interface.
Does the method changes in 3.0 support this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Thanks Anno
1) You can do global initialization (for all instances). Example:
FUNCTION_BLOCK SyncSwitch
VAR_INPUT
bSync: BOOL := TRUE;
β¦
2) In the instances you can redefine the initialization:
SyncSwitch_1 : SyncSwitch := (bSync := FALSE);
3) You can use different direct variables in different instances. See Variable Configuration in the manual.
Thanks, I assume this also applies to the VAR declaration block and not just VAR_INPUT?
IEC programmers are used to concentrate all parameters in inputs. Therefore in LD or FBD they connect external constants with the graphic box (FB instance) and get an easy to review and change diagram.
But if you consider it reasonable⦠Why not:
FUNCTION_BLOCK xz_xz
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
END_VAR
;
...
Declaration:
xz1 : xz_xz := (byVar1 := 1);
By the way, in CoDeSys you can use 'Actions' in FB = very useful feature. You could use it for a few 'smart initialization'. For example if you need to calculate something during the initialization.
Sounds interesting, will read up on that, thank you.
So for example if you had an FB that read a specific CAN message from different sources, for a specific instance you could initialise the instance with the Device Id of a specific source and then at initialisation produce and store the entire message Id?
Without actions you need extra inputs for parameters or for change the behavior. As result FB looks like a hedgehog
With actions you can write: MyFB1.Stop(), MyFB1.Set_new_ID(), MyFB1.Run()β¦
Unfortunately FB has no a specialized automatic action for initialization (it is possible in SFC), but you could call any action only once for a special work.
Can't wait till we get 3.0, The limitaiton of this is that the Actions require the usage of the defined inputs for the type, rather than a 'Class' with methods/functions that operate on the instance data.
Real limitation of the language/system.
Igor can you elaborate slightly on your last post about actions with the example of myFB1.Run().. etc.. It sounds interesting but I am not sure I understand your point. Or we might be thinking of the same thing.
Actions are required to use the function interface of the heading block.
In 99% of all other true object orientated languages procedures of the defining class can have a different function interface.
Does the method changes in 3.0 support this?