copy bit array

cjjeeper

Member
Join Date
Aug 2018
Location
Nowhere
Posts
71
I am having to manipulate MB data in a compactlogix 5380.
I need to copy the bit array from the TCP MB master into a matching bit array to use in logic and then be read by WW.


1024 bits in the BOOL array.



COP is throwing an error on data type. BOOL is not a valid data type for that instruction.


How can I do this? I don't see a file instruction where BOOL is a valid data type.
Thanks
 
Okay I will give that a try. I will follow up tomorrow and let you know if it works.


Thanks for the idea

I think there may be an instruction BTOD -- Binary TO Decimal that will do that so one can use a copy. I haven't used it in a while but I seem to recall that I had your exact problem. Hope this helps.
 
I think there may be an instruction BTOD -- Binary TO Decimal that will do that so one can use a copy. I haven't used it in a while but I seem to recall that I had your exact problem. Hope this helps.

Rockwell has a BOOL array to DINT array Add-on instruction available on their support site. This might be what saultgeorge is referring to. Access is open to everyone without a contract, but you do have to have an account (free to create).

https://rockwellautomation.custhelp.com/app/answers/answer_view/a_id/680320/loc/en_US#__highlight

It is setup to copy a BOOL[32] array to a DINT[1] array. You can step it up in 32 bit increments but you would have to edit the AOI logic.

They are basically brute force moving the bits which you could do yourself without the AOI.

OG
 
Rockwell has a BOOL array to DINT array Add-on instruction available on their support site. This might be what saultgeorge is referring to. Access is open to everyone without a contract, but you do have to have an account (free to create).

https://rockwellautomation.custhelp.com/app/answers/answer_view/a_id/680320/loc/en_US#__highlight

It is setup to copy a BOOL[32] array to a DINT[1] array. You can step it up in 32 bit increments but you would have to edit the AOI logic.

They are basically brute force moving the bits which you could do yourself without the AOI.

OG


yeah I could just do the MOV on an index and yes brute force it. I will look at the AOI. Might be worth it because although the array is 1024 we are only using probably 60 or so bits.
 
yeah I could just do the MOV on an index and yes brute force it. I will look at the AOI. Might be worth it because although the array is 1024 we are only using probably 60 or so bits.

You don't like the UDT method? Create a UDT with 1024 BOOL array, Create a 32 DINT array, one single COP will copy all BOOLS over to the DINT array.
 
used structured text..rips right through

Just ended up setting up a tmr and and then a TASK

@ 1250ms and doing this in structured text




if tmr_T1.DN then
for indexer:= 0 to 1023 by 1 do
TargetBOOL[indexer] := SourceBOOL[indexer];
end_for;
end_if;


That's my test code. Modify as appropriate. Mileage may vary.
 
You don't like the UDT method? Create a UDT with 1024 BOOL array, Create a 32 DINT array, one single COP will copy all BOOLS over to the DINT array.




I think your missed soumething. The source is from the Modbus AOI and is BOOL data type. As the Source that is not a valid data type for a COP.
 
Another way.

Rather than using a BOOL[1024] array, why not just use a DINT[32] array and reference the bits? You can still reference bit number 100 in such an array using the following (admittedly ugly) addressing:
    DINTArray[(Index AND NOT 31) / 32].[Index AND 31]
-------------------------| |----------------------------------


Coils work too.

Then you have access to all your favorite command: COP, FLL, FAL, BSL, etc., without getting that annoying "Invalid data type" error.
 

Similar Topics

Hi, done Cop(Copy) instruction but usually with DINT or INT in an array, but just happen an hour ago that I try to COPy an array of 380Boolian...
Replies
0
Views
2,085
We need to copy 32 bits from a REAL to a DWORD. We don't want any conversions done. We want a bitwise copy like the AB COP command. In GX Works...
Replies
0
Views
1,996
This is a carrie over from another thread I have going. Just figured I might get more hits with it being labled as ANY pointer. Other thread...
Replies
10
Views
3,812
I have 2 7cp476 plcs. How can I copy one of them and install it somewhere else?
Replies
0
Views
73
Hello Inside a FB, I´m trying to transfer a string from a DB to a IN_OUT var that was define as a UDT. The problem is that i can´t determine the...
Replies
4
Views
137
Back
Top Bottom