You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 22nd, 2012, 11:36 AM   #1
Izabela
Member
United States

Izabela is offline
 
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
  Reply With Quote
Old January 22nd, 2012, 02:56 PM   #2
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 980
look at BTD instruction
the following is From 5000 Instruction Manual
Quote:
Description:

When enabled, the BTD instruction copies a group of bits from the Source to the Destination. The group of bits is identified by the Source bit (lowest bit number of the group) and the Length (number of bits to copy). The Destination bit identifies the lowest bit number bit to start with in the Destination. The Source remains unchanged. If the length of the bit field extends beyond the Destination, the instruction does not save the extra bits. Any extra bits do not wrap to the next word. If you mix integer data types, the instruction fills the upper bits of the smaller integer data types with 0s so that they are the same size as the largest data type.

Last edited by cwal61; January 22nd, 2012 at 03:07 PM.
  Reply With Quote
Old January 22nd, 2012, 03:27 PM   #3
Izabela
Member
United States

Izabela is offline
 
Join Date: Jan 2007
Location: United States
Posts: 27
Dog

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.
  Reply With Quote
Old January 22nd, 2012, 04:18 PM   #4
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 980
Address DINT to Bit levels. Use DINT.0, DINT.1, DINT.2... Instead of BOOL.
  Reply With Quote
Old January 22nd, 2012, 05:00 PM   #5
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,243
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
  Reply With Quote
Old January 22nd, 2012, 05:36 PM   #6
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 4,380
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.
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old January 23rd, 2012, 08:49 AM   #7
Izabela
Member
United States

Izabela is offline
 
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?
  Reply With Quote
Old January 23rd, 2012, 02:41 PM   #8
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 4,380
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.
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old January 23rd, 2012, 04:27 PM   #9
Doug-P
Member
United States

Doug-P is offline
 
Doug-P's Avatar
 
Join Date: Jun 2003
Location: Pa
Posts: 1,244
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...
  Reply With Quote
Old January 23rd, 2012, 04:41 PM   #10
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 4,380
Quote:
Originally Posted by Doug-P View Post
Might it work to XOR the array with itself?
No, you cannot use a BOOL Array as an operand to the XOR instruction...
Attached Images
File Type: jpg 2012-01-23_223849.jpg (20.5 KB, 570 views)
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old January 23rd, 2012, 04:45 PM   #11
TConnolly
Lifetime Supporting Member
United States

TConnolly is offline
 
TConnolly's Avatar
 
Join Date: Apr 2005
Location: Salt Lake City
Posts: 6,147
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.

CLEAR A[0] A[1] A[2] A[3] A[4] A[5] A[6] A[7]
--] [-----(U)---(U)---(U)---(U)---(U)---(U)---(U)---(U)---



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 04:54 PM.
  Reply With Quote
Old January 23rd, 2012, 04:56 PM   #12
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 4,380
Quote:
Originally Posted by daba View Post
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.
To be pedantic, and for clarity, i made a few typos in the post above. What i should have said was....

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)
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old January 23rd, 2012, 05:02 PM   #13
Kev77
Member
United States

Kev77 is offline
 
Kev77's Avatar
 
Join Date: Mar 2008
Location: Beaverton, Or
Posts: 395
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...
  Reply With Quote
Old January 23rd, 2012, 05:05 PM   #14
daba
Lifetime Supporting Member + Moderator
United Kingdom

daba is offline
 
daba's Avatar
 
Join Date: Jul 2004
Location: uk
Posts: 4,380
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.
__________________
___________________________
ControlLogix & SLC Training
a-b train ltd.
abtrain@tiscali.co.uk
www.abtrain.co.uk
tel: 07506 73 9999
nil illegitimi carborundem


  Reply With Quote
Old January 23rd, 2012, 05:29 PM   #15
TConnolly
Lifetime Supporting Member
United States

TConnolly is offline
 
TConnolly's Avatar
 
Join Date: Apr 2005
Location: Salt Lake City
Posts: 6,147
Quote:
Originally Posted by Kev77 View Post
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...
Its a perfectly legitimate question.

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 05:34 PM.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
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


All times are GMT -5. The time now is 05:07 AM.


.