01-21-2013 10:23 AM
Good Evening ..
First of all, I'am a labVIEW beginner so be easy on me!
I want to check if an input has the same value for a certain amount of time, for example, if some input has a voltage above 2 V for 10 seconds, how can I express that using a formula node ? If it's not possible then what should I do ?
I wrote the following program:
{
int i,j ;
for (i=1;i<=10;i=i+1)
{
if ( A>2)
j=j+1;
}
if (A >2 && j==10)
{ B = 1; }
else B = 0;
}
the value has to match the condition for the whole period, I know that my code doesn't gurantee it but that's what I could think about!
I need to make the steps between i increments seperated by one second, but I don't know how to make LabVIEW understand that!
I would appreciate it if someone told me how to do so
Best Regards 🙂
01-21-2013 10:30 AM
I thought about using the frequency at which the loop is running, but how can I know that ?
01-21-2013 10:30 AM
Is your data already an array? Or are you acquiring data and checking as you add more data?
Assuming you have an array of 10 seconds already: use the In Range & Coerce function. Set the low limit to 2 and the upper limit to 10. You will get a boolean array out of the In Range? output. Use the AND Array Elements to turn this into a single boolean.
01-21-2013 10:31 AM
First I would avoid using a formula node to write actual code. It is intended to support mathematical formulas, not code logic. You should consider looking at the examples for state machines. A basic state machine would accomplish what you want. The basic building blocks of a state machine are a while loop, a case statement and a state value. The state value is kept in a shift register. One of your states would be to check the value. You can keep the current value in a shift register and compare this and the time (with your start time in a shift register) to the current time. Based on the result of that test you decide your next state.
01-21-2013 10:57 AM
Thanks for your replies!
I'm acquiring the data from an analog channel so I don't have a pre-set array. I don't really get much of what you guys said since I'm a beginner as I told you!
I attached the block diagram that I'm working on, I think that the clock frequency is 2^32 - 1 as I understood from the LabVIEW help. Is it logical to write the loop as (for i=1;i<=(2^32-1)*10;i++) for a 10 seconds check ?!
if the formula node is impractical solution, then what should I use in terms of blocks ? sorry but I'm lost 😛
01-21-2013 11:00 AM
A formula node is not the right way to do this. I recommend you spend a little time going through the online tutorials and familiarize yourself with the basics of LabVIEW. It will be much easier for you to ask questions and understand our answers.
01-21-2013 11:17 AM - edited 01-21-2013 11:18 AM
As has been said, you really should check out some of the online tutorials:
With that said, I think you want to get away from using the DAQ Assistant and use some of the more basic nodes. You can actually set the sample rate of the DAQ and that will be constant. So you can then get a sample and compare it. If the value is in the right range, increment a counter. If it isn't, reset the counter. Once the counter reaches a certain amount, you are done.

01-21-2013 11:37 AM
Thanks 🙂
I will try to apply your method and see the results ..
Best Regards ..