02-19-2019 10:46 AM - edited 02-19-2019 10:48 AM
Hello
I have a question about changing states inside the block diagram.
My code plots and save data gathered from a infrared sensor (see image below)
The "Elapsed Time" and "XY Graph" needs to reset every time a test is completed (but the VI cannot stop, it needs to be always communicating with the sensor).
The solution that I'm using now (the Reset Button boolean control and a local variable) is working, but isn't a "optimal" solution. The Reset Button is a control hidden in front panel, cause the final user will never interact with it.
There is way that I can create a boolean that have TRUE the first time this loops executes and FALSE in the others cases?
I've tried the "First Call" function, but it doesn't worked because my VI cannot stops.
Solved! Go to Solution.
02-19-2019 10:51 AM
Replace the control with a shift register. Use whatever logic you need to use to determine when the reset needs to fire, and wire a True to the shift register when it needs to reset, and a False other times.
02-19-2019 11:33 AM
@mthheitor wrote:
There is way that I can create a boolean that have TRUE the first time this loops executes and FALSE in the others cases?
I've tried the "First Call" function, but it doesn't worked because my VI cannot stops.
02-27-2019 10:15 AM
@BertMcMahan escreveu:
Replace the control with a shift register. Use whatever logic you need to use to determine when the reset needs to fire, and wire a True to the shift register when it needs to reset, and a False other times.
Thanks for the tip. I'm not very experienced with data flow... yet 🙂
02-27-2019 10:28 AM
The very first thing I learned when starting with LabVIEW was the Principle of Data Flow. It is so central to how LabVIEW works, to understanding how variables inside and outside of Structures change, of the importance of "sequence wires" (I'm thinking here of the Error Line) that I can't imagine being able to write reliable and efficient LabVIEW code without understanding it!
Go find a Tutorial (or Textbook) for LabVIEW and review the first few chapters.
Bob Schor
02-27-2019 10:39 AM
@altenbach escreveu:
Your big flat sequence structure is not needed. Dataflow alone enforces the correct execution order.
Thanks @altenbach for the feedback.
1) Sorry about the annoying VI configs, I forgot to change back the VI to normal mode without hidden menus. My bad.
2) Yes I have only one loop and the "save mode" is going to execute a few times during the tests. But the VISA cannot stop. The iteration terminal will not help in this case. I implemented Bob's "Retriggerable First Call " function and it worked (http://labviewinsights.blogspot.com/2008/09/retriggerable-first-call.html)
3) The feedback node is new to me, thanks for the tip.
4) Added more cases in my state machine
5) About the event structures, thank you for showing me what are "locking up my code". I'm learning how to deal with event structures and LabVIEW Core 1 isn't very clear about these structures
6) The flat sequence is something my superior likes a lot... (I removed from my attached new code)
Please take a look at my new code, if it's ok or if there's room for more improvement.
02-27-2019 10:49 AM - edited 02-27-2019 10:59 AM
@Bob_Schor escreveu:
The very first thing I learned when starting with LabVIEW was the Principle of Data Flow. It is so central to how LabVIEW works, to understanding how variables inside and outside of Structures change, of the importance of "sequence wires" (I'm thinking here of the Error Line) that I can't imagine being able to write reliable and efficient LabVIEW code without understanding it!
Hello @Bob_Schor.
The "secret" about putting Boolean Constants inside a shift register (in my vision) is not about the data flow method itself, but more likely a logic problem. I think only experience (training) will make these "tricks" more clear to me.
LabVIEW have things like Event Structure that isn't "strictly" Data Flow (dynamic events, property nodes, local variables, queues...). This is something that we almost have to use in all long programs and can confuse inexperienced users (like me).
And about Tutorials (or textbooks) for LabVIEW, do you any suggestion? I'm using LabVIEW Core 1 but not liking it.
Thanks for the help
02-27-2019 12:40 PM
When I typed "Data Flow, LabVIEW" into Google, I got several "hits", including numerous NI citations, including the implications of Data Flow. An interesting one is Going with the (Data) Flow, and another is Block Diagram Data Flow.
02-28-2019 05:48 PM
This my favorite:
Dataflow Programming Basics, and that's just because it has this one sentence in it: Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution. Armed with that one sentence and some determination, you can predict the dataflow of just about any LabVIEW code you encounter.