09-16-2018 12:39 PM
@nighthawk117 wrote:
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)
Those are terminals for front panel controls. If you go to the front panel and the Array, Matrix, & Cluster palette, you'll find those controls there.
09-16-2018 12:55 PM - edited 09-16-2018 01:07 PM
@nighthawk117 wrote:
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?
All you need to do is right-click on any error input or output terminal of a function on the diagram and "create control" or "create indicator". No need to go to the front panel at all. If you need it elsewhere, just disconnect and rewire.
Once you get familiar with all these tricks, programming in LabVIEW is extremely fast.
Also, don't forget Quickdrop! A seasoned LabVIEW programmer rarely even goes to the function palette. 😄
09-16-2018 03:54 PM
My computer finally rebooted and this is what I ended up with.
Thank you so much!
09-16-2018 04:20 PM - edited 09-16-2018 04:24 PM
You really still have a potential race condition because you seem to talk to the same instrument in parallel (upper code vs lower code). Since the two code fragments are independent there is no real guarantee what will happen first.
You should create a data dependency to ensure that the two code fragments execute in a defined and desirable order.
You should also only have exactly one instrument string constant if they are all the same. You can branch the wire to the various use locations. (Imagine you have to change the device string because of a change in hardware. In your current code, you would need to make identical changes in N different locations, and if you forget one instance, the resulting malfunction might be hard to track down).
I also don't understand why you need to take the same AI reading twice in immediate succession. Most likely the result does not change. You probably can eliminate the first I read and the bigger case structure without change in functionality.
Nothing is generating any error, so that entire error wire in the shift register never changes its value, so why is it there?
09-16-2018 05:05 PM - edited 09-16-2018 05:08 PM
Thank you so much for your comment
The error wire and register were something suggested earlier. So i just blindly put them there ( i thought it was in case my machine breaks down or some breakdown) should i just delete it?
The AI being read twice was to simulate the amount of time it takes for the voltage cutoff to kick in. I wanted to include the input reading in the time measured.
Regarding the race thing, i guess i will move the sequence ( the bottom half) in another case above. I will post my updated work soon. Thank you
09-16-2018 05:22 PM
More like this
09-16-2018 05:24 PM
@nighthawk117 wrote:The AI being read twice was to simulate the amount of time it takes for the voltage cutoff to kick in. I wanted to include the input reading in the time measured.
That does not "simulate" anything. If you want to include the AI time, you would simply delete the outer reading and the outer case structure completely (as suggested!) and connect the reading indicator to the inside. Right now you take a reading and if it is outside the threshold you immediately take another reading again. At this point, you already know the result.. Once is enough to get the elapsed time if arranged correctly! It is peanuts to always measure the timing, independent of the comparison.
The correct use of the outer error terminals would be that if this is a subVI and called with an error, ALL code here should be bypassed. In this case you would place a big case structure around the code and put everything in the "No error" case. Then you would also wire across all the various DAQ Vis, so if they generate an error, the loop should stop and the subVI return the error. It really depends on what you want to happen if things go wrong.
09-16-2018 05:48 PM - edited 09-16-2018 05:50 PM
Before moving it into a new case in the upper half of the code, I have a question.
The reason I had the outer case structure was to measure the time difference only when the voltage was exceeding the threshold.
The way I have it now probably isn't what you suggested but this is how i interpreted it. The way it's set up now, the time difference reading is continuously updated no mater what.
The only way I can think of is what I have below, but this obviously returns an error..
09-16-2018 05:58 PM - edited 09-16-2018 06:07 PM
This is what would be my final product (including moving the lower half into the upper half)
I really appreciate your patience...
09-16-2018 06:10 PM
Use block diagram cleanup. Too many crooked and hidden wires.