08-21-2024 01:29 PM
Hello, i am very new to Labview and i am trying to use it for a Fuzzy Logic Controller.
The output from the Fuzzy Logic Controller is the duration for a pump to run. How do I set up a timer so that it has the takes the output from the controller and uses this value to time the running of the pump so that the pump turns off once the duration value is met?
For context the temperature is measured and only when it is above zero does it move on to analyse the inputs for the fuzzy logic controller. The water level and Blockage % are the two inputs (4-20mA) into the fuzzy controller which then outputs a percentage of rotation and is then calculated to determine a running duration for the pump, (which is only if the percentage of rotation is above 33%) Once the pump has run for the duration it shuts down and the cycle begins again.
Does the program make sense for what i am trying to achieve? Any help would be much appreciated.
Solved! Go to Solution.
08-21-2024 01:52 PM
One mark of someone who is "very new to LabVIEW" is they are probably using the most up-to-date version of LabVIEW (probably installed at school). Most of the Experienced Developers who help out on these Forums don't update LabVIEW every year, and because of its graphic nature, LabVIEW VIs (and their Block Diagrams) cannot be opened and run in earlier versions of LabVIEW. Our advice is to "Save for Previous Version" and specify LabVIEW 2019 or 2021 (which appear to be "popular choices" -- I happen to have both installed, but nothing more recent). Similarly, please don't post "pictures" of your LabVIEW code, particularly if it has "wires running everywhere, with lots of changes in direction".
Have you looked at the Timing Functions? Do you know how a While Loop runs? Do you understand why those two questions are related to each other and a possible solution to your question? [Personally, I dislike Express VIs, but some of the ones in the Timing Palette aren't too bad ...].
Bob Schor
08-21-2024 02:08 PM
Hi Bob, Thanks for the quick response.
I saved as a different version and saved as 21.0, is that the version for LabView 2021?
I have had a look at timing functions but i dont understand how i can use them to start the timer and the pump at the same time and stop the pump once the timer is done. I'm slightly more familiar with PLCs and ladder logic, so i guess i am looking for the done bit of the timer to de-energise the pump but not sure how to do this with labview.
I think i need to use a while so that it stops when the timer is done but i'm not sure how this fits into the rest of the program.
I'm assuming my program is a bit of a mess but i was hoping if i can try to explain it then i can get some guidance to get it to work.
08-21-2024 03:52 PM - edited 08-21-2024 03:54 PM
09-03-2024 06:28 PM
Thanks for the feedback, it was really useful.
I have updated my program to be a state machine with states for the initial temperature check, the fuzzy inference system (FIS), motor on, check time and motor off. Does this meet what you had suggested?
I had a look at your previous program but i am struggling to understand its application. With the state machine, i can change instruct the motor off once the check time state has completed but i am unsure how to set the variable for my timer. I would like the value of duration from the FIS state to be used to determine the length of the timer. How can i get that value to the check time state and how can i then use it to start the timer?
Please ,let me know if i need to correct anything. I dont know how to create that shorter path you previously mentioned for the fuzzy system. Is there a way to group the path or something?
09-04-2024 10:58 AM
Sorry, I won't have access to a computer that can open LabVIEW 2021 for a few more days. Please do a "save for previous", LabVIEW 2020 or below, and attach again. Thanks.
09-04-2024 01:23 PM
Thanks for getting back to me. Please see the file below.
09-04-2024 06:26 PM
From some research, I think I may need to use a shift register to move the value of the duration from the temperature check state to the check time state. I'm not sure how this can be implemented though. Is this something I should look into further?
I think I am needing something like a 'move' function from a PLC program. I did see there is a move function for LabView but it mentions a file path so I don't think its used for moving variables.
Thought I would just provide an update in case I'm heading in the wrong direction but i will keep investigating to see if I'm on the right track.
09-04-2024 10:02 PM
Sorry, I was away all day, but when you do a "save for previous", you should zip up the entire resulting folder because we are missing lots of things (e.g. the typedefs)
Currently, the VI is also broken because of unwired tunnels.
Are zeroes really reasonable default values for most of your controls? Why are some controls hidden? Maybe it would be more reasonable to use diagram constants for values that the user is not supposed to change.
You are currently not doing any timing.
What is your "move" function supposed to do? (the on in the file IO palette basically renames a file). You can always right-click any function and call up the help for details.
Shift registers are great to maintain data across iterations, basically you read from the left, modify if needed or just wire across, then write the updated value back on the right. Very efficient!
I would recommend to leave out all the hardware IO and just simulate data to work out the overall logic. Much easier to debug!
09-05-2024 05:31 AM
No need to apologise I appreciate your time.
The VI is incomplete because I am unsure how to set up the timing function. I have now created a shift register to take the value for duration to the check time state. I would like this value to be inputted into a timer and once this is complete the state changes to turn the motor off. Do I use a wait timer for this and one this is greater than or equal to the duration time the output would be true?
For some reason when I converted the file to a previous version it reset all my controls to zero. Can I set the analogue/digital channels to a constant? Is that what you were suggesting?
I hid some controls as I repeated the motor controls to turn the motor off but I don't want to the see the control for the digital output again so I hid it. If i changed to a constant though I could get rid of this.
A PLC move function take a variable and moves it to another location, so I think this is similar to the shift register for Labview.
I have attached my updated version with the shift register and updated values while I make another version with the hardware IOs eliminated.