LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically select array value as time changes

Solved!
Go to solution

Hi everyone,

 

I'm trying to find a way to automatically change the value of a control based on the elapsed time. I want to set different time periods during which the frequency of true and false Booleans varies. These values are contained within control arrays and I'm trying to select one of them per time period. I'm attempting this with the interpolate 1D array and index array functions. However it seems to stay in the state that it starts in - behavior doesn't change in different time periods or within the same time period - it just stays as true or false.

 

Please let me know if there's any more information I can provide, and thank you for your help.

 

0 Kudos
Message 1 of 9
(3,848 Views)

You are never resetting your Elapsed Time functions.  There is a nice input on them called "Reset" that you need to set TRUE when you need the timers to go back to 0.  For the second timer, that would be each time you change states.  For the first timer, that would be when you need to restart the whole process.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(3,814 Views)

Handle reset option (True) when you need to reset to zero, if not provide auto Rest as True so that it will get re setted automatically when it reaches the elapsed time. so value change will occur for whenever the elapsed timer becomes true.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 9
(3,810 Views)

Thank you for your help. For the first timer I don't want that to reset, when it runs out I want the time to stay elapsed so that it always outputs a true and stops anything else from happening. As for the second one I've already set it to automatically reset after time target by ticking that option in properties, is that not sufficient?

 

I've done some more investigation and the behavior of the VI is very strange, and I think the problem occurs with Interpolate 1D array. I have changed the attached VI slightly to label the 6 points I'm talking about more clearly. They are at the top right of the front panel.

For the first 5 seconds of running the VI only elapsed time updates. Everything else is 0. After this, wait time number and spray time number increase from 0 to 50000 within 5 seconds, independent of the input range. They then stay at 50000 as the VI is left running. Given that I'm only inputting 6 different values for Ranges I'd have thought that wait and spray time number would give either 1,2,3,4,5,6 and never anything else, certainly not 50000. Since I'm not getting the integer that I'm expecting here the wait and spray times are not getting called correctly from the spray and wait time input arrays.

Any ideas as to what could be causing this behavior? Thank you

 

 

0 Kudos
Message 4 of 9
(3,805 Views)
Solution
Accepted by topic author Neil_C

Just noticed you are using the wrong function.  You should be using Threshold 1D Array, not Interpolate 1D Array.  Threshold gives you a fractional X value (index) based on your Y (time).  Interpolate is the opposite.  Since you have the time, you are trying to find the index.  Therefore use Threshold 1D Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 9
(3,797 Views)

That's an embarrassing mistake, sorry for wasting your time! I've run the VI with the proper functions now and there still is some strange behavior. The spray on/off works perfectly for the time I've tested it, but the integers from threshold 1D array (spray/wait time number) are always 5 larger than they should be and how the VI acts. So when I start the VI they are displayed as 5, but act is if they are 0 - the behavior I specify for the first range is what happens, not the fifth. The same happens with 6 and 1, 7 and 2 etc. Without the displays on the front panel I would never have noticed something was wrong but I don't feel comfortable using the VI as it stands with this behavior. Have I not set something up correctly for this to happen?

0 Kudos
Message 6 of 9
(3,788 Views)

Your arrays are empty, so it is impossible for us to know what you have typed in there when you run it.

 

But all of those arrays are set to show index 5 rather than 0.  So perhaps you think you are on 5 when you are not?  Or you think you entered a value at 0 when you are actually at 5?

Message 7 of 9
(3,749 Views)

Ah it looks like it's to do with them being set to show index 5. So if I write a value in the first box that appears I'm actually writing that in the 5th entry in the array? This should all be solved then if I set the index to 1

0 Kudos
Message 8 of 9
(3,737 Views)

@Neil_C wrote:

Ah it looks like it's to do with them being set to show index 5. So if I write a value in the first box that appears I'm actually writing that in the 5th entry in the array? This should all be solved then if I set the index to 1


Actually, you are writing to the 6th element.  The first element is at index 0.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 9
(3,730 Views)