Monday, December 12, 2011

Getting the water bottle to work

One weekend, Ruth and spent pretty much all Sunday trying to implement the water bottle part of our suit. We'd agreed on getting a pouch style water bottle several days ago and I had gone to get one that looks pretty much like this:The idea is that we would connect it to a tube, which would let you keep it attached to you while you drink water.

While this was a great idea, a slight problem occurred to me on Saturday night: this kind of water bottle works through suction - the complete lack of air within the water bottle is what allows the water to reach the tube at the top. To achieve this the water level within the water pouch can't ever actually decrease, making compatibility with our water level sensor impossible. Even if we turned it upside down, there is still no way for the air to escape and allowing the water level to go down. What we needed was a pouch (which would allow us to install the liquid level sensor), that could connect to a tube, that let air in and that was watertight.

What we found was that this didn't exist. However, I managed to rig something together during a frantic second trip to REI. Luckily Nalgene makes a pouch water bottle, as well. While the lids don't let air in, they are the same size as Camelbak water bottle lids, which DO let air in and suck water up via a straw. So what we ended up doing was getting a Nalgene water pouch, using a Camelbak lid, and then connecting it with the Platypus tube we had from before.

Meanwhile, Ruth began to actually experiment with how to set up an Arduino board and breadboard. Basically the breadboard allows you to extend the input and output docks on the Arduino board itself, giving you a space to use things like resistors (which decrease the current), and the several different kinds of input and output that we'll eventually need.

On Monday evening we went back to the lab to actually program for it. We needed a way to continuously keep track of someone drinking water, while also making sure that they've drank enough in the last 24 hours. I had come up with an implementation (that was maybe a little complicated) which involved creating a new class that would describe every cup of water drunk. When the water level had decreased a cup a new waterCup object would be created with a time stamp of when it was created. It would then be stored in an array. The array would have to have at least 8 waterCup objects in it (people are supposed to drink 8 cups of water a day), or a pink light would go on telling the user to drink more water. The main method would be continuously checking the array to make sure that all the waterCup objects had been created in the last 24 hours, removing ones that had passed the 24 hour mark, and making sure at least 8 were in the array.

This, however, was going to be very difficult to code and I hadn't yet figured out how to deal with the fact that people might fill the water bottle up mid cup. While Ruth and I were talking the problem through, she came up with a really elegant solution. The program will keep track of the total amount you drink in a variable. Every five minutes the program will test the water level to see if it has changed since the last five minutes. If it has changed in a negative direction (if the water level has decreased), then it adds that amount to the total amount you've drank. Every six hours, the program subtracts 2 cups from the total amount that you've drunk. If the variable representing the total amount drunk sinks below an arbitrary number (I think we ended up going with 0), then the program will turn a pink light on and the blue light off, letting the user know they need to drink more water. This keeps the user pacing their water intake throughout the day, and also allows them to store water intake, (since for instance, you can't drink water while you're sleeping).

We needed to come up with a way of making sure that the change in water level wasn't the result of a momentary shift in posture or something of the sort, so I suggested we also test the water level a couple second after the initial test, verify the initial reading.

While Ruth and I worked on implementing the code, Kat came in and attached the liquid level sensor to the interior of the water bottle. While Ruth was continuing to add details to the code, I began testing the thresholds for the water level, trying to figure out what was a cup, where the bottom of the water bottle was and how sensitive the sensor was. The sensor was giving fairly reliable feedback, but did not seem to acknowledge the bottom quarter or so of the waterbottle, giving it all the same reading.

As I was trying to figure out why it was doing this, the liquid level sensor stopped working entirely, giving us gibberish. We still don't know why it did this, but suspect that a membrane which reads the air pressure at the top of the sensor became damaged in some way. We hooked our board up to a flex sensor, and called it a night, since there was very little we could do about the sensor.

No comments:

Post a Comment