Electronics and Arduino Programming
I had fun naming my control variables. Earth = temperature of the soil, wind = temperature of the air, water = moisture, and fire = light.
The sensor stalk
I needed a way to connect all the sensors into the Arduino. I made my own shield and used a motherboard firewire cable. I used the heating pad (earth) from the previous project, a hair dryer, and a 12 DC fan (wind) and the two fluorescent lights (fire).
Finding the right layout was kind of a pain using a cheap board from radio shack (not so cheap).
Firewire cable had just the right amount of wires.
Three sensors: two thermistors and a photocell. This is the first version. The original plan was to be able to differentiate between daylight (higher) and the artificial lights (lower), but the photocell would get saturated and keep rising. I had to put an extension on it so that it was above the lights. I did not implement the water sensor because I did not have a pump.
Testing out the fan circuit. Used a TIP120.
Sensor Stalk header: I/O for the open squid, 2 pins for the the 12VDC, and 2 pins for the fan.
A little bit fuzzy, but everything hooked up.
Fire
The goal of the Fire (light) control was to turn on the lights at 6am and then turn the lights off when the sensor (sunlight) reached a specific point. The lights would turn on again if the sensor value dropped below the determined value and stay on until 8pm. As summer approached, the light would be used less and less.
Challenges:
I used the DateTime library. Syncing up the time with a pc and adjusting for a timezone were a pain.
I got the fire variable to work sporadically, but it never worked longer than a period of a couple days.
The lights are on!!! Having to haul my work laptop onto the porch did not help with debugging, especially when it is all software. I have really old Arduinos that still require the manual reset so that did not help either. I have not gotten around to modding them.
Here is a little clip from testing the photocell circuit. I sound ridiculous. That is Noelle's beautiful thumb at the end.
Timers
I used the FrequencyTimer2 library. Something wasn't running 100% correctly because the calculated overflow did not come out right, and I had to tweak it until it was approximately 1ms. I created an earth and wind PWM timer based off of the 1 ms tick. The wind period was 100sec, and the earth period was10sec broken into 100 increments with a divisor. This strategy needs to be evaluated because I was constantly troubleshooting the timers to see if they were correct.
Earth
Earth was almost the exact same algorithm that I used with the original PID controller. I cleaned up some of the calculations and added a larger range to the thermistor formula for both thermistors. The PID function producted a value from 0-100, which was used as the duty cycle of the earth PWM.
Earth was almost the exact same algorithm that I used with the original PID controller. I cleaned up some of the calculations and added a larger range to the thermistor formula for both thermistors. The PID function producted a value from 0-100, which was used as the duty cycle of the earth PWM.
Wind
Wind was a bit more complicated. I designed the algorithm to turn off the hairdryer and turn on the 12VDC fan. The wind PID algorithm was allowed to go negative. The negative state would mean that the station had gotten too hot, and the fan needed to turn on. I think I got this working right at the end of the project, but I figured out that the fan did not have the CFM to cool down the germination station as the days got warmer. My original idea was to have one fan and a large heat sink with a film heater attached. I think that would have been a little neater, but the control algorithm would have been a little more complex.
Wind was a bit more complicated. I designed the algorithm to turn off the hairdryer and turn on the 12VDC fan. The wind PID algorithm was allowed to go negative. The negative state would mean that the station had gotten too hot, and the fan needed to turn on. I think I got this working right at the end of the project, but I figured out that the fan did not have the CFM to cool down the germination station as the days got warmer. My original idea was to have one fan and a large heat sink with a film heater attached. I think that would have been a little neater, but the control algorithm would have been a little more complex.
In the end, I did not feel confident enough to leave some plants in the germination station. Whenever it rained hard, the plastic concaved a little and caught some water. I did not frame out the entire base of the station so the water leaked back inside. Thank goodness nothing got fried!
Here is some analysis of what problems I ran into and what I can do better next time. If anyone has additional input, I would be grateful.
Scope - I really wanted to have a GUI and a solid communications protocol so that I could read the data live. I hacked together a serial protocol, but it was not robust enough, and the fact that I had to sit outside on the deck did not help the whole development process.
One of the interesting philosophies that my boss has mentioned when developing our products (embedded systems) at work is to take a single slice of the project and make it work top to bottom. One of my goals going forward is to get a single element working (i.e. thermistor) and have it communicating with my new laptop (birthday present!!!!) with a pyQT UI. If I can get that to work, then I can slowly add the other variables.
I am going to have to adjust the Frame structure so that it is more stable. I plan on getting a sheet of lexan for the room. I would like to make the whole structure out of lexan but that might be cost prohibitive.
I have some really good ideas for the water sensor and pump. I am currently trying to figure out what method would be the cheapest and easiest to control (ac pump vs. dc pump).
The end game of this project is to have a system that will transmit the control data to a web server so that the station can be monitored remotely. Tweaking the PID values online would be kind of neat, but I don't think that is necessary.
Next post, whenever I get around to it, will be about the raised bed and garden that Noelle and I created this summer.