LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automating mass flow controller

Solved!
Go to solution

Hello everyone!

I am very new to LabView and i am trying to build a VI for controlling two mass flow controllers. I will try to explain my problem as clear as I can to avoid doubts.

I want the mass flow controllers to operate in two different states, for example: 

During 2 hours passing a pre-determined mass flow (State 1) and then, for 1 hour,  pass a different pre-determined mass flow (State 2). The idea is to perform this in a loop (S1, S2, S1, S2 and so on)  until i want to stop the experiment. 

Since I know very little of LabView programming, I am having difficulties programming this loop. 

The possible solutions i tried to implement mainly comprised of using while loops or case structures but i am having difficulties counting the time and changing between S1 and S2 at the end of the target period. I tried using Elapsed Time but I could not put it to work. How can i built a VI for this automatic control of the mass flow controllers? 

Thanks in advance for the help

 

Best regards, 

0 Kudos
Message 1 of 12
(259 Views)

Hi vpereira,

 


@vpereira wrote:

Since I know very little of LabView programming, I am having difficulties programming this loop. 

The possible solutions i tried to implement mainly comprised of using while loops or case structures but i am having difficulties counting the time and changing between S1 and S2 at the end of the target period. I tried using Elapsed Time but I could not put it to work. How can i built a VI for this automatic control of the mass flow controllers?

Why don't you attach your "possible solutions" so we can tell you what is wrong with them?

To me it sounds like you need to implement a state machine: set MF value, wait, set MF value, wait…

 

Have you taken the "Training resources" offered in the header of this LabVIEW board? Have you examined the examples (including a state machine) coming with LabVIEW?

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 2 of 12
(244 Views)

The VI's i tried to build were very far from what i needed and since I have no experience i didn't knew how to improve them. I thought that i wouldn't be worthy to attach them since were far away from the objective and asked for help regarding the best strategy to attack the problem. 

I am sorry for that. I am doing some progress and when i improve my VI i will come here for more detailed help. 

 

Thanks for the suggestion, I will try to implement that.

0 Kudos
Message 3 of 12
(176 Views)

This is the best i could do but but it still does not operate automatically.

While one state is running I need to used the Boolean controls to change to the other, otherwise it will repeat again and again the same state.

When i tried to used the Boolean of the "Time has elapsed" of the while loops to control the state machine , it gives the error that a variable in a loop cant be used to control the state machine.

 


Thanks in advance for the help

0 Kudos
Message 4 of 12
(173 Views)

Hi vpereira,

 


@vpereira wrote:

While one state is running I need to used the Boolean controls to change to the other, otherwise it will repeat again and again the same state.

When i tried to used the Boolean of the "Time has elapsed" of the while loops to control the state machine , it gives the error that a variable in a loop cant be used to control the state machine.


Several items:

  • A state machine can happily repeat a state again and again - until you/conditions decide when to change to a different state…
  • Have you used shift registers to forward a value to the next iteration of your (main) loop? (This is pretty basic LabVIEW stuff!)
  • What's the point of those Select functions with TRUE/FALSE as values? This is pure Rube-Goldberg:a simple NOT will do the same!
  • Did you examine the state machine example, which comes with LabVIEW? Use an (typedefined) enum to provide state names. Use (atleast) one shift register to forward the new state for next iteration of your loop. I tend not to use long running loops inside of states of your state machine…

 

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 5 of 12
(159 Views)

Thanks for the help, you are obviously right and i want to believe that  was the inexperience talking when i did those mistakes, nothing else. 😅 I am very new to Labview and also not so familiar with programming languages so i apologize for that mistakes.

 

When I started working on this I saw the videos provided in the NI website to learned the basics and did not get to deep into other materials.

 

I tried to implement what you suggested and I managed to change from state 1 to state 2 but not the other way around. I can´t see whats wrong. 

Can you help me please? 

Thank you so much for the help. 

0 Kudos
Message 6 of 12
(152 Views)

Suppose I wanted to learn C (I don't, but suppose I did).  I go to a lecture on the Web and spend an hour, but don't write any code, don't run any code, don't try to debug any code that I write, don't ask for help attaching the (very simple) code I wrote as well as "what I was trying to do" (so as to learn my "simple" mistake and how to avoid it).  Would you expect me to jump into a task to automate some mass flow controllers?

 

Please learn to "walk" before you start "running with scissors".  Talk to your classmates.  Talk to your instructor.  Find someone who knows LabVIEW and ask if you could "apprentice" yourself to them (i.e. sit beside them as they write code, and explain to you what they are trying to do, and how they are accomplishing it using LabVIEW).

 

Bob Schor

 

Bob Schor

Message 7 of 12
(148 Views)
Solution
Accepted by topic author vpereira

Hi vpereira,

 

besides Bob's excellent advice on learning LabVIEW basics:

learn about using AutoCleanup: it cleans up your block diagram a lot, making it more readable…

learn about avoiding local variables (and so avoiding "Race conditions"): use wires instead!

why do you use "value" property nodes to set boolean values? They are the same as local variables, but just slower! Again: use wires!

Your loop is buring (atleast) one CPU core just for checking the current time: slow it down a little bit!

 


@vpereira wrote:

I tried to implement what you suggested and I managed to change from state 1 to state 2 but not the other way around. I can´t see whats wrong.  


Because you used an ExpressVI (which in general is a bad idea, but ElapsedTime is one of two exceptions to this rule). And you set the properties of this ExpressVI in a way not suitable for your task…

You set ElapsedTime to AutoReset: now it counts the time also when the other state is in charge. Switch off that AutoReset and create your own Reset signal.

Or much simpler: create your own algorithm to determine the elapsed time: all you need is a shift register…

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 8 of 12
(133 Views)

Bob, I understand and appreciate your point and you are probably right. But I will explain to you my situation: My boss asked me to work on this with the objective of running an experiment automatically. In our entire group only two or three people know how to our with LabView and only to simply read data and output simple controls with a DAQ. That I managed to learn quickly. I spent a day learning the basics of LabView and, after that, I tried to find or learn something very similar to what I wanted, with the objective to start from there. After that was when I came here for help. In my initial post, I said: "The possible solutions i tried to implement mainly comprised of using while loops or case structures but i am having difficulties counting the time and changing between S1 and S2 at the end of the target period. I tried using Elapsed Time but I could not put it to work." Since I was getting nowhere, I posted here. And, because I am not familiarized with all of the capabilities of LabView, my objective with this post was only for someone to tell me a direction like, "Use this or use that". That's why I did not attach any file, because I did not wanted anyone to spend time, I just wanted an advice to have a starting point. I apologize if I should not have done that. 

0 Kudos
Message 9 of 12
(118 Views)
Solution
Accepted by topic author vpereira

@vpereira wrote:

... my objective with this post was only for someone to tell me a direction like, "Use this or use that". That's why I did not attach any file, because I did not wanted anyone to spend time, I just wanted an advice to have a starting point. I apologize if I should not have done that. 


Fair enough!  So I'll echo GerdW's suggestion of a State Machine, something where you divide your task up into steps (Initialize, read configuration, set up hardware, take data, take data, take data, ... , clean up after taking data, close files, exit), and execute them in some order, perhaps determined by Button Presses, perhaps by other signals.

 

Do you know about the LabVIEW Tools Network?  When you installed LabVIEW, did you also install the VI Package Manager?  (VIPM is made by JKI -- look for a JKI folder in C:\Program Files (x86) if you are using 32-bit LabVIEW).  If so, you might open VIPM and install the JKI State Machine which (as I remember) has some examples.  Another very popular State Machine-like pattern is the Queued Message Handler (QMH), which you can find by starting LabVIEW and saying New Project (and choosing a QMH).  If you do a Web search on "Queued Message Handler", you can find examples and tutorials.

 

Bob Schor

Message 10 of 12
(97 Views)