Nutrient Containers and Pumps
Time to mock up some hardware and write some code to drive the pumps using the nutrient containers and pumps now on hand.
Constraints/Requirements
- Use the transistors available spare parts bin
- No need for speed control so PWM not required
- Dispense a specific volume (ml) of liquid
- Pump a volume (ml) liquid over a period of time (s)
- Periodically dispense a volume (ml) of liquid every interval (s)
Wiring Diagram
I did not have any MOSFETs on hand and the BJTs available could easily drive small loads. The measured current draw of the pump came in at around 160mA. The max current the Arduino can source is 40 mA per pin with a max of 200mA combined. Given that the hydroponics drives several circuits, I opted to limit the driving current to 4mA resulting to a 1kΩ resistor and would drive the transistor into saturation. (switch mode).
The flyback diode is to prevent any back-emf to harm the transistor. The before and after reveal shows the effects of shunting the excess voltage when turning off the pump.
Software
The software is built on top of what is currently written. The partial class diagram with public methods highlights the gist of the PeristalticPump class.
Dispensing fluids becomes quite simple. I’ve tested the outputs using an oscilloscope. The one issue the cheap pumps and hoses is the max flow rate degrades over time. e.g. hoses don’t contract and expand the same way. I will deal with that later but there is a method to set the maxflowrate which could be part of the calibration process.
DA_PeristalticPump XY_001 = DA_PeristalticPump(XY_001_PIN, HIGH);
XY_001.dispenseVolume(50); // dispense 50ml
XY_001.dispenseVolumeEvery(10, 15); // dispense 10 ml every 15 seconds
XY_001.dispenseVolumeOver(150, 600 ); // dispense 150 over 10 minutes (600 seconds)
Now that this is unit tested, it is time to replicated the setup 2 more times, and come up with a control philosophy for pH/EC.