LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced data entry correction in Numeric Control

Hello. I am using Labview 2014. I have a Numeric Control that user can write 1 or any positive number multiple of 8. Maximum 1024 is allowed. Therefore, available numbers could be 1, 8, 16, 24, .. , 1024. If the user enters any number not obeying this rule, the number should be automatically rounded to nearest of these allowed entries. I know that Numeric Control has increment and decrement option in proporties, which can also round to closest possible entry with a given constant step, however this doesnt match with my need since the user is allowed to write 1 too (it is not only multiples of 8). Could you please inform me about how can I make this kind of advanced data entry control and auto correction ? It would be nice if you can share an example VI which can perform this control.  

0 Kudos
Message 1 of 7
(2,541 Views)

Hi,

 

my first idea is something like this:

LV_solution01.PNG

 

Regards

Kay

0 Kudos
Message 2 of 7
(2,524 Views)

Sorry, the image is quite small. Please find the original one attached...

0 Kudos
Message 3 of 7
(2,521 Views)

Use an enumerated type def.  The list is discreet an known at Development time 


"Should be" isn't "Is" -Jay
Message 4 of 7
(2,518 Views)

An enum will limit the operator to a discrete list of values to select from, but be aware that the value of an enum on the block diagram using the terminal will return the index of the selected value on the front panel.

 

The member items of an enum are entered as a list of strings for presentation on the front panel. 

 

For example, an enum control selecting a value of '8' on the front panel would result in an output a value of '1' (one) from the block diagram terminal.

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 5 of 7
(2,484 Views)

There are many ways to solve this -- it sort of depends on how much "fun with numbers" you want to have.  Because I like numbers (I'm a card-carrying member of the MAA), I'd do the following:

  • I'd make sure the Numberic Control was an I32 (to force "whole numbers") and that its Data Entry property was set to Minimum of 1, Maximum of 1024, with both set to Coerce (when you do that, you'll see the default Value change from 0 to 1).  This, at least, "forces" the User to enter something "in range".
  • The value "1" is a special case, not divisible by 8.  I'd treat it separately (a test and Case Statement).
  • So what about numbers from 2 .. 1024?  I'd do an integer Divide-by-8.  If the remainder was <4, I'd do nothing.  If the remainder was >4, I'd increase the quotient by 1.  And if the remainder was =4, I'd "flip a coin" (or use a rule that you can choose about what value a number like 4, or 12, should have -- note that "4" might be its own "special case", since it is closer to 1 than it is to 8 ...).  Then I'd multiply the quotient by 8 to get my "Divisible-by-8" equivalent value.
  • Did you want to "force" this value back into the Control?  I'll leave this as an "Exercise for the Reader".

Bob Schor

0 Kudos
Message 6 of 7
(2,480 Views)

Of course, you can always type def this ring

Ring.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 7
(2,474 Views)