From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-08-2021 07:00 PM
Hello,
I set a numeric control with a min of 0 and a max of 23. I want to make it so that if you try to go above 23 the numeric control goes back to 0 and vice versa, if it goes below 0 i goes to 23. Basically I want this to work in a circular type of motion.
Maybe there is a better more elegant way to do this, with an array for example.
Thanks!
01-08-2021 07:07 PM
Are you aware of what is sometimes called the "mod" operator? "a mod b" means "the remainder when you divide a by b" (b must be non-zero, and is generally positive, with the remainder also usually positive).
23 mod 5 = 3 (23 / 5 = 4, remainder 3)
-23 mod 5 = 2 (-23 / 5 = -5, remainder 2)
Have you looked at the Numeric features that come with LabVIEW? Look at the function called "Remainder and Quotient", and get the answer to your question (I'll leave the details to you -- you should be able to figure it out for yourself, even without the hints in the first paragraph).
Bob Schor
01-08-2021 10:19 PM
I am aware of the "Quotient and Remainder" function, it was one of the first options/ideas I had when I started working in this project but I didn't like the fact that it wasn't "intuitive" in the control side as the values would be outside the range (see picture attached).
I would prefer if the values weren't outside the range (0-23) on the control side, and I was wondering if there is a different method like changing a property node value of the control for example since that's what I used to set the Min and Max.
01-09-2021 06:03 AM
One of the reasons the Unofficial Forum Rules and Guidelines stress that it helps to post code rather than pictures (and is a topic I've been known to stress, as well) is that it helps us to understand what you really are talking about!
I think I understand, now, what you want. See if this is correct: You'd like a Control that has the following properties:
Is this correct? I've designed a number of these controls. Do you know about Event Loops, and the Value Changed property for controls? This lets you (almost instantly) "trap" when a Control has been modified (by a Front Panel interaction, typically) and lets you "post-modify" it, say by always replacing it with "value mod 24".
Bob Schor
P.S. -- go read those Unofficial Rules, and thank Hooovahh for posting them.
01-09-2021 10:35 AM - edited 01-09-2021 10:46 AM
As you can see, you have plenty of options! Is the control an integer or floating point?
@ht210 wrote:
Maybe there is a better more elegant way to do this, with an array for example.
Can you explain why you think an "array" would help? That seems to be completely unrelated to the question.
01-09-2021 10:51 AM
@ht210 wrote:
I would prefer if the values weren't outside the range (0-23) on the control side, and I was wondering if there is a different method like changing a property node value of the control for example since that's what I used to set the Min and Max.
If you use the Q&R method, you don't even need to define the min&max. Don't overcomplicate things!
Here's a simple example:
01-11-2021 03:37 PM
Yes, this is exactly what I want to do. Sorry for not posting code, I thought it wasn't necessary as what I wanted to achieve was pretty straight forward.
Doing an event structure and having the event structure "re-assign" or overwrite the value once it goes outside the allowable range sounds like a good idea, ill give this a shot. Is the "Value Changed" property for controls the same as the Value property node?
@altenbach:
The snippet really helped out a lot! And regarding the array, I was thinking that maybe by cycling through the elements of an array I could achieve what I wanted to.
01-11-2021 03:51 PM - edited 01-11-2021 03:56 PM
@ht210 wrote:
Doing an event structure and having the event structure "re-assign" or overwrite the value once it goes outside the allowable range sounds like a good idea, ill give this a shot. Is the "Value Changed" property for controls the same as the Value property node?
You can place my code inside an event case with no changes.
Watch your terminology!
@ht210 wrote:The snippet really helped out a lot! And regarding the array, I was thinking that maybe by cycling through the elements of an array I could achieve what I wanted to.
An array has nothing to do with this problem. You can cycle through the index, getting array elements in sequence and wrapping to the other side when the end is reached.
For example, the following code would cycle through all elements of an array forever.