Showing results for 
Search instead for 
Did you mean: 

Signed int8 overflow logic in knob

Go to solution

I want to make logic for a continuous rotating knob where a person can rotate it as many times he wants in either of the directions(clockwise @ anti-clockwise), the logic of knob is:


In clockwise direction:

1 full rotation is equal to 32 value(value starts from 0) and by rotating it for the second time it should count after 32 (like 33,34,35....64,65,66......,127) till 127, once it reaches 127, if we rotate it more it should start counting from -128 (like -128,-127,-126....) till 0, then from 0 again it should go to 127 then again -128 to 0 and this should be in an infinite loop and user can rotate the knob as much as he wants.


(0,...,32,....,64,....,96,.....,127,-128,.....,-96,.......,0,......32 and so on)


In anticlockwise direction:

1 full rotation is equal to 32 value and by rotating (value starts from 0) but the count goes like 0 to -128 then post that if we rotate it more it should go to +127 and move back to 0  and then again till -128 and so on.


(0,......,-32,......-128,127,......0,.....-128,127,..... and so on)






0 Kudos
Message 1 of 6

Since this is I8, it will automatically wrap at the boundaries, and all you need is something similar to what has been discussed long ago here. Let me find the thread..

0 Kudos
Message 2 of 6

Am I correct that the Knob doesn't need any "numeric" values, i.e. it can have 32 otherwise-unmarked "scale lines", with any of the 32 numbers representing 0?  [Alternatively, 0 could be the top-most line].  Your logic is that if you go to the "next" scale line to the right, the number goes up by one, and if you rotate left, it goes down by 1.  I trust you recognize the "Representation" of the values of this dial, which goes from -128 to 0 to 127 (if not, read @Altenbach's reply).


Have you tried making such a Dial control?  It can be a little tricky getting the dial to "look right".  You know you don't want to show "numbers" on the dial itself (that gets messy when you cross the N mod 32 = 0 value (i.e. crossing 0, 32, 64, etc. in either direction), so you'll want to turn "numbering" off (and may also want to turn the little "tick marks" off).  You also want to use the whole 360 perimeter of the dial, so you need to (a) put 0 at the top, and put 31 (not 10!) just to the left of this.


Do you know how to "edit" the appearance of Controls, using their "Properties" page?  There are several "cursors" that let you set the top value, rotate the scales (so 0 is on top), and move the "last value" next to the first.  You might find it easier to do this if you enlarge the control by, say, 50% ...


When doing a task such as this, where you are learning about a Controls properties, it is always a good idea to write a little LabVIEW program to test things out.  So you have edited an I8 control so that 0 is on top, there are tick marks (32 of them) all around the perimeter (with no empty spaces), and you want to see "what happens".  How do you know the "value" of the Control?  (Can you say "numeric indicator"?)

You'll also want the Control and Indicator inside a While Loop so you don't have to push the "Start" button each time.


Ha, ha -- I bet you already tried something like this, and are trying to trick some LabVIEW Champions into saying something really stupid (fortunately, I did the little test I described in the previous paragraph, only to discover that in LabVIEW 2021, this cannot be done with the standard LabVIEW Numeric Controls.


Or so it seems to me.  I'm prepared to take my punishment if I'm wrong about this ...  I'm trying to figure out a clever way of getting around this design limitation -- ah, yes, two (almost) identical controls.  We use one when the dial is in the upper semicircle, and the other when the dial is in the lower semicircle, switching them as you rotate out of one half-circle and into the other.  [Wow, this is getting complicated ...  I hope @Altenbach can come up with a more clever way to do this -- I'm going to stop here].


Bob Schor




0 Kudos
Message 3 of 6

Also don't forget to uncheck "Lock at max/min"




0 Kudos
Message 4 of 6
Accepted by topic author Spectra235

See if this works for you... (You can change the "scale...start" to any angle you like, of course)




Message 5 of 6

Yeah, this is exactly what I was looking for, just need to do some changes. Thanks a lot for helping me out.

0 Kudos
Message 6 of 6