I have the product line as mentioned above. I have 4 types of drive devices and 2 types of IO devices.
Please note that the number of each device may vary as per my PLC configuration.
I wish to declare in my program a global variable as below:
device : Array [1..MAX_NO_OF_DEVICE] of Device ;
Is it possible that I can assign an individual type of device to the indexed element.
device is (Drive > Type1)
device is (Drive > Type4)
device is (Drive > Type3)
device is (IO > Type2)
device is (IO> Type1)
no impossible as a declaration is not dynamic.
however you can compile it with a variable in the compile list.
Yes this is very possible indeed using the new OOP features in V3:
Create a interface called IDevice and add a method Update to that interface (and the other methods you'd need ) and then create a few function blocks implementing the interface and the interface methods.
FUNCTION_BLOCK FB_Drive1 IMPLEMENTS IDevice
Devices: ARRAY[0..9] OF IDevice;
FOR I:= 0 TO 2 DO
your suggestion sounds interesting but i still wasn't succeessfull getting this to run. I'm afraid I havn't understood the example. Could you please explain this a little bit more?
Log in to post a comment.