Host Engineering Forum

General Category => DirectSOFT => Topic started by: bowtie496 on December 13, 2018, 07:04:53 PM

Title: bit shift
Post 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. 
Title: Re: bit shift
Post by: b_carlton on December 14, 2018, 12:09:24 AM
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.
Title: Re: bit shift
Post by: alectek on December 14, 2018, 12:18:23 PM
Maybe you can try SHFL AND SHFR?

A binary 0000100000000 in which 1 is the location?
Title: Re: bit shift
Post by: b_carlton on December 14, 2018, 01:30:38 PM
SHFL and SHFR are great if 32 or fewer bits. A great suggestion.
Title: Re: bit shift
Post by: bowtie496 on December 14, 2018, 05:51:21 PM
thanks for the info, I will play around with it this weekend.