# LabVIEW

cancel
Showing results for
Did you mean:

## Count the number of revolutions a knob makes

New to Labview. I have been looking to create a program that counts the number of times the knob passes zero.  Just needs to be simple.  I can't seem to figure it out.

Message 1 of 11
(3,202 Views)

## Re: Count the number of revolutions a knob makes

Hi Creepy,

counts the number of times the knob passes zero.

Translation of the problem:

When does the "knob pass zero"? Answer: when the sign of the knob value changes…

You need:

- a shift register to hold the previous knob value (or sign)

- a comparison of previous sign with current one

- when the result is "has changed" you need to increment a value, stored in a 2nd shift register

So how far you get!

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(3,195 Views)

## Re: Count the number of revolutions a knob makes

Does your knob count up to a maximum value then restart at zero if you keep "turning it clockwise" and count down to zero and reset to maximum value when "turning it counterclockwise"?

Seems to me you just need to count the number of times the knob=zero.

========================
=== Engineer Ambiguously ===
========================
Message 3 of 11
(3,173 Views)

## Re: Count the number of revolutions a knob makes

@Creepy wrote:

New to Labview. I have been looking to create a program that counts the number of times the knob passes zero.  Just needs to be simple.

The question is not well defined, because we don't know where zero is (are there positive and negative position or is it e.g. 0..10). Do you need to distiguish the direction of passing through zero? What should happen if it goes to zero but then reverses rotation?

Just counting revolutions can be done using "unwrap phase ptbypt" as follows, but it is not clear if this is what you want.

Message 4 of 11
(3,170 Views)

## Re: Count the number of revolutions a knob makes

@RTSLVU wrote:

Seems to me you just need to count the number of times the knob=zero.

That would only work for integers. we don't even know the datatype yet. 😉

Message 5 of 11
(3,166 Views)

## Re: Count the number of revolutions a knob makes

I don't think I know how to make a multi-turn Knob control!  I tried doing this with an Integer Control, but if it counts 1 through 10, it stops at 1 and 10 (I didn't spend a lot of time poking around with this, thought it was prudent to ask for help ...).

Bob Schor

Message 6 of 11
(3,119 Views)

## Re: Count the number of revolutions a knob makes

@Bob_Schor wrote:

I don't think I know how to make a multi-turn Knob control!

Also don't forget this option (checked by default), although it seems to be ignored if the scale covers the full 360 degrees.

Also note that the subject and question contradict: count revolutions is not # of zero passes. You can pass zero an infinite number of times without ever doing a full revolution. 😉

There are also these old discussions that can easily be found 😉

Message 7 of 11
(3,115 Views)

## Re: Count the number of revolutions a knob makes

Hmm -- I'll try again, but I did see the "Lock" entry and though I unchecked it (but I may have had an 11-value Knob, 0 .. 10, with 0 and 10 overlapping, silly me).  Ah, with a Knob with 10 values, it (as perhaps should have been expected) will do multi-turn fine with Lock Needle turned off.  However, its value is still restricted to 1 .. 10 (despite trying to mitigate it by Data Entry Limits), forcing the Implementer to recognize multi-turn values.  [Note -- I tested this with LabVIEW 2018 and an I32 Knob].

Bob Schor

Message 8 of 11
(3,099 Views)

## Re: Count the number of revolutions a knob makes

Yes, counting turns needs to be done in software, e.g. as in my ptbypt solution above or in the linked discussion.

(I won't mention xcontrols ... Oops, I just did ;).)

Message 9 of 11
(3,097 Views)

## Re: Count the number of revolutions a knob makes

@Bob_Schor wrote:

Hmm -- I'll try again, but I did see the "Lock" entry and though I unchecked it (but I may have had an 11-value Knob, 0 .. 10, with 0 and 10 overlapping, silly me).  Ah, with a Knob with 10 values, it (as perhaps should have been expected) will do multi-turn fine with Lock Needle turned off.  However, its value is still restricted to 1 .. 10 (despite trying to mitigate it by Data Entry Limits), forcing the Implementer to recognize multi-turn values.  [Note -- I tested this with LabVIEW 2018 and an I32 Knob].

Bob Schor

You need to be able to turn it up to 11 Bob, its one louder.