From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-27-2015 03:44 AM
I'd imagine this problem has a very simple solution, but I don't seem to be able to find one. I've searched around the forums quite a bit but nothing has answered my question.
I have code to calculate a pressure ramp rate inside a case structure, where the 'True' case runs the code and the 'False' case sets flow rate to zero.
However, for the calculation to be correct, the software needs to know the starting pressure in order to calculate the incremental set points. Currently I have the "starting pressure" as a manual input. I'm trying to find a way to request the pressure value from the DAQ input on the Boolean button press that changes the case structure to 'True'. I know that a Local Variable will pass the information over, however it will do this once per loop iteration and I don't want to cause any race situations with LVs. Is there a way that the code in the case structure can request a single data value from the DAQ pressure input on the Boolean button press?
Apologies if this is very basic. I've been trying to teach myself LabVIEW for the past couple of months and I'm struggling a little!
11-27-2015 03:48 AM
You should post what you have done so far.
It is easier for us to give hints if we know where you are....
Norbert
11-27-2015 04:04 AM
I'll post the VI in it's current state when I can get on my work PC. It will probably help if I annotate it before I post it. It's all been developed through trial and error and lots of reading on this forum so I'd imagine that the code is very inefficient.
You're all going to rip me to shreds, but I want to learn to get better!
11-27-2015 04:12 AM
@MattEff wrote:
[...]You're all going to rip me to shreds, but I want to learn to get better!
That's the spirit! 🙂
And, btw.: posters get rip only if they prove to be resistant to learning and improving themselves. The worst case to happen normally is to get a honorable mention in the Rube Goldberg thread....
Norbert
11-27-2015 04:52 AM
Just thinking about it (still don't have access to my work PC). If I put a for loop with a local variable inside the 'True' case structure and set it to run for only one iteration will that just grab the value from the pressure input?
11-27-2015 06:18 AM
Have you taken advantage of the LabVIEW Tutorials (such as the ones listed in the upper right of the Forum's Home Page)? If so, then I suggest you study two more things: Simple State Machines and the Producer-Consumer Design Pattern, particularly as they relate to Events.
Here's how to do this (NI has made it very easy for you). For the Simple State Machine,
Now, to figure out how to handle "Do something when I push this button on my Front Panel", you need to learn about the Producer-Consumer Design Pattern. Here's how to do that --
Give this a try. Feel free to come back here and ask more questions (though it would help us to help you if you post your code). When posting more "complete" code that (necessarily) involves several VIs, controls, and a Project, the best way to do this is to compress the folder holding the Project (such as "Simple State Machine", the default folder created for the Simple State Machine project) and attach the resulting .ZIP file.
Bob Schor
11-27-2015 07:59 AM
Right - here are a couple of VIs for you guys to have a chuckle at.
The first one I've attached is an earlier, simpler version that I've annotated.
The second is the VI in its current state.
What I'm trying to achieve:
When the boolean switch for any of the processes is pressed - take the current pressure value and apply it as the starting pressure for the ramp rate calculation. I only want it to take the current pressure value once for each time the boolean is switched to 'True'. This stops the user having to input the starting pressure manually, negating the risk that the wrong starting pressure is used in the calculations.
Please go easy on me. This is my first time ever using LabVIEW and I'm really enjoying it so far. However, with zero experience in any sort of coding I am struggling quite a bit. I expect to see some of this code in the Rube Goldberg thread
11-27-2015 08:34 AM
You really, really need to view the tutorials. Look at your Logging loop in Current Version. Besides using a Local Variable (which should be avoided, if at all possible -- learn about Shift Registers, for example), ask yourself what you want to do. I'm assuming that you want the While loop to start running if Logging is true. When do you want the While loop to stop? Note that you have wired the local Logging variable to the Stop indicator, so if it is true when you enter, it will (probably) be true when the Local Variable is evaluated, which will stop the loop. That is, the Loop will (almost always) run exactly once! Can you see how to fix this?
A slightly harder exercise is to figure out how to get rid of the Logging local variable. There are some simple ways to do this (and some more sophisticated ways, but learn to walk before learning to run), but first try to get a better understanding about how you want to control your entire program, i.e. how the Logging and Stop buttons work and what else is going on in your code.
Bob Schor
11-27-2015 08:44 AM
Thanks for your reply. Unless I've attached the wrong VI, I'm pretty sure the logging code works on my end. The file is created when the VI is started, then logging starts when the button is pressed and continues until the button is switched off. How would shift registers be implemented for the logging loop?
Again, I apologise for my terrible code.
I'll have a look at the tutorials.
12-04-2015 10:10 AM
Hi Bob,
I've had a go at updating the VI to include a state machine for the logging part. Everything seems to be working ok other than the 'Stop logging' button. When pressed, the state machine should switch back to "File created - Ready to start logging", however the VI just keeps logging. Would you be able to have a quick look to see if I'm on the right track? Thanks for being patient with me - it's taking me a while to get my head around the whole concept.
I've attached a .zip containing the VI and the control for the state machine.