LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with program structure - simple question.

Hi. I need a piece of advice on how to create the correct structure for my program. It consist on two main processes:

 

1)Detecting time difference between 2 rising edges, and showing the data. I used the concept of another user "panoramarts" that you can see here:

http://forums.ni.com/t5/Digital-I-O/Measuring-Time-between-two-Digital-Signals/m-p/2091868#M16230

(If anyone knows a better way to do it I will really appreciate it)

2) A continuous process.

 

I attached a picture of the structure I am using. The numbers I will refer to, are indicated there.

 

The program basically starts counting the time until a rising edge is detected (number 2 in the picture). After that the next sequence is executed (number 3 in the picture) counting the time again until the next edge is detected. After that the subtraction is made to have the time difference and then displayed (number 4 in the picture).

 

Here is the problem: I have a continuous process that must be executed, so if I place it in "Number 1" then the edge detection must be running otherwise i do not see the continuous process (is like Labview execute de FLAT sequence, and after that the continuous process). If a place the continuous process in another While loop, then is like sometimes I get inaccurate data from the edge detection.

 

How can I solve that? Is there another way to acquire time between edges? I hope you can help me without the VI.

 

I am using Arduino, so I can not use DAQmx VI's.

 

 

DMDsync
0 Kudos
Message 1 of 3
(2,215 Views)

Firstly, if the second parallel while loop interefers with the rest of the code, it probably means that it is a CPU hog. Make sure it has a small wait statement, even 0ms)

 

Sequences are not good. You basically have duplicate code and rigid serialization doe to the sequence structure. Better would be a single instance of the edge detection code and a state machine architecture that knows if it is waiting for the first or second pulse.

 

Please show us some real code so we get a better understanding what you are doing.

0 Kudos
Message 2 of 3
(2,197 Views)

Thanks for the quick feedback!

I believe my problem is that I am not using the best way to estimate time between edges. As I previously said, I am using almost the exact VI that "Panoramarts" shared in this link:
http://forums.ni.com/t5/Digital-I-O/Measuring-Time-between-two-Digital-Signals/m-p/2091868#M16230

The only difference is that instead of a DAQ assistant in each of the While Loops, I use the same input for both of them. It works ok. It measure the time difference between the 1st and 2nd edges, the 3rd and 4th, and so on. All that VI is inside a while loop to continuously perform the counting. May be I can simplify my question:
How can I continuously measure time difference between incoming edges (it could be a Boolean variable varying from true to false periodically) in a VI that already has a continuous process running?

As Altenbach said, I used a wait statement in the continuous process (as it is not necessary a fast data update for it, because it is just a simple temperature measurement), but that delay created some faulty timing in the edge timing sequence.

 

Any ideas?

 

Thanks again!

DMDsync
0 Kudos
Message 3 of 3
(2,161 Views)