![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]()
|
New Here? Please read this important info!!!
![]() |
#1 |
Member
![]() ![]() Join Date: Jan 2007
Location: United States
Posts: 27
|
Logix 5000 instruction or method to clear / 0 out an array of bits
Is there any instruction or way to do this on a bool array.
I want to zero out all the bits in a bool array in my program. Thanks ![]() |
![]() |
![]() |
#2 | |
Member
![]() ![]() Join Date: Jan 2011
Location: NC
Posts: 906
|
look at BTD instruction
the following is From 5000 Instruction Manual Quote:
Last edited by cwal61; January 22nd, 2012 at 04:07 PM. |
|
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Jan 2007
Location: United States
Posts: 27
|
![]()
Thanks. I referenced that instruction, and it does not work with bool's. In fact it does not appear that any of the move, or clr, or .. . .instructions even work with word arrays.
Kind of dissapointing. Unless someone knows of a way. |
![]() |
![]() |
#4 |
Member
![]() ![]() Join Date: Jan 2011
Location: NC
Posts: 906
|
Address DINT to Bit levels. Use DINT.0, DINT.1, DINT.2... Instead of BOOL.
|
![]() |
![]() |
#5 |
Lifetime Supporting Member + Moderator
|
Second cwal61's suggestion. In logic you can do indirect, using '[]' to make it kind of like an array. If you don't alias the bit then you'll have to type int the bit number yourself from Factorytalk for a display reference.
__________________
Controlling outputs is the PLC's way of getting its inputs to change. www.thePLCguy.com |
![]() |
![]() |
#6 |
Lifetime Supporting Member + Moderator
|
If you have to use BOOL arrays, (you've already discovered they are pretty unfriendly!), there is a way out of your dilemma, but it will require some careful thought, re-coding, and re-testing !!!!
Make a UDT (User-Defined Data-Type) with one element of data-type BOOL[xxx], where xxx is the size of your BOOL array. Let's say you call the UDT "BOOLARRAY" Re-create the tags you have as data-type BOOL[xxx], to make them of data-type BOOLARRAY. Now your BOOL arrays are embedded in a "structure", and structures can be copied and filled using COP and FLL instructions. To reset your BOOL array, (let's say the tag is called MyData), simply fill the structure with 0, with a length of 1 (1 element, your embedded BOOL array) ..... FLL 0 MyData 1 For future reference, avoid BOOL arrays, but if you have to use them make the BOOL array part of a structured tag by creating a UDT.
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 nil illegitimi carborundem |
![]() |
![]() |
#7 |
Member
![]() ![]() Join Date: Jan 2007
Location: United States
Posts: 27
|
Don't need to use a bool array. I understand your technique here, thanks for that.
Perhaps you can comment on the lack of any instructions in this product that allow you to do anything with arrays, bool or word, other that shifting. To me its a Logic 500 instruction set inside a Logic 5000 which allows arrays, and tag names . ... . Does Rockwell add instructions ever for 5000? |
![]() |
![]() |
#8 |
Lifetime Supporting Member + Moderator
|
All of the "old faithful" SLC/PLC file handling instructions are present in Logix5000, like FSC, FAL etc.
Plus there are others like SRT, AVG, etc. But Logix5000 arrays are more than just SLC "data-tables". For instance you can make arrays of any data-type, including UDTs, and you can have (up to) 3-dimensional arrays.
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 nil illegitimi carborundem |
![]() |
![]() |
#9 |
Member
|
Might it work to XOR the array with itself?
__________________
Let's eat Grandma! Let's eat, Grandma! Words are very important, but punctuation saves lives... |
![]() |
![]() |
#10 |
Lifetime Supporting Member + Moderator
|
No, you cannot use a BOOL Array as an operand to the XOR instruction...
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 nil illegitimi carborundem |
![]() |
![]() |
#11 |
Lifetime Supporting Member
|
A Boolean is not the same thing as a B data type and you need to stop thinking of them as the same thing. The SLC B data is really just an integer and for all intensive purposes is the same as N data and in fact the two can be used interchangeably. N data can be used as bits and you can do math on B words. For the ControlLogix Boolean memory is allocated differently by the compiler and word instructions don't work on it. The compiler allocates a full 32 bit word for a stand alone boolean but it still may contain only boolean information and so word level instructions are not allowed. When you create an array the memory allocation is word optimized but the data type remains the same, meaning you may not use word level instruction on it.
If your array is small then a brute force unlatch is the simplest and fastest.
For larger arrays you may want to use a for/next loop to clear the array or define a UDT as Daba described. If you want to name the bits so that you can access them by word or as a named bit you can create a bit overlay. A bit overlay is an advanced topic and once you create it you cannot redefine it or modify it, but if you are interested there are some forum threads you can search for on how to do it.
__________________
True craftsmanship is only one more power tool away. That's the beauty of processors, they don't have emotions they just run code - The PLC Kid. Last edited by TConnolly; January 23rd, 2012 at 05:54 PM. |
![]() |
![]() |
#12 | |
Lifetime Supporting Member + Moderator
|
Quote:
Now your BOOL arrays are embedded in a "structure", and elements of structures can be copied and filled using COP and FLL instructions. To reset your BOOL array, (let's say the BOOL Array element is called MyData), simply fill the element with 0, with a length of 1 (1 element, your embedded BOOL array)
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 nil illegitimi carborundem |
|
![]() |
![]() |
#13 |
Member
|
Might be a dumb question but, what is the difference between a BOOL[32] and a single DINT? For whatever reason I have always used the DINT addressed at a bit level and never thought about using a Bool[32]. I had a coworker that was using a Bool[32] for a one shot array. I have always used the DINT. Would they consume the same amount of memory?
Sorry, I hope I am not highjacking the thread... |
![]() |
![]() |
#14 |
Lifetime Supporting Member + Moderator
|
Other logical and math operations on BOOL arrays are possible by COPying them into suitably sized DINT arrays, doing the operations on the DINT arrays, then COPying the modified data back. COP doesn't worry about data-type, it is simply a bit-copier, so each 32 bits of your BOOL array will lay into successive 32-bit words of the DINT array.
Just remember that the Length specified in the COP instruction is the number of elements of the destination tag. Be careful with this. Instructions that address array tags will not go beyond the destination tag boundaries, but if the destination is a member of a structure, a bad Length parameter will cause following members of a structured tag to be stomped on. Ask if you want to see a practical example of this. It all gets messy, but a lot can be done this way.
__________________
___________________________ ![]() abtrain@tiscali.co.uk www.abtrain.co.uk tel: 07506 73 9999 nil illegitimi carborundem |
![]() |
![]() |
#15 | |
Lifetime Supporting Member
|
Quote:
I usually define a Boolean array called OneShots[64] in my projects. But I only use that for one shot storage bits. For most other Booleans I prefer to use stand alone tags. I've never had a memory limitation problem from doing that and a boolean tag named Process_Ready is a lot more clear than B[19]. Boolean arrays should be defined in 32 bit chunks (In fact I think if you try to make it smaller the compiler will change it for you). Bool[32] and a single Dint will occupy the same space in memory. However they are fundamentally different kinds of data as far as the compiler is concerned and that affects how you can use them. If you ever want to use any math instructions or bitwise manipulation instructions that work on words (eg, CLR, AND, NOT, XOR, ADD, SUB, etc) then use a DINT instead of Bool[32].
__________________
True craftsmanship is only one more power tool away. That's the beauty of processors, they don't have emotions they just run code - The PLC Kid. Last edited by TConnolly; January 23rd, 2012 at 06:34 PM. |
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ALMA instruction help (RS LOGIX 5000) | dginbuffalo | LIVE PLC Questions And Answers | 1 | October 27th, 2011 11:41 AM |
rslogix 5000 instruction help | md.abdullah | LIVE PLC Questions And Answers | 16 | September 25th, 2011 11:02 PM |
RS logix 5000 array question | dsg | LIVE PLC Questions And Answers | 4 | September 21st, 2011 07:59 PM |
Shifting an array in Logix 5000 | shoelesscraig | LIVE PLC Questions And Answers | 11 | January 13th, 2011 02:30 PM |
Clear Logix 5000 FBC.IN bit | bulletin blues | LIVE PLC Questions And Answers | 2 | July 31st, 2008 05:33 PM |