can i define array fb instance in unity pro

qikuidg

Member
Join Date
Feb 2007
Location
shenyang
Posts
29
in unity ,every time when i call a fb,it makes a instance of this fb,i want to define an array instance of a fb,but i don't know if it's permitted ?
 
Yes, I think so ...
I don't understood what you want to do exactly, but I will try to help you.

For example calling a mulitiinstance FB:

CALL FB 50 , DB50
Timer1 :=T1
Input1 :=IW1
ParamSet :=DB100 <---- this is permitted
Output1 :=MD100
Error1 :=MW200
NOP 0

In FB50 ParamSet is declared as Block_DB (1 word, in other words - by ref)
Please don't forget use AR2 in your FB code if it is needed. So:

TAR2
LAR1 P##Input1
+AR1
L W[AR1,P#0.0]
T to an [0..15] local bit array, for example.

absolute address of Input1 = area-crossing pointer + area-internal pointer

OPN #ParamSet

// DB100.DBW0 --> DB50.DBW0
L DBW0
T DIW0

// DB100.DBW0 --> DB50.DBW0 indirect
L DW#16#0
LAR1
L DBW [AR1,P#0.0]
L DW#16#0
LAR1
POP
T DIW [AR1,P#0.0]

here area is specified by "DB" or "DI" chars.
 
Last edited:
qikuidg said:
in unity ,every time when i call a fb,it makes a instance of this fb,i want to define an array instance of a fb,but i don't know if it's permitted ?
What do you want to do?
To use an instance a lot of times?
Or create a lot of instances and put them into array?
Why do you need an array of instances? What for?
 
yes,i want to create a lot of instances and put them in one array? everytime when i call a fb,it makes an instance with a name efb_*,i want to change the name in order to make its meanning clearly.but it's terrible for me to change the name everytime,so i think maybe i can create an array ,when i call a efb in my program,i'll call the instance in this efb array,but i don't know how to do.
 
qikuidg said:
yes,i want to create a lot of instances and put them in one array? everytime when i call a fb,it makes an instance with a name efb_*,i want to change the name in order to make its meanning clearly.but it's terrible for me to change the name everytime,so i think maybe i can create an array ,when i call a efb in my program,i'll call the instance in this efb array,but i don't know how to do.
Ok, I understand. You create a lot of instances and they are automatically named as "FBI_0, FBI_1" etc., but you want to call them, for example, ENGINE_0, ENGINE_1 etc.
I recommend you to create all instances, then export project to a XEF file. XEF is a XML-file with UTF-8 encoding. Than you can open it with any text editor and replace "FBI_" to anything you like (for example, to ENGINE_). Good luck!
 
Schtiel said:
Ok, I understand. You create a lot of instances and they are automatically named as "FBI_0, FBI_1" etc., but you want to call them, for example, ENGINE_0, ENGINE_1 etc.
I recommend you to create all instances, then export project to a XEF file. XEF is a XML-file with UTF-8 encoding. Than you can open it with any text editor and replace "FBI_" to anything you like (for example, to ENGINE_). Good luck!

thanks for the answer,in fact,i want to make a cycle by for..end_for syntax .in every circle,i want to call a dfb and pass the parameters by array,if i can't build an dfb array,i don't think my idea will be succeed,i have to write these sentences one by one,maybe someone will have some good ideas?
 
qikuidg said:
thanks for the answer,in fact,i want to make a cycle by for..end_for syntax .in every circle,i want to call a dfb and pass the parameters by array,if i can't build an dfb array,i don't think my idea will be succeed,i have to write these sentences one by one,maybe someone will have some good ideas?
Post here the part of your code where you want to use a dfb array. Imagine that arrays are allowed. Then your idea will be clear and we'll try to suggest a solution.
 
Schtiel said:
Post here the part of your code where you want to use a dfb array. Imagine that arrays are allowed. Then your idea will be clear and we'll try to suggest a solution.

FOR pid_count :=1 TO 7 DO
PIDFF_0 (PV := ai_toreal[pid_count],
SP := ao_toreal_a[pid_count],
FF := 0.0,
RCPY := 0.0,
MAN_AUTO := mau[pid_count],
PARA := para[pid_count],
TR_I := 0.0,
TR_S := 0,
OUT := ao_toreal[pid_count],
OUTD => ao_toreal_absolute[pid_count],
MA_O => common_bool[pid_count],
INFO => info[pid_count],
STATUS => common_word[pid_count]);
END_FOR ;

i don't know if pidff_0 could be replace with pidff_[pid_count].
 
No, you can't create an array of PIDFFs.

Array in Unity can contain:
1) elementary data (EDT), for example:
- BOOL;
- UINT;
2) derived data (DDT) such as:
- WORD tables;
- structures.

PIDFF is a complex type and can't be used as an array element.
 

Similar Topics

hello dear forum, About DELTA DIAView SCADA I defined a variable in Timescript VBscript I want access this variable from within a window For...
Replies
0
Views
585
Hello PLCS.Net! I have the EDS Hardware Installation Tool installed on my PC. When I try to install a file, It says it's successful, the...
Replies
2
Views
2,032
Hi all, I want access a Mitsubishi PLC Q series to SMC. I am using Archestra DASMTEthernet as my server in SMC to connect with PLC. After I...
Replies
0
Views
1,405
Hi, I was wondering if anybody can help me with this issue. I have *.cab backup created from a lower version (Dev Studio 2012R2) and I loaded it...
Replies
8
Views
5,358
Hi Guys, I searched throughout the forums but didnt find any information on this topic. I currently have an application that relies on macros...
Replies
0
Views
1,613
Back
Top Bottom