LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How might I implement a rotary encoder knob?

Hi.  Many of you are probably familiar with the rotary encoder knob on most of today's test equipment.  Typically, the knob increments/decrements the count on whatever function is currently "active".  This is a panel space-saving technique that has proven useful on smart devices (e.g. test equipment) for a few decades now. 

I wonder if anybody has a workaround to implement such a control knob.  As far as I can tell, using standard numeric dial or knob controls, the user is limited to minimum and maximum values.  I'd like to build a control that:

1) allows continuous turning of the knob and output positive or negative integers as a function of the speed and direction (CW/CCW) it is turned, and
2) can be operated by the mouse scroll wheel

I suspect most users will prefer the latter control method.

thanks for any ideas

calvin
0 Kudos
Message 1 of 14
(7,479 Views)

Hi calvinf15,

I'm not sure I understand what you are looking for...

Are you looking for some way to update a numeric control on a CVI User Interface when the user scolls the mouse-wheel?

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 2 of 14
(7,451 Views)
Hi Jervin.

I'd really like a control that looks like a knob or dial.  Unlike a standard CVI knob/dial numeric control, the user could rotate continuously in either direction (no stop at a min or max value).  The knob would control a counter variable that either increments or decrements at a rate proportional to the "speed" the knob is turned. 

Of course, I'd expect that many users might get tired of the "circular action" they'd have to make with the mouse to operate the control, and that is where I'd expect that the mouse scroll wheel would be a welcome input device.  It would still be nice to see the knob move during this action though (but not critically necessary).

Many such knobs are implemented in firmware using a mapping that increments/decrements much faster as the knob is rotated faster (non linear or acceleration).

Is it possible to just set up a numeric indicator display and just operate it using the mouse scroll wheel?  I suppose that would be sufficient, but not as asthetic as a big knob.

thanks
Calvin
0 Kudos
Message 3 of 14
(7,443 Views)
These
0 Kudos
Message 4 of 14
(7,432 Views)
Hi calvinf15,
 
You can catch the EVENT_MOUSE_WHEEL_SCROLL event in the Panel Callback, something like:
 
case EVENT_MOUSE_WHEEL_SCROLL:
     GetCtrlVal(paneltest, PANELTEST_NUMERIC, &count);
     if (eventData1 == MOUSE_WHEEL_SCROLL_UP)
           count += eventData2;
     else if (eventData1 == MOUSE_WHEEL_SCROLL_DOWN)
           count -= eventData2;
     SetCtrlVal(paneltest, PANELTEST_NUMERIC, count);
   
     break;
 
You can find more information about the EVENT_MOUSE_WHEEL_SCROLL event in the CVI Help.
Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 5 of 14
(7,408 Views)
I took a crack at this. I am attaching my code. Enjoy.
Download All
0 Kudos
Message 6 of 14
(7,401 Views)
Thanks Mohan -

I see what you are doing with the source code - looks like it will work nicely!  I can't open the .uir because I'm using my laptop and have not had the chance to update it from 8.0 to our new 8.5 version.  I can do that when I get back from my business trip though.  Thanks for the help!

calvin
0 Kudos
Message 7 of 14
(7,390 Views)
I saved it in LabWindows/CVI 7.1 and 8.0 so that you can open it in older versions of CVI.

Hope this helps.
LDP

P.S.: Good job, Mohan, btw.
Download All
0 Kudos
Message 8 of 14
(7,323 Views)

I didn't realize that you could adjust the angle of the ticks marks on a rotary knob.  That's awesome!  It took me a few minutes to figure out how to do it (place your mouse over the first or last tick mark so that your cursor turns into a circular arrow, then just drag in a circle).  BTW, the example might look better if you change the Tick Style to "No Ticks".

I have a somewhat related question: is there way to replace any of the graphics in a rotary knob?  I'd like to be able to change the background, the needle, the center pin, etc.

0 Kudos
Message 9 of 14
(7,313 Views)
Hey Tony,

As of now, you cannot customize the background, needle (knob), or center pin of a knob/dial control.  We are always looking for good product suggestions like this; we would love to take your suggestions at our Product Suggestion Center.  Have a great day!
Best Regards,
Software Engineer
Jett R
0 Kudos
Message 10 of 14
(7,289 Views)