I've learned how to pack an array with addresses so i can indirectly address them a use them in loops. the problem i have now is that i dont understand how to unpack the array to an output address.
example:
{putting stuff in an array}
CH0ReadDataArray AT %IW12 : ARRAY[0..127] OF BYTE;
WordArray : ARRAY[0..127] OF WORD
{pack Bytes into Words}
for i:0 to 127 do
WordArray[i]:=(BYTE_TO_WORD(CH0ReadDataArray[i])*256)+BYTE_TO_WORD(CH0ReadDataArray[i]);
end for;
Now how do i fill %QW406 through %QW469 with the contents of WordArray[0..127]??????
PS. i want to do this quickly and efficiently. i don't want to:
%QW406 := WordArray[0];
%QW407 := WordArray[1];
.
.
.
etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-06-19
Originally created by: scott_cunningham
Something like the code below should work. Double check that your pointer math is working correctly and you donβt go one too many points in the loop, etc.
hello, new to CODESYS.
I've learned how to pack an array with addresses so i can indirectly address them a use them in loops. the problem i have now is that i dont understand how to unpack the array to an output address.
example:
{putting stuff in an array}
CH0ReadDataArray AT %IW12 : ARRAY[0..127] OF BYTE;
WordArray : ARRAY[0..127] OF WORD
{pack Bytes into Words}
for i:0 to 127 do
WordArray[i]:=(BYTE_TO_WORD(CH0ReadDataArray[i])*256)+BYTE_TO_WORD(CH0ReadDataArray[i]);
end for;
Now how do i fill %QW406 through %QW469 with the contents of WordArray[0..127]??????
PS. i want to do this quickly and efficiently. i don't want to:
%QW406 := WordArray[0];
%QW407 := WordArray[1];
.
.
.
etc.
Related
Talk.ru: 1
Originally created by: scott_cunningham
Something like the code below should work. Double check that your pointer math is working correctly and you donβt go one too many points in the loop, etc.
Code not tested and from memory!
PS execution time is actually longer than if you explicitly list out all of the assignments like you donβt want to.