It's been nearly two weeks since I last worked on this. This is a typical pattern for me - do a lot of work really fast, then stop completely. But I'm not going to stop this time!!
In my last update, I had gotten to a point where the device would sense the water temperature but then compensate too much and end up oscillating between freezing and burning. This time, I have three next steps:
1. Add more time for it to wait for a temperature change before compensating again.
2. Brace the servo
3. Make the device more physically robust
........
Ok, I'm getting irritated. I pulled out my awesome new jumper leads and attached them to the temp sensor. To make the temp reading quicker, I used silicone glue to waterproof the sensor connectors. Sounds awesome. Now the sensor gives completely erratic readings. It likes to stay in the negatives, and has now been stuck on -50 C for the past few minutes. WTF? I don't want to rip off the glue after I got it so perfect. I have no idea why this is happening!
Sunday, May 27, 2012
Sunday, May 13, 2012
A real test with real water!
I managed to get the setup to a point where I could run water from the bathroom sink over the sensor and control the flow with the servo! The only issue was that (hopefully) due to the plastic over the sensor, it took a few seconds for the sensor to register change. During that time, the unit would compensate by turning the knob. However, it was adjusting so far ahead of what it was detecting that by the time it sensed that the temperature was correct, it had adjusted too far. When the temperature kept changing beyond what it was expecting, it started correcting in the opposite direction - again, much too fast for the sensor to keep up. So what ended up happening was the servo would move the temperature back and forth between freezing and burning over and over.
Luckily, the fix for this is easy enough: increase the time it waits to detect a change. I'd also like to brace the servo so I don't have to hold it in order to keep it from turning freely when it's trying to turn the knob. Lastly, I want to use some cables or other robust hardware to make this thing less fragile. I'll report back when I've done some of these things.
Luckily, the fix for this is easy enough: increase the time it waits to detect a change. I'd also like to brace the servo so I don't have to hold it in order to keep it from turning freely when it's trying to turn the knob. Lastly, I want to use some cables or other robust hardware to make this thing less fragile. I'll report back when I've done some of these things.
Last steps before moving to the shower
In my last few posts, I haphazardly put together the wiring to allow the unit to take a reading from the sensor and from the potentiometer and then compensate by turning the servo up or down. Now I need to actually stick the thing on the shower knob and test it out.
However, last night I thought of an easier way to set the temperature than using a potentiometer. Instead of messing with the pot as you would the shower knob in order to find the right temperature, just mess with the shower knob itself and then press a button on the unit to let it know you like this temperature. Later on, I'll include buttons to nudge the temperature up or down by a couple degrees if your tastes change. But for now, it'll be enough to just set the temperature yourself and tell the unit to keep it there. This will also allow me to avoid dealing with the issue of how hard it is to turn the shower on from the full off position, which requires a ton of torque. I thought I'd calculated it when I began this project, but either I wasn't accurate or my servos can't do what they claimed. Either way, I'll deal with it once I get the fundamentals of this thing working.
Ok, so the first step is to remove the pot, add a button, and program the unit to recognize a button-press as the signal to keep the temperature where it is.
The next step is to extend the wires to the sensor so it can get the temperature of the water. However, this will require a little waterproofing. Luckily, I think I can do this quick-n-dirty by putting a plastic bag over the sensor. Later on I'll embed it into a coupler with silicone glue, but for now I just want to take the dang temperature.
Tuesday, May 8, 2012
Potentiometer and progress!
Now I see why arduinos are so popular. It's really not that hard to program them in simple ways! I just got it to take a reading from the potentiometer, convert that to the desired temp, compare that with the detected temp, and then rotate the servo +5 or -5 degrees per second until they match.
This is significant progress! I'm actually shocked that I've come this far so easily.
Literally, if this were all I had programming-wise, I could make this project work. It wouldn't be ideal -you'd have to go by feel to tell whether you liked the temperature, it would be very slow to rotate, you'd have to turn on the hot water yourself, etc. But it would freaking work! This step-by-step, get-it-working-first-and-add-polish-later approach has worked better than pretty much anything I've ever done. Wow!
So now what? An LED readout so you know the temp you're asking for? Consolidating the circuitry so it's not a bunch of delicately arranged wires that can't be moved from my desk? Making a waterproof housing and actually hooking the thing up to my shower? Finding a power source so I don't have to use the USB cable?
I want to take the straightest route to something that works, so my next steps will be:
- stabilizing the wires so the project can leave my desk without falling apart
- mounting the servo on the shower knob so I can start testing
Stay tuned!!
Just for fun, I'm speculating about one of the steps further down the road once I finish the design and want to stamp out some more of these. What's really cool is that you don't need to pay $30 for more arduinos, nor do you need to pay through the nose for custom-built chips. Instead, you can just buy the same processor chip the arduino uses and a couple components for like $7, and use this procedure coupled with this procedure. Just pop the chip into your existing arduino to program it beforehand. This is a big step in reducing production costs!
This is significant progress! I'm actually shocked that I've come this far so easily.
Literally, if this were all I had programming-wise, I could make this project work. It wouldn't be ideal -you'd have to go by feel to tell whether you liked the temperature, it would be very slow to rotate, you'd have to turn on the hot water yourself, etc. But it would freaking work! This step-by-step, get-it-working-first-and-add-polish-later approach has worked better than pretty much anything I've ever done. Wow!
So now what? An LED readout so you know the temp you're asking for? Consolidating the circuitry so it's not a bunch of delicately arranged wires that can't be moved from my desk? Making a waterproof housing and actually hooking the thing up to my shower? Finding a power source so I don't have to use the USB cable?
I want to take the straightest route to something that works, so my next steps will be:
- stabilizing the wires so the project can leave my desk without falling apart
- mounting the servo on the shower knob so I can start testing
Stay tuned!!
Just for fun, I'm speculating about one of the steps further down the road once I finish the design and want to stamp out some more of these. What's really cool is that you don't need to pay $30 for more arduinos, nor do you need to pay through the nose for custom-built chips. Instead, you can just buy the same processor chip the arduino uses and a couple components for like $7, and use this procedure coupled with this procedure. Just pop the chip into your existing arduino to program it beforehand. This is a big step in reducing production costs!
More steps
Since last post, I've added a "desired temperature" variable, which I arbitrarily set to 22 because that's the ambient air temperature here. I set the servo to rotate +5 degrees per second if the sensor detected less than the desired temperature, and -5 degrees per second if the sensor was more than the desired temperature. I also had to set limits on its movement or else it would hit its own physical limits and start grinding. It worked! All I had to do was warm it up with my fingers or cool it by blowing on it, and it compensated. Ok, awesome. What's next?
My next step is to get it to recognize user input. I think a potentiometer will be the simplest to get working, and then I can work on better methods later. I'll use the pot (that's what the cool kids call it) to set the desired temperature.
Monday, May 7, 2012
Step by step
I've been worried about the programming aspects of this project. I can modify existing code, but I have trouble if my goal is too different from the code I'm trying to modify. But instead of trying to do everything at once, I set the goal of just making the servo respond to the temperature sensor in some way.
I succeeded! Since any temperature I'm likely to get will be between 0-100 degrees Celsius, and since the servo moves between 0-180 degrees of rotation, I simply set the servo to move to whatever temperature is read! Since the air temperature is relatively constant, the servo doesn't move much at all. It stays at about 20 degrees. When I vary the temperature by a small amount by warming the sensor with my fingers, the servo moves a small amount. This is great, because I don't want it moving all over the place when I'm taking a shower. I may be able to optimize for power consumption by having a dampening system or something, but for now my next step is to wrap my head around how to make it compensate for a change in temperature rather than echo the change in temperature.
My initial thought is to have variables for "temperature we want" and "temperature detected" and have the servo move until they're the same. I'll try that.
I succeeded! Since any temperature I'm likely to get will be between 0-100 degrees Celsius, and since the servo moves between 0-180 degrees of rotation, I simply set the servo to move to whatever temperature is read! Since the air temperature is relatively constant, the servo doesn't move much at all. It stays at about 20 degrees. When I vary the temperature by a small amount by warming the sensor with my fingers, the servo moves a small amount. This is great, because I don't want it moving all over the place when I'm taking a shower. I may be able to optimize for power consumption by having a dampening system or something, but for now my next step is to wrap my head around how to make it compensate for a change in temperature rather than echo the change in temperature.
My initial thought is to have variables for "temperature we want" and "temperature detected" and have the servo move until they're the same. I'll try that.
Sunday, May 6, 2012
Semi-success
Got new arduino, hooked servo to shower knob. It was able to turn the knob once the water was on, but it wasn't able to turn it on or turn it off all the way. Booo! It's also possible I'm not getting the full available torque because I'm powering the servo off the arduino instead of using a separate power supply. I'll try that later, though, because my next step is to get the servo to respond to the temperature sensor. Here's where it may get dicey, because I'm not really a programmer. But if I can't do it, I'm sure one of my programmer friends would find it simple. I love my friends.
Saturday, May 5, 2012
Using servo with arduino!
I finally brought the servos home and hooked them up to my arduino! Using some sample code, it worked great. Then I hooked up a 9v battery to the arduino's 5v regulator, and the servo started behaving erratically. Upon connecting the USB again, it is not responding. What happened?! I've run things on the arduino using a much more powerful 12v battery and everything was fine! Boo!! Hopefully it didn't somehow get fried. I'll post again when I know more :(
Subscribe to:
Posts (Atom)