Inputs/Outputs to array

Hi I have 64 Inputs and 64 Outputs i would like to transfer to an Array or a Struct.

I’m thinking of transfer it to an Array [0..63] of BOOL fx. I cant connect the array to the process data from the module. I can connect it to a LWord, and then use LWord_to_Buf but it’s like it’s only takes the first byte? The function only do it once. It must be continuously? Any other/better solution?
buffer

Hello, what exactly are you trying to accomplish? Maybe accessing the LWord by the .X function already does the job for your usecase? myLword.X1:= myLword.X50;

myLword.B3.X2 := myLword.B4.X7;
What you expect to get is properbly
true in each element.
The Problem with the"to_Buf" approach is that memory wise a bool is recognised as a Byte. So it does not map myLword.X1 to ArrayElemt[1] but it maps myLword.B1 to ArrayElemt[1].

At this point you properbly know what needs to be done:
You need to create a function. that does LWORD_TO_MyINs and MyOuts_TO_LWORD.
there you map your IOs accordingly and it can be reused and easily debugged or ajusted if some of your wiring does change.

FB LWORD_TO_MyIN {
IN
StructStation1
Out:
LWORD
myLword.X1 := StructStation1.SomeUsefullName;
myLword.X2 := StructStation1.SelfDestruct;
myLword.X3 := StructStation1.AnotherUsefullName; …
}
Either this or you go with the “DI1.X1” ect. from the start where you give each Input a usefull “Function”-text.

I personally prefer option 1. where you map your IOs to some usefull struct.Name as this can be easily adopted and checked.

There also existis the topic of “memcopy” but this is something I do not recommend as there is alot of room for error.

I will try find out if there are plans for a Functionblock like “ANY_TO_BOOLArray” (i am not aware of that existing…) I hope this helps,
kind regards,
Oliver

Hi Oliver Thx. for the answer. i was just thinking of connecting a struct variable with 64 bool directly to the process data, for saving the time for making the FB, but i can see that it will be the easiest to make sure that it works.

I had made something similar in PcWorx, there is working but i cant remember it now. - Emil

You can also just transfer the digital inputs directly into the elements of an array of BOOLs, if you want. Annotation 2019 11 20 210236

Hey,

another method might be using the “GET_BIT” Function to dynamiyally assign your Input Data to an array.

ArrayofBool[AnotherIndexVar] := GET_BIT(yourWord,IndexOfBit); kind regrads,
Oliver