11-22-2019 08:04 AM - edited 11-22-2019 08:19 AM
Still new to LabVIEW. How can I improve my VI.
I have two conditions:
When the sp is in %, it can be directly connected to PID (CSV or manual entry)
When the sp is in litre/hour, m3/h, litre/sec it needs to be converted percentage values and then fed to PID.
Right now, I have everything in a case structure and the second condition is working. But I want to include 1 condition in my VI and I was trying to do this with nested case structures but I have repeat what is in it for every case.
Is there any better way to accomplish the same task.
Solved! Go to Solution.
11-23-2019 02:47 PM
I'm not sure I completely understand your Question, and it was difficult to figure out what you were doing in your Block Diagram (many VIs missing, far too much detail in main VI (need more sub-VIs), but here's a guess:
Bob Schor
11-23-2019 04:16 PM
@girish_jadhav wrote:
Right now, I have everything in a case structure and the second condition is working.
there is no nested case structure in your .vi attached. are you talking about this section of your code?
what is the second condition? the false case?
@girish_jadhav wrote:
But I want to include 1 condition in my VI
Where do you want another condition?
I suppose you want to add another case, besides true and false?
use an enum to control the case structure instead of the "Manual (OFF)" boolean.
@girish_jadhav wrote:
...and I was trying to do this with nested case structures but I have repeat what is in it for every case.
Is there any better way to accomplish the same task.
what do you repeat?
please be more precise with your problem description.
and don't forget to attach your subvis, you could upload a .zip
11-24-2019 11:39 AM
Hi girish,
@girish_jadhav wrote:
I have two conditions:
- Setpoint (sp) values in % or litre/hour
- Setpoints from a CSV file or manual entry
When the sp is in %, it can be directly connected to PID (CSV or manual entry)
When the sp is in litre/hour, m3/h, litre/sec it needs to be converted percentage values and then fed to PID.
Right now, I have everything in a case structure and the second condition is working. But I want to include 1 condition in my VI
When you have two conditions then why do you only want 1 condition??? You really need to explain this…
Why is there a wait in your while loop and an additional wait inside the FOR loop?
Why is there a FOR loop calling your PID (?) subVI twice per iteration of the while loop?
Why do you need to read the CSV file in each iteration of the while loop? Why don't you read that file once before the loop?
11-24-2019 01:56 PM - edited 11-24-2019 02:08 PM
@Bob_Schor wrote: [I don't understand what you mean by CSV, though I know what a CSV file means -- are you saying that the CSV files that you are using are all in "percentage" units? If so, I recommend dropping the mention of CSV as it only leads to (my) confusion].
Sorry for being unclear. Right now, the values are in percentage but I would also like to have an option to read data in other units and convert them to percentage before connecting to PID input.
@Bob_Schor wrote: You have data that are either in percentage, L/h, cubic M/h, or L/s. Read the data, pass it though a VI called "Convert to Percentage" (that has an input that selects Units In). Notice I wrote this VI which has little to do with the main task of using the data, but only formats the data so it can be used appropriately.
And this can be achieved with enum data type? I will add the zip file which contains all other sub-VIs necessary.
11-25-2019 01:34 PM
Hello Bob,
I used the enum and it worked. Thanks for the help 🙂
I have one more question: I tried to include this in a sub-VI as you suggested, but since there were some indicators and control elements present, I got a pop-up message saying that it might not work as expected. Do I need to neglect this message? Because the VI was working as expected, I thought this wouldn't be an issue in the future.
11-25-2019 01:46 PM
> are you talking about this section of your code?
Thanks for reading my post. Yes, I was referring to this part of the code.
> what is the second condition? the false case?
I thought I would first check if the data I am reading is in percentage or other units (this being the first true/false condition) and then give the option to enter the data manually or from an excel sheet (also true/false condition). This line of thought caused a lot of confusion as I didn't know how to handle this. One solution that came to my mind was using nested case structures.
But as you and Bob suggested, I used enum and got my VI working.
Thanks for the help 🙂