Studio 5000, BSL, Questions about "Length"

So, AutomationTechBrian only wants to shift 5 bits of a DINT, leaving the remaining bits unchanged.

Well... at the point you start to recognize me, you can trim that down to just "Brian." :)

I think I'm going to just use BSR, then use the value of the array as a condition to cycle through another cycle: BitArray does not equal 0. Also, if the only values of the array are in the first two stations, the 5 minute timer can be used, versus the 15 minute timer for any other condition.

Beyond that, I've never used BTD for anything, so I'm looking forward to checking that out. But first, I realized that this would be the perfect project to get familiar with using SFC for the cycle routine of lifting the product up, moving over to the next bin, then returning to the home position. I've only programmed in ladder and FB, with a little ST for setting some values. Again, just like BSL and BSR, I've been waiting for something like this to get familiar with SFC.

My internet is still limited until tomorrow afternoon. Some of the videos I've wanted to check out are too difficult to follow on my phone. ...It's hard to see the values on the screen.
 
OK Brian it is then :)

I have just run a test with BSR, and the diagrams in the Instruction Help are incorrect. They show the bits to the left of the intended "shifted" area as unchanged. This is not true.

The text description says these bits are "invalid", just like the help for the BSR.

Both BSL and BSR shift the whole of the DINT, so "unused" bits will be damaged.

My solution above, where the shifting is done in a separate DINT Array tag, and the relevant bits are BTD'd back into the Data tag works for both BSL and BSR.

But do the 5 bits need to be shifted at all ? Could you not use indirect addressing, using a Pointer tag - value limited to the range of the bits you need to inspect.

Then you could simply increment or decrement the pointer, and use indirect addressing to see if the addressed bit is on or off.

2020-11-28_062014.jpg
 
I have just run a test with BSR, and the diagrams in the Instruction Help are incorrect. They show the bits to the left of the intended "shifted" area as unchanged. This is not true.

The text description says these bits are "invalid", just like the help for the BSR.

Both BSL and BSR shift the whole of the DINT, so "unused" bits will be damaged.
This confirms what what shown in the screen capture video in post #13 of this thread.



It makes sense: the code is compiled to machine code for the CPU, and I have never seen a CPU instruction that shifts only some of the bits of a "word," whatever a word means for that CPU.

My solution above, where the shifting is done in a separate DINT Array tag, and the relevant bits are BTD'd back into the Data tag works for both BSL and BSR.
It's neat that the BTD thing works (I was going to do it with bitwise instructions), but, like almost any other solution, that method has to save the bits in another DINT. So if the OP needs those other bits, then why not just put them in the other DINT to begin with and not fiddle around the the shift register?
 
It's neat that the BTD thing works (I was going to do it with bitwise instructions), but, like almost any other solution, that method has to save the bits in another DINT. So if the OP needs those other bits, then why not just put them in the other DINT to begin with and not fiddle around the the shift register?

I believe he's using a 32-bit word for direct his process, and 5 bits are used to choose timings or something, and those bits he wants to shift without compromising the rest of the word.

Anyway, whats an extra DINT with tons of memory to play with. It's been a long time since I worried about memory usage.

My solution means that any shifting is done outside his controlling data, which is kept updated by the BTD. I really like the instruction ...
 
Anyway, whats an extra DINT with tons of memory to play with. It's been a long time since I worried about memory usage.


LOL


That was exactly my point: why combine the shifted bits with the other 27 bits in the first place? All the BTD is doing is replicating the the high 27 bits (from the cache DINT) into the bits that the BSL/BSR keeps corrupting in the shift register DINT. Why bother putting those bits into the shift register DINT when they are already in the cache DINT?



Use two separate DINTs: one to keep the high 27 bits; the other as the shift register in its low 5 bits and who cares about its munged 27 low bits; and never the twain shall meet.
 
LOL


That was exactly my point: why combine the shifted bits with the other 27 bits in the first place? All the BTD is doing is replicating the the high 27 bits (from the cache DINT) into the bits that the BSL/BSR keeps corrupting in the shift register DINT. Why bother putting those bits into the shift register DINT when they are already in the cache DINT?

Perhaps that single DINT tag is passed down various processes, or may be produced for other controllers - I don't know, just suggested a way to do what requested 🍺
 
Perhaps that single DINT tag is passed down various processes, or may be produced for other controllers - I don't know, just suggested a way to do what requested 🍺


ah, my mistake, from the OP it appears they are interested in the five bits being shifted*, not the upper 27.


So while the BTD will work, so will many other options e.g.

  • Bit-wise AND of the array with a mask of 31 (0x1f), to zero out the upper 27 and keep the lower 5.
  • Unlatch bit 6 whenever control.EN is 1, so any bit that starts into the upper 27 is always 0.
  • And the actual solution that requires no extra steps, the the OP already found: use BSR instead.



* "... use the value of the Array to change which timer to use between cycles ..."
 
Quick question:
Can the length in a BSL be zero? And what does it actually mean, it would seem to me that it would make the BSL instruction to NOT shift any bits of the File Register.. Correct?
Thanks!
 
Thanks for your soon reply, and Yes.. in fact that's how I came up with the thought that it should not shift anything if Length is set to 0. As it says in the manual that Length is: "the total number of bits to be shifted by the BSL." Or: "Number of bits in the array to shift "..
But I have came across code in machines (faulty code btw), that uses 0 for Length.
I was looking more for a answer from someone who had used/seen it and actually know what it means. To me it seems like you should not use 0 for Length (although you can).
Thanks
 
Thanks for your soon reply, and Yes.. in fact that's how I came up with the thought that it should not shift anything if Length is set to 0. As it says in the manual that Length is: "the total number of bits to be shifted by the BSL." Or: "Number of bits in the array to shift "..
But I have came across code in machines (faulty code btw), that uses 0 for Length.
I was looking more for a answer from someone who had used/seen it and actually know what it means. To me it seems like you should not use 0 for Length (although you can).
Thanks

If the .LEN is hard-coded as 0, and not poked into the instructions control tag by other code, then I can only suggest it is done deliberately to set arithmetic status flags on the original data. If that's the case it seems a tricky way of doing so, should be easier ways ....
 
Thanks.. Interesting reply.. Although still not making sense to me.. I am fairly new to BSL.
I have used and seen many BSL with .LEN set to different values but they always make some sense. Yes,deliberately hard coded to 0.
I guess I will just restate my question as What does it mean for a BSL instruction that .LEN is set to 0??
Thanks again..
 
Thanks.. Interesting reply.. Although still not making sense to me.. I am fairly new to BSL.
I have used and seen many BSL with .LEN set to different values but they always make some sense. Yes,deliberately hard coded to 0.
I guess I will just restate my question as What does it mean for a BSL instruction that .LEN is set to 0??
Thanks again..

Check in the instruction "Help" to see under what conditions the arithmetic flags are set. It may start to make some sense.

The other possibility is they are using some "standard code" that they have just put in there, and it may be easier (as in faster, less memory) to do that than continuously range-checking the instruction's parameters.
 
I guess I will just restate my question as What does it mean for a BSL instruction that .LEN is set to 0??

Have you looked at the flow diagram logic in 1756-rm003?
According to this (see image below), it means the source bit value will be transferred to the <counter structure>.UL bit on every rising edge of the input rung (.EN pin), and the .UL bit will hold its value otherwise. I dunno but I imagine that could be useful. I am pretty sure it is equivalent to

IN .EN src .UL
--] [--[ONS]--+---] [--[L]--+--
| |
| src .UL |
+---]/[--]U[--+


OR
IN .EN ons
--] [--[ONS]--( )--

ons src .UL
--+--] [--] [--+--( )--
| |
| ons .UL |
+--]/[--] [--+

Untitled.png
 
Thanks for this one.. I will take it a deep look today, I guess I will find the answer to my question there.. Thanks for the pointer...
I trust that I can come back with more questions if any!!!
Much appreciated(y)
 

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,919
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,674
Hi everyone, I have an issue with installation of Studio 5000 33.00.02 DVD Media disc 2 with View Designer on Windows 11. After installation...
Replies
0
Views
63
Anyone have problems/solutions with Rehosting Studio 5000 to a new computer. Our IT department successfully Rehosted 2 laptops, but the other 2...
Replies
1
Views
114
Hi, I'm quite new to Rockwell PLC and currently trying to implement the following if Sw1 then for i:=1 to 20 by 1 do xEnable := 1...
Replies
4
Views
137
Back
Top Bottom