LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Solenoid Valves for a water level application with LabVIEW:

Hello,

 

I am trying to control the water level in a tank using solenoid valves with LabVIEW.

 

I have an ultrasonic sensor that is going to measure the water level in the tank, I have the working VI (attached) for how the sensor measures the water level, I have made the vi so that it measures the distance the water level is away from the sensor (the sensor is attached to the top of the bucket). The vi which is attached also calculates the volume as more water is added into the bucket (the bucket is frustum shaped). 

 

What works: VI interacts with ultrasonic sensor. VI measures the distance the water level is away from the sensor, VI calculates the volume in the bucket as more water is added. 

 

What I am trying to do now: I want to have another bucket (filled with water) sitting above my bucket with the sensor on it, and with a solenoid valve attached to that bucket, and another bucket sitting below my bucket with the sensor on it (not filled with water). I want to interface these solenoid valves with LabVIEW in a way, that the user can enter in say "70%" as the desired percentage of water in the bucket with the sensor, and LabVIEW controls the the valve on the bucket to fill up the bucket with the sensor up to 70% and if there is any overshoot, there will be another valve attached to the bucket with the sensor that will let water out to go into the empty bucket).

 

Basically, turn on and off the valves based on how much more water needs to be added into the bucket and what the desired percentage is. 

 

The equipment that I have is:

 

Ultrasonic sensor: http://www.amazon.com/Ultrasonic-Module-HC-SR04-Distance-Arduino/dp/B004U8TOE6

 

Solenoid Valves: http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&item=290763981675&ssPageName=ADME:L:OU:US:3160

 

3 buckets.

 

I need some ideas on how I can complete the rest of this project. Thank you in advance! Please see the attached vi.

 

 

0 Kudos
Message 1 of 23
(5,682 Views)

Hello newyorklife99,

 

It looks like you already have an NI PCI-6251 that you're using for counter I/O, so the easiest way to approach getting the solenoid valve you've linked to work would be via a relay controlled by a digital output on the same card; also done through DAQmx.  The key concern would be the logic (when to open/close the valve), as well as finding a relay that can handle a 500 mA/12V DC signal that can be controlled with a 5V TTL digital output line (24 mA maximum on that card, depending on the channel used.)

 

Regards,

Tom L.
Message 2 of 23
(5,625 Views)

Thinking off the top of my head, if it were me, I'd start with the master-slave design pattern.

 

In the master loop, put your vi for reading the level.

 

In the slave loop, put very simple logic that looks at the value coming from the notifier and takes one of three actions each time a notification is received:

 

  1. If the level is greater than the setpoint (+some "empirically determined" hysteresis value, say 1-2%) open the valve to let water out of the middle bucket.
  2. If the level is equal to the setpoint (+- the same hysteresis value) make sure both valves are closed.
  3. If the level is less than the setpoint (-the same hysteresis value) open the valve to let water into the middle bucket.

Repeat until you're done.

 

You will probibly want to figure out a better way to stop things than what is shown in the design pattern template - using an error to stop works, but in the long run limits your options.

 

Oh yes, when shutting down, there is one thing that you will need to be sure that you do - to prevent wet feet. But I'll leave that for you to figure out as well.

 

Mike...

 

PS: This is homework right?


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 3 of 23
(5,618 Views)
Thank you 0utlaw. How would this logic work? Would it be something like a case structure? (We are very novice Labview users). How can we make the vi using relays and the logic?

Mikeporter - I'm not sure how your idea interfaces the valves with labview?

Thank you both for responses!
0 Kudos
Message 4 of 23
(5,613 Views)
To open and close the valves you need to turn the solenoid on and off (These are normally closed valves, right). You do that with digital io. What DAQ do you have available?

Just as you used analog input to read the level, you will need to write a VI to toggle a digital output bit to energize and deenergize the solenoid. As Outlaw mentioned you need to find a way to control a 12V solenoid with a TTL output. Try Googling "relay driver".

Mike...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 5 of 23
(5,607 Views)
Yes, the values apparently open with a +5v applied and close when you remove voltage. I'm using NI-PCI 6251 DAQ.

Right, so I will need to get a relay, and this relay will be interfacing with labview through digital inputs? And this is written into labview similar to how I did the analog inputs for the ultrasonic sensor? Is there a pre-built VI that you know of that does something similar to this and that I can modify? I used a NI example VI for the ultrasonic sensor and modified it for my use and added in the volume calculations.

Thank you again for your help!
0 Kudos
Message 6 of 23
(5,602 Views)
You will need a relay driver board. A solenoid is actually just a relay that causes a mechanical action. You need a driver board that will let you control a 12V solenoid (relay) with 5V digital *output* signal. This is a very common thing and there are many available inexpensively from hobby robotics shops.
The answers to your other two questions are (in order) yes and yes.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 7 of 23
(5,596 Views)
Thank you...I searched around some but I did not find any VIs that did this, could you point me in the right direction?
0 Kudos
Message 8 of 23
(5,587 Views)
Look for examples for single-line digital output.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 23
(5,580 Views)

We got a reed relay from radio shack, 5VDC and a contact rating of 0.5 amps, 125VAC - So that should work for us, right?

 

But as far as the VI, I searched for about an hour, but can't find any VIs that we can modify for our application, even searching single-line digital output VIs on the forums?

 

Not sure where else to search or what else to search?

0 Kudos
Message 10 of 23
(5,569 Views)