LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

measure time lapsed from reaching threshold to execution

The snippet attached is what I came up with to enforce the order of execution I have in mind. 

 

Thank you for your patience.

thisisit.png

0 Kudos
Message 31 of 60
(1,546 Views)

That's looking correct but very sloppy.  Try ctrl+U to clean up your diagram 


"Should be" isn't "Is" -Jay
0 Kudos
Message 32 of 60
(1,541 Views)

Then I get the following image. 

 

I really appreciate your help.

 

Of course once I am happy with the program and time characterization, I am going to remove the outer case structure and directly connect to the inner case structure (like the 2nd image below).

hellothere.pngWhat I will actually run in experiments. anotherone.png

 

0 Kudos
Message 33 of 60
(1,538 Views)

You also should wire the error chain and place an OR before the loop conditional terminal so the logic is

 

Continue unless Stop or Error  and wire the error out of the loop to a simple error handler to let you know when and what error occurs. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 34 of 60
(1,536 Views)

I think this is what you are recommending.  Sorry, I just started reading up on handling errors. I guess it's there to stop the while loop when the system runs into a glitch. Not sure what to do about "select error."

 

thisisit2.png

0 Kudos
Message 35 of 60
(1,534 Views)

Also, don't split the DAQmx purple reference wire before the first read.  Connect the 2nd read to the 1st read's output at the top right of its connector panel.  It won't change the execution of your code, but follows standard practices of how LabVIEW block diagrams should look.

0 Kudos
Message 36 of 60
(1,521 Views)

@nighthawk117

 



@nighthawk117 wrote:

I am not sure what ensures that "the high resolution relative clock" knows when to get executed. 

 

thebesticould.png



 

EDIT: Commenting on this post. Did not see the next page where most of it has been resolved since. Still, let me summarize in detail what's happening in that particular old code to maybe give you a better intuitive understanding of the magic of dataflow. While it might be confusing at first, you'll learn that it is one of the most powerful features of LabVIEW!

 

The first ticker (=high resolution relative seconds) executes once the lower outer case structure starts executing, i.e. once all inputs to the structure have received data. It will do that in parallel to the start of the AI next to it (It does not matter where in the case structure the ticker is located, you would get the same result if you would place it after the innermost case structure (e.g. right below the subtraction) as long as no wiring changes. Now the innermost case structure needs to wait until that AI has completed (slow) and the comparison made (infinitely fast) because it cannot start until the boolean output wired to it is available. Once the innermost case structure starts executing, the second ticker and the VISA will execute in parallel. (This is probably not what you want, because you are not measuring the time of the VISA call at all). Once the innermost case structure has completed, it will output the ticker taken at the start of the inner case. The subtraction will basically give you the time of the AI read, ignoring the time of the VISA call.

 

Benchmarking is very hard to get right, and easy to get wrong. Have a look at our 2016 NI Week presentation.

0 Kudos
Message 37 of 60
(1,515 Views)

Thank you for your explanation.

 

For my experiment, I think I am pretty much done but for learning of how to use LabVIEW, I want to better understand error handling. 

 

I looked everywhere and tried to create the error in and out I circled below (found the image online) but couldn't.  So, I just opened a few random examples and copied pasted it.  Could you tell me where I can find those units? (sorry, my lab computer just crashed so im using my personal laptop to post this question)

post-11742-126892283135.png

0 Kudos
Message 38 of 60
(1,510 Views)

@nighthawk117 wrote:

 

thisisit2.png


Note that the innermost case structure belongs inside the innermost first sequence frame and should only contain the VISA call. Now you only need one instance of the ticker (i.e. nothing in the FALSE case). Avoid duplicate code! Avoid chopping up code into tiny fragments!

 

You only need one simple sequence structure, e.g. as follows:

 

(Sorry, I don't have DAQmx installed, so the AI read icon does not show)

 

You could even merge the first two sequence frames. It is unlikely that it makes a real difference here because the ticker is infinitely fast and the AI read is very slow in comparison. Within error, you'll get the same result if you start them in parallel.  Simpler code is easier to read, debug and maintain!

 

 TimeAIVISA.png

0 Kudos
Message 39 of 60
(1,506 Views)

Thank you!

 

 

By the way, is there a way I can create "error in" and "error out" in block diagram directly without having to create "error in" and "error out" in front panel first? (in front panel, I can go to Modern -> Array, Matrix &Cluster and find error in and error out.  I, for the life of me, wasnt able to find them in block diagram.  

 

(whatever I created, named '0: No Error' outside the while loop, I don't think that is right. I think I have to have 'Error In' instead.  I can of course create it now, by creating it on Front Panel first.  Just out of curiosity, I want to know how it can be directly created in Block Diagram first.) 

0 Kudos
Message 40 of 60
(1,499 Views)