Example Code

NIWeek2017: Hydroponic System using myRIO and LabVIEW OPC UA Toolkit 2017

Code and Documents

Attachment

Description

Overview

 

Hydroponic is a method of growing plants without soil, using nutrient solutions in a water solvent. Specially in region with harsh climatic surroundings it makes sense to grow plants indoor in a controlled environment. Growing indoor is not only faster by extending the number of light hours. It also can be done on a smaller footprint without wasting water. As a result, the system delivers high quality of food within a short amount of time.

 


Description

 

Using a myRIO (1900,1950) hardware with LabVIEW Real-Time made it easy to automate the hydroponic system. Controlling several pumps, valves based on user and/or sensor inputs.

Hydroponic.png

 

Inputs:

-PPM Sensor

-PH Sensor

-Leaf Sensor (measures leaf thickness)

-Water Tank Level (optional)

 

Outputs:

1.) Main City Water Valve

2.) Transfer Water Pump

3.) Bucket1 Drain Pump

4.) Bucket2 Drain Pump

5.) Bucket2 Water Plants

6.) Air Bubble

7.) Bucket1 Drain Valve

8.) Bucket2 Drain Valve

9.) Nutrient1 Pump

10.) Nutrient2 Pump

11.) Nutrient3 Pump

12.) PH Down

13.) PH Up

 

Hardware and Software Requirements

 

 Software:

  • LabVIEW Full Development System 2017 (or compatible)
  • LabVIEW Real-Time 2017 (or compatible)
  • LabVIEW myRIO Toolkit 2017 (or compatible)
  • LabVIEW OPC UP Toolkit 2017 (or compatible)
  • LabVIEW FPGA 2017 (optional)

Hardware:

 

Steps to Implement or Execute Code

 

  1. Download and open the attached ZIP-file
  2. Open and run the RT Main.VI listed located underneath the myRIO target
  3. Stop the RT Main.VI after verifying it works as expected
  4. Set the desired min & max PH range (Min=5.5, Max=6.5)
  5. Set the desired sprayer On/Off time (On=0.5min, Off=90min)
  6. Set to automatic mode
  7. Set current value as default
  8. Build a startup application and set it as startup
  9. Reboot the unit to run the startup application

 

Additional Information or References

myRIO Aquaponic System

 

The different systems states are highlighted below. Once operation mode is reached the system will constantly adjust PH level and water the plants based on user inputs. The preparation phase can execute in parallel while normal operation mode is continuously running. That way it’s possible to dechlorinate the tap water and mix up the nutrient solution while watering the plants.

Flowchart Statediagram.png

 

Stage1: Fill Bucket1 with Water

In this stage, Bucket1 gets filled with water. At the bottom of the systems, there is a manual valve that is always open. But in case the city water needs to be shut off manually it’s possible to do so. To be able to fill Bucket1 only the Main City Water Valve gets turned on for 3min. The system has a manual shut-off valve installed to make sure water is not filling up above the maximum tank level of 7Gal.

 

Stage2: Monitor PPM

Fresh water is usually full of chlorine and needs to be dechlorinated first to be able to take on all the nutrients. Ideally, the PPM range should be as low as possible. Austin City Water is quite hard and the starting PPM range is about 500-600PPM. After waiting for 24h it goes down by about 100-150ppm. Which is the trigger to start mixing up the nutrients.

 

Stage3: Add Nutrient

I’m using a common nutrient solution from hydroponic flora series

  • FloraGro
  • FloraMicro
  • FloraBloom

Based on the vegetables that are growing in the system the ideal PH and PPM range is given.

 

Table 1: Vegetables Chart for ideal PPM and PH level

Plants

pH

cF

EC

PPM

Banana

5.5-6.5

18-22

1.8-2.2

1260-1540

Black Currant

6.0

14-18

1.4-1.8

980-1260

Blueberry

4.0 -5.0

18-20

1.8-2.0

1260-1400

Melon

5.5-6.0

20-25

2.0-2.5

1400-1750

Passionfruit

6.5

16-24

1.6-2.4

840-1680

Paw-Paw

6.5

20-24

2.0-2.4

1400-1680

Pineapple

5.5-6.0

20-24

2.0-2.4

1400-1680

Red Currant

6.0

14-18

1.4-1.8

980-1260

Rhubarb

5.0- 6.0

16-20

1.6-2.0

840-1400

Strawberries

5.5-6.5

18-22

1.8-2.2

1260-1540

Watermelon

5.8

15-24

1.5-2.4

1260-1680

 

Based on the starting PPM range of around 400PPM it’s possible to add about 800PPM on nutrients to reach a starting PPM value of 1200. Every single nutrient pump will be turned on separately. That’s important to avoid nutrient lock in the first place. After adding the first nutrient solution by turning on Nutrient1 Pump the system waits for 3min. To make sure the nutrient gets dissolved completely using air bubbles before adding the next nutrient solution.  

 

Stage4: Transfer Water from Bucket1 to Bucket2

After the nutrient mix is ready the Transfer Water Pump gets turned on to get ready to water the plants.

 

Stage5: Adjust PH level

Before the system turns on the vegetable sprayer, the PH level needs to be adjusted. The system checks automatically every 5 min the PH sensor value. In case it’s out of range it will turn on either PH Down or PH Up. After reaching the ideal range usually between 5.5. and 6.5 it’s ready to be used.

Note: It’s important to not apply too much acid or base at once. Because it takes a while to get it dissolved to be able to detect the changes by the PH sensor. The system adds about 1ml every 5min in case it’s needed= PH is out of range.

 

Stage6: Water Plants

To water the plants the Bucket2 Water Plants pump gets turned on every 90min and is on for 30sec until it turns off again. Based on the room temperature, light on period as well as the kind of plant those on/off cycles needs to be adjusted. Therefore, a leaf sensor is used to determine the leaf thickness. Too much water will increase the leaf thickness. If the leaf gets too thick one water cycle will be skipped -> 180min before watering again. That helps to reduce the risk of mold roots especially during the night.

 

Stage7: Wash Bucket1 and rinse

The nutrient solution in Bucket1 will last for about 7days. It’s recommended to not use the nutrient solution more than 10days. Also, the PPM will increase every day by a certain amount. Because water is leaving faster than nutrients and adding salt like PH down is causing the PPM level to go up. It’s around 150 to 200ppm within a week. In case you are growing strawberries, the ideal starting PPM level is 1260. After a week, it will go up to 1460 which is close to the maximum PPM range which triggers to start a fresh nutrient solution -> Stage1. Before you fresh water gets added to Bucket1 it needs to be cleaned first. To get rid of any old nutrients from the previous mix. Therefore, multiple outputs need to get turned on:

 

  • Bucket1 Drain Valve
  • Bucket1 Drain Pump
  • Main City Water Valve

 

That way the whole bucket1 gets flushed with fresh water while pumping out any remaining residue. After 1min all the outputs are turned off to closing the valve as well as the city water inlet.

 

Stage8: Drain Bucket2

Before the new nutrient solution mix can be used it’s necessary to get rid of the existing solution in bucket2. Only if the new nutrient solution in bucket1 is ready to go it will drain the old nutrient mix in bucket2. To do that Bucket2 Drain Valve and Bucket2 Drain Pump needs get turned on for 3min to get rid of the old solution before they turn off again.

 

 

NI Week 2017.jpg

Image (21 May 2017): Setup station at the Austin Convention Center.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Mario_
Member
Member
on

Great Work 😄 keep it up!

SathwikReddyveluri
Member
Member
on

Awesome project 

Can I know how you  measure  nutrients N P K values