CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

addressin an array of byte containing bits of type bool
https://forum.codesys.com/viewtopic.php?f=1&t=9301
Page 1 of 1

Author:  cuiblie [ Wed Nov 14, 2018 10:35 am ]
Post subject:  addressin an array of byte containing bits of type bool

HELLO guys
I'm working with a module containing an ASI_MASTER_(1or2).
It contains an ASI_(1or2)_binaryIO, Itself containing ASi INPUT bin and ASi Output bin.
Inside i have the address %IB1 of type ARRAY[1..31] OF BYTE.

INPUT :
So %IB1 contains bits %IX1.0...%IX1.3 of type BOOL,
%IB2 contains bits %IX2.0...%IX2.3 of type BOOL
and so on up to 31.
OUPUT:
Same way as the INPUT expect : %QB1.........%QB31.
%QX1.0......%QX1.3
Question : My code looks like this;
For idx := 0 to 31 do
case idx of
1 : IF %IX1.0 = TRUE THEN
%QX1.0 = TRUE
end_if
IF %IX1.1 = TRUE THEN
%QX1.1 = TRUE
end_if
2 : IF %QX1.0 = TRUE THEN
%QX1.0 = TRUE
end_if
IF %QX1.1 = TRUE THEN
%QX1.1 = TRUE
end_if
.
.
.
31 : ...................
END_IF
idx := idx + 1;
end_case
end_for
The program works correctly. But i want to know if there is another method that will allow me to not copy the same thing 31 times.
I hope I have been clear enough.
Thank you

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/