Studio 5000, BSL, Questions about "Length"

AutomationTechBrian

Lifetime Supporting Member
Join Date
Jul 2013
Location
St. Cloud, MN
Posts
669
Sidenote: One of my favorite lessons back in school was learning about BSL in RSLogix 500, and making it work in a simulator. I've been waiting about 11 years for the opportunity to use it... and here it is! But I'm having trouble with it.

I made a test routine to play around with it in Studio 5000, v32. I only need 5 bits, so my array size is 1. I can't find the help file for "Control" data type, so I just created the test "control" tag and left it blank. I tied the "Source Bit" to a switch using a local input. And I only need 5 bits for the "Length". I put an XIC contact on that rung, and tied it to another local input. Then I tried it out. It seemed to work great... until I found that it kept writing to the DINT after I passed the 5th bit. I'm going to use the value of the Array to change which timer to use between cycles, and I expected the values to drop off after the 5th bit. What am I doing wrong? I tried a BSR, and that works great... starts at the 5th bit and works down to 1 and drops off. I believe I should be able to have BSL drop values beyond the 5th bit as well. What am I doing wrong?

I have limited internet for a couple more days, which is frustrating for trying to research things like this.
 
Sidenote: One of my favorite lessons back in school was learning about BSL in RSLogix 500, and making it work in a simulator. I've been waiting about 11 years for the opportunity to use it... and here it is! But I'm having trouble with it.

I made a test routine to play around with it in Studio 5000, v32. I only need 5 bits, so my array size is 1. I can't find the help file for "Control" data type, so I just created the test "control" tag and left it blank. I tied the "Source Bit" to a switch using a local input. And I only need 5 bits for the "Length". I put an XIC contact on that rung, and tied it to another local input. Then I tried it out. It seemed to work great... until I found that it kept writing to the DINT after I passed the 5th bit. I'm going to use the value of the Array to change which timer to use between cycles, and I expected the values to drop off after the 5th bit. What am I doing wrong? I tried a BSR, and that works great... starts at the 5th bit and works down to 1 and drops off. I believe I should be able to have BSL drop values beyond the 5th bit as well. What am I doing wrong?

I have limited internet for a couple more days, which is frustrating for trying to research things like this.

Sounds to me like you need to get acquainted with the Logix/Studio 5000 "Help".

Program a BSL or BSR instruction (you don't need to supply parameters), highlight the instruction name (BSL, BSR, etc.) and hit F1 on the keyboard, which takes you immediately to the Help on that particular instruction.

I have never known an inbuilt instruction to not perform exactly as the "help" states. Perhaps your problem is worded confusingly....


From what you have stated, this does seem to go against what the Help says, perhaps I need to read it a few more times to digest ....

2020-11-26_220905.jpg
 
I used the help file to build my test. That's why I'm so confused with it not working the way it says it would. I thought this would be a simple question to get answered on the board. Maybe I'll go for a drive with my laptop later on and find a Wi-Fi connection and post a screen print.
 
Logix works in units of words i.e. 16* bits. So when it shifts the bits to the left, it shifts 16* at a time, even if the code is only interested in the rightmost, and control.Length is, five. The bits do stop moving at bit 15, the 16th bit.



The meaning of control.Length is to locate which bit is transferred to control.UL.


* 16 is my experience with MicroLogix (RSL500); with the ControlLogix/CompactLogix it could be different i.e. 32 as you seem to suggest.
 
Read carefully into the help, and especially understand the diagrams....

It specifically states that bits beyond the shifted data are "invalid", which indicates to me that they are indeed shifted along with the other bits, so the data within them cannot be used. The LEN spec simply dictates which bit is UnLoaded to the destinatin.

If you only need to shift a specific number of bits in a 32-bit DINT, then you could BTD those bits into a temp DINT, do the BSL on the temp, then BTD the result back into the original data
 
Last edited:
...it could be different i.e. 32 as you seem to suggest.


Logix5000 is 32-bit biased, the smaller integer data-types simply use a 32-bit memory location, positioning the sign bit at bit 15 for an INT, or bit 7 for a SINT
 
Read carefully into the help, and especially understand the diagrams....

It specifically states that bits beyondthe shift pattern are "invalid", which indicates to me that they are indeed shifted along with the other bits, so the data within them cannot be used.

Yeah, I thought about that, too. But how lame is that? When you see BSR working it makes you question why it goes beyond the 5th bit.

I can make BSR work, but it seemed like it should work with BSL as well.
 
Yeah, I thought about that, too. But how lame is that? When you see BSR working it makes you question why it goes beyond the 5th bit.

I can make BSR work, but it seemed like it should work with BSL as well.

I will investigate further, but I doubt I will ever catch the Help descriptions, flowcharts, and the example diagrams out.

For "Invalid" bits, read "Not what they were before" - the instruction has invalidated them ....
 
The term for what I'm looking for is the "unload." I'm watching Youtube videos, hoping to find the answer why it's not "unloading" after the 5th bit. Hopefully, I'll find more answers to my "control" data type.
 
The term for what I'm looking for is the "unload." I'm watching Youtube videos, hoping to find the answer why it's not "unloading" after the 5th bit. Hopefully, I'll find more answers to my "control" data type.

Not sure what you mean that "it's not unloading after the 5th bit", can you reword the problem ?

The "Control" data type is basically inherent in all file arithmetic, search, and manipulation instructions, and very rarely do you need to modify its data, it's just there to keep track of things ....
 
Well... I misunderstood what to expect. Here's a video: https://youtu.be/C35Ognh9e7w

He's using Logix 500, but the instruction is the same. It's just 16 bits versus 32 bits. For my purpose, it looks like BSR is the easier instruction to work with when I'm using the Array value to select which timer to activate. Thanks for responding, guys.
 
The "Control" data type is basically inherent in all file arithmetic, search, and manipulation instructions, and very rarely do you need to modify its data, it's just there to keep track of things ....

Ok, that's helpful. You're saying its like my one-shots... I give it an unique address, but it's just for keeping track internally. There are no values to change.
 
You've already seen this in another video, but I put it together so here it is:The point is that bit-shifts happen between word boundaries (16-bit for MicroLogix, 32-bit for C*Logix), even if the control.Length is not an integer multiple of 16 or 32.


N.B. if the code uses a BSR (Bit Shift Right) instead of a BSL (...Left), it will still be shifting bits that are to the left of the control.Length point, so even with a BSR the code cannot use the bits from control.Length to the next boundary to the left for anything.


Update: okay, it was easy so I made the BSR example as well:P.S. another thing to note is that, even though the array in my examples is array of 32-bit DINTs, the bit shift still occurs between 16-bit boundaries.
 
Last edited:
One thing that is confusing to some people is that the .LEN value of the CONTROL tag is not the length of the shift register at all, but it is simply the pointer to the bit address that is copied into the .UL bit in the CONTROL tag.

In the pictures attached, you can see that the bit loaded doesn't reach bit 5 of the shift register until it has been shifted 6 times. That means that the "length" of my shift register is 6 : bits 0 thru 5.

I continued to shift, watching the single bit marching up the first DINT, so any usable data in bits 6 to 31 gets destroyed.

I needed 32 shifts to get my "Data_In" into bit 31 of the first DINT. Another shift did not shift the Data-In bit into bit 0 of the second DINT, that will only occur if the .LEN is greater than 31

Starting Position.jpg After 1 shift.jpg After 6 Shifts.jpg After 32 Shifts.jpg
 
So, AutomationTechBrian only wants to shift 5 bits of a DINT, leaving the remaining bits unchanged.

One solution would be to perform the shift on another DINT then put only the bits you wanted to shift back into the original DINT, without upsetting the other bits.

BTD instructions will do that for you easily ...


In the attached picture I have done exactly that, plus I have wrapped it to create a circular shift, by mapping bit 4 of the shifted DINT back to the Data_In of the BSL.

You can see that temp_DINT[0] is happily shifting bits beyond where I wanted to, but that doesn't matter, because the BTD is only updating bits 4 to 8 (5 bits) of my data word.

2020-11-27_082752.jpg
 

Similar Topics

I feel like I'm circling back to a very newbie question, but am genuinely curious. I'm using a BSL on a DINT for a length of 14 bits. For some...
Replies
2
Views
1,922
So I used the migration tool for converting RSlogix 500 to Studio 5000 and the resulting came out. See attached png files. I am having trouble...
Replies
10
Views
3,684
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
1
Views
38
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
3
Views
84
I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
49
Back
Top Bottom