Host Engineering Forum
General Category => DirectSOFT => Topic started by: bowtie496 on December 13, 2018, 07:04:53 PM
-
How do I do a bit shift in dirctSOFT? I have a prox sensor on a crane need shift left in one direction then right in the other direction. So I can keep track of location.
-
There is no single instruction which allows both left and right shifts. The SR instruction direction of shift is controlled by the order of the two operands.
I haven't tried this but you might try two SR commands, One with the operands ascending (eg C0 - C17) and the other descending (eg C17 - C0). I don't have a system to test this on so try it yourself and get back.
I think of this because of the Allen Bradley SLC line of creating an Up/Down counter. Two counter instructions, an Up counter and a Down counter are used both using the same counter number.
-
Maybe you can try SHFL AND SHFR?
A binary 0000100000000 in which 1 is the location?
-
SHFL and SHFR are great if 32 or fewer bits. A great suggestion.
-
thanks for the info, I will play around with it this weekend.