LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: question about timing in LabVIEW

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 🙂

0 Kudos
Message 1 of 8
(2,810 Views)

I thought about using the frequency at which the loop is running, but how can I know that ?

0 Kudos
Message 2 of 8
(2,806 Views)

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.



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 3 of 8
(2,805 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 8
(2,804 Views)

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 😛

0 Kudos
Message 5 of 8
(2,789 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 8
(2,783 Views)

As has been said, you really should check out some of the online tutorials:

LabVIEW Basics

LabVIEW 101

 

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.



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 7 of 8
(2,770 Views)

Thanks 🙂

 

I will try to apply your method and see the results ..

Best Regards ..

0 Kudos
Message 8 of 8
(2,757 Views)