09-16-2018 09:41 AM
The snippet attached is what I came up with to enforce the order of execution I have in mind.
Thank you for your patience.
09-16-2018 10:04 AM
That's looking correct but very sloppy. Try ctrl+U to clean up your diagram
09-16-2018 10:10 AM
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).
What I will actually run in experiments.
09-16-2018 10:19 AM
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.
09-16-2018 10:38 AM - edited 09-16-2018 10:58 AM
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."
09-16-2018 11:09 AM
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.
09-16-2018 11:55 AM
@nighthawk117
@nighthawk117 wrote:
I am not sure what ensures that "the high resolution relative clock" knows when to get executed.
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.
09-16-2018 12:10 PM
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)
09-16-2018 12:25 PM - edited 09-16-2018 12:31 PM
@nighthawk117 wrote:
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!
09-16-2018 12:38 PM
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.)