Seven Segment Thermometer
Hey look, a project!
While I’m waiting for everything to align perfectly for my descent into robotics (still waiting on Mars to align with Neptune, and a few misc pieces from Sparkfun, and soon I’ll be waiting for time), I’ve built a thermometer for the dining room. Three times. I’ve now gotten it to some form of a stopping point.
Pieces and Parts
This uses:
- 4x Common Anode 7 segment displays (got from Allied Electronics)
- 2x A6276- a 16 bit constant current (sink) LED driver (from somewhere)
- 2x 10k resistors
- 1x DC Boarduino (from Adafruit)- Arduino clone intended for breadboarding use
- 1x Prototyping PCB (from RadioShack)
- 1x TMP36 (also from Adafruit)
- More 22ga solid core hookup wire then I care to remember
The A6276 is pin compatable with the STP16C596, the apparent Arduino LED driver chip of choice. It was acquired in efforts to fix the legendary Proton LED sign- sadly (or fortunately) the chips on the sign were a different form factor, and the A6276’s were donated to my evil prototyping causes. The chips work as a constant current sink; when a pin is set high, it effectively opens a current limited channel to ground; when set low the pin is at high impedance.
The Boarduino was originally intended for use in a cable tester due to it’s awesome size (cable tester may be a different post… or just a set of images). Strange things happened with that, and it is now serving as an overpowered thermometer.
Displays of Seven Segments
Technically the displays are eight segments including the decimal. Which works out nicely for being driven from a 16 bit driver. This 4 digit display is the main reason that the thermometer is getting posted, and here’s why: I’m using a protoboard and 4 7-segment displays. There’s no direct/simple way to connect the LED driver’s to the pins of the displays. 32 pins need to be connected for the displays. 32 small wires. 64 solder joints. In a small space. I present: pain.
There’re probably also a great many samples of ‘bad soldering’ in that photo, but I’m ignoring that for now. Why? Because of this:
I’m 90% certain there is a much better way to do this (Possibly a 4 digit seven segment display?). But it works. And it is awesome.
The wiring for this part, other then being tedious and made of pain, isn’t complex. To prevent excess pain, I have the hookup wires always run parallel. What this functionally means is the pin out on the right side of an LED driver chip is reversed on the left side. This requires some special handling in the software, and is not necessarily ideal, but, we tossed out ideal with the 40 hookup wires. Ignoring the reversing bit, each display has it’s pins hooked up in the same order to a given 8 pin side of the driver chip. The rest is basic stuff- serial out on chip one to serial in on chip two; latch, and clock are shared between both chips, chip output (the R-EXT pin on the datasheets) is a 10k resistor to ground, etc.
I would actually like to do this again as an intro to PCB design project. When time is found to figure out how to use Eagle.
Sensing Temperature
Temperature sensing is mildly straightforward- the TMP36 sensor is supposed to put out a 0V-someV signal based on the temperature it is currently at, following a roughly specific formula (outputting 500mV at 0C, and increasing at 10mV per degree C). Just a simple analog read and conversion. Roughly.
You can see the TMP36 at the bottom of the pic, snuggled next to 0.1uF capacitor as the spec sheet requests. I tried this without the capacitor and tended to get strange readings quickly (within a few minutes). With the capacitor, they tend to be less frequent (that said, no matter how bad the insulation in my house, it was not 4F last night. I refuse to believe). I started taking a median of several readings in order to solve the issue of strange outliers, and it appears to have worked. No ghosts causing 4F readings yet.
One other quick comment though: The TMP36 outputs 10mv/C roughly. Due to the fact that the Arduino is using a 10bit ADC converter over a 5V range, it effectively reads in 5mv increments. Therefore, we can only read the temperature to an accuracy of about 1 degree F. Which is a bit sad, as it makes those last decimals of accuracy kind of meaningless. But alas.
Conclusion
I’ve built a thermometer! With (reusable) seven segment display! For more cash then I care to think about! I’ve had two other variations of this before: outputting current temperature to a set of normal LED’s in binary (fun, simple, slightly confuses relatives, need right LED size to make it nice), and to an LCD (can display high/low/current readings simultaneously, and be read by non techies). A few other variations could be done relatively easily: an indoor/outdoor meter, monitoring multiple rooms, temperature loss in ducts from straight out of AC to last outlet, etc.
This and a few other projects I’ve done fall under the ‘can be done with 3 output pins and maybe an analog read’ category of projects. I’m plotting to start playing around with the ATTiny series of uC’s to get the project down to component parts / decrease the requisite bulk. We’ll see how that goes. I’d also like to remake the 4 digit 7 segment display as a PCB prototype if I get the time/chance.
Depending on how things go, I suspect either the box game, tilt RC bot, or a report on the cable tester will be next. Or, alternatively, LC3D may get finished. Who knows with me?
More details are available on request, as I’m not sure what the best level of detail is for folk (non-existent ones at that).
UPDATE:
Small update. I changed the analog temperature sensor to a digital sensor, the DS18B20 (from Sparkfun), using a set of libraries for the sensor (from Miles Burton). The nicest thing about the new sensor is that it has an onboard 12bit ADC, which lets it sense temperature accurately to the last tenth of a degree that I was wanting. It also doesn’t appear to suffer from the same noisey readings I was getting with the TMP36. The only downside is that it takes 3/4’s of a second to get the 12 bit value and send it back to the Arduino. Which is fine for what I am doing, but it doesn’t seem ideal for other applications.
One interesting other bit about the new sensor: it can operate on only two lines; a ground line, and a data line. The data line is supposed to be connected (via a 4.7k resistor (why 4.7k?)) to a voltage source. When the sensor wants to send a 0 to the uC, it connects the data line to ground, and the uC reads 0. When it wants a 1, the data pin becomes high impedance, and the uC reads a 1 coming from the pull up resistor. Which I find fascinating- it’s about like staring into the abyss of infinite knowledge, seeing all these little connections, and then start to see the big picture form and make perfect sense. (It should be noted, I am not an author).
Arduino Project Ideas
Projects I’d like to eventually work on with the Arduino:
- PC Remote Control Robot- Preferably Built with K’Nex, but that’s inner child talking. A simple, lightly mobile, robot that can be computer controlled. Preferably with video cam for a robots-eye-view of the world.
- Tilt RC Robot- An interesting idea probably from a video I watched- using an accelerometer and a psuedo-game-pad to provide tilt based control of the robot. True, at this point it’s little more then an RC car, but it would have a cool controller!
- Mapping Robot- A bit more complex; a bot that can try and map out the space it is located in; no doubt in constant communication with a PC workstation
- Motion Control Lighting- We use a set of lights on a timer as walkway lights; I’d like to change that to motion activated from two locations, in some overly complex scheme
- PT Camera Mount- A Pan/Tilt mount for a camera; possibly to be combined with motion tracking.
- LED Table- More specifically, I’ve seen a coffee table esque item with LED panels underlaid. I’d like to do something similar as a sole source of light for a room. And/or implement Game of Life on it
- Simple Web Server- Web Server Controlled… thing. I’m thinking something for outputting, say, two connected temperature sensors in a web clean format; but it’d also be nice to figure out an application for a stationary motor
- Wireless Sensor Network- A set of sensors, connected wirelessly, each re/broadcasting sensor information at timed intervals. Each node would have the most recent reading of every other node stored, such that you only needed to interface with one node to get an idea of what everything is doing. Could also be an application of adhoc network routing; given a sensor network, find a route to and from the furthest node.
- Solar Powered/Recharged Wireless Sensor- Either as part of a motion sensing network for controlling outdoor lights, or finding the temperature of the outdoor air. Attach a set of solar panels to recharge a battery powered Sensor Node.
- Persistence of Vision Odometer- A set of LEDs connected to a bike wheel with a Hall Effect Sensor, set to display interesting characteristics of the journey as the wheel turns- current speed, trip distance, overall distance, etc.
- LED Clock + Weather- Build a binary LED clock which includes a color coding for current and forecast weather- Blue in the hours column for rain in 12h, Red in Minutes for Heat Stroke right now, etc. Would need a method of getting the weather forecast, but I’m sure that’s in some way solvable. Would also allow me to have a binary clock with a date listing, and automatic 24h based clock. (One of the items I dislike about a ThinkGeek binary clock purchased ohh so long ago- on power loss it loses the ‘24h’ display configuration). Possibly to be combined with wireless sensor network above.
- RC Car GPS Control- Hook a GPS device to the Arduino, and combine that with a high performance RC car to see what happens. Akin to having a UAV fly waypoints.
- AutoMower!!!- An automated lawnmower. Basically a push mower with drive motors mounted, hopefully able to map out the yard, and not fall apart due to vibration, or go into a lake
- Bike Trip Logger- For a different project, I would like to figure out how to log bits of data about changes in elevation on a bike trip. It’s theoretically possible that a set of accelerometers could help solve the core problem I’m working with. This eventually evolves into a system for suggesting bike routes; but I need to get data collection first
- Auto-Pilot with Video Transmission- I’d like to combine an RC plane with waypoint following and Wireless Video Transmission. Technically, what I really want from this is to be able to fly an RC plane with a first person view; so not actually an Arduino project. But a project!… for much later in life.
- 3D Rotation Puzzle- A bit simple, but could be interesting. Use either a 3 axis accelerometer, or a set of 3 tilt switches, to build a puzzle that you play by rotating. Generate sequences of increasing length using a random number generator. Use a painful buzzer of shame on failure, cool LED’s of awesome on successful navigation of the puzzle. Alternative would be to use time trials on a puzzle with visual feed back on next turn to take. (The description will make more sense when it’s implemented)
- Knock Lock- An interesting use of Piezo Elements is detection of sudden changes in noise level; as one might expect with, say, knocking. You could reasonably extend this to opening locked doors, for keyless house entry. Alternatively, might be safer to use a keypad, but why go the boring route?
- Plywood Impact Location Sensor- http://www.youtube.com/watch?v=WNZCS-coZjY FPS with real guns… or, you know, duck hunt. Whatever works for you. It also seems like, if this could detect soft enough motion, that you could then use said large surface as a simple input device.
- Kite Control- I’d like to get into Kite Photography. Or flying kites. Or both. One interesting aspect of this could be adding control surfaces to a kite, allowing for rudimentary wireless control… of a kite. (Side note: I am not an RC Plane Hobbyist, or Aeronautical Engineer)
- Air Soft Turret- Probably not technically Air Soft, but I’m not sure of the official name. Many moons ago, I and my brother got a set of small battery powered toy guns that fired reasonably painful yellow BB’s. I’d like to to strip the toy casing, and mount the parts onto a turret for remote controlled target practice… with co-workers. Would also probably go nicely with a robot mounting.
I think one of the more frustrating things about going from PC’s to microcontrollers is that while uC’s have the ‘interact with the physical world’ aspect to them, they have such limited processing power that for a lot of interesting applications they need constant contact with a PC. At least I suspect so. As an example, I’d like to play around with motion tracking cameras. Video Processing like that isn’t something that could be done on a 16 MHz processor. Granted, doing it real time would probably also be a strain on an average computer, but the point still stands. This is probably something better suited to embedded PC’s, which is another ball of wax I’ll need to play with sooner or later.
Broad Update
Yes, this shall be a blog updated once every few months to say ‘I should write more’. Whatever.
ACM and AI
Starting with the current purpose of this blog, the ACM Local competition was last week; and I successfully succeeded at succeeding. First place by one problem. I went to the last two ACM contests with one of my teammates, and the other one I have a fair amount of confidence in. We shall see what happens. But, as a humorous aside to that: I very nearly implemented a Sudoku solver in under 30 minutes. Had I stopped asking myself ‘is it worth it to put in this much effort into a problem you probably won’t solve before the contest is over’; I probably could have solved it. Probably not, but maybe. I solved it using a horribly hacked together Constraint Satisfaction based Solver. For that interesting 30-50 minutes of my life, I would like to thank Robin Murphy (AI Prof), and Peter Norvig (Algorithms God/AI Book Author); both of which suggested Sudoku solving as an application of CSP. I’ll probably clean it up later and post it… as it stands currently it makes me want to cry, but it theoretically should work. (Theoretically because the test data was, in fact, invalid).
Education- Dr. Tao?
On a different note, I think I’m going to go for a PhD. This conclusion was got to by an interesting failure in my ability to communicate. As part of a follow up email, I had written the line ‘assume I go for a PhD’, which led to the thought ‘If I graduate and go into industry with a Bach, I’m going to end up drifting from job to job with mounds of uncertainty and stress’ (drifting coming from the popular consensus that a programmer should expect to change jobs every 2-3 years). If I get a PhD, there’s a lot less uncertainty in terms of job (at least I hope), I have the opportunity to interact with really incredibly frustratingly annoyingly intelligent folk, and if I go the academia route, I can torture a class of Yankee’s with ‘Howdy Class’. How can you not like that?
As a side note, I suspect the reason I was never comfortable with the thought of Grad School before is because I had never really come across something that peaked my interests. There’s a popular quote by Dijkstra: “Computer Science is no more about Computers then Astronomy is about Telescopes”. I have this odd sense that it is often misinterpreted from it’s original context. Computer Science is about the mathematical basis behind computing: proving algorithms correct, classifying problems as NP-hard, finding the most efficient way to find a correct solution, all about the theory. To me, that is what Computer Science Grad School is/was about. And I hate that definition. Mostly because it feels like something from the Ivory Tower- occasionally interesting results with only limited real world applicability. I want to generate solutions to real problems. Is making a formally proven OS kernel useful? Maybe to some, but spending 5 years to develop 10,000 lines of proven code just feels like a waste. I’ll probably regret those statements later, but, such is life.
Further side note: one thing I’ve heard fairly commonly is that in general, you don’t recoup the cost of a PhD. A master’s is worth it, but a PhD won’t earn you more over a lifetime. My response: Who cares? If you’re making a career or education choice based soley on ‘will it pay off in the end’, then you’re doing something wrong. Education (and career) should be driven off personal interest, and as an auxiliary, will it earn enough money such that you won’t live in a cardboard box. Going into advanced education because it will buy your retirement home a heated pool is just plain wrong.
Shiny New Toy- Arduino
Yet another different tact, I have a shiny new toy. An Arduino. With a product name which I can neither remember, pronounce, nor spell. I can at least remember/spell Arduino… pronunciation is still off. I blame the Italians. I got it in part because I wanted to get involved in the electronics/embedded side of computing, and mostly because it provided a convenient way to solve a problem my brother was having.
My brother, through what I assume were family connections, was hired to fix an outdoor LED sign for a bank. The company that manufactured the sign had gone out of business, but he was able to get some schematics for how the individual boards in the sign were wired. While he could take the boards down, ohm out connections, and so on, he didn’t have a convenient way of actually testing that either the repaired sign worked, or finding where issues might lie in malfunctioning boards.
I psuedo-come-in at this point. He asks me if I can write a program that would be able to test the boards. The boards themselves are driven off 4 inputs- 2 serial lines, a clock, and a latch. In the sign they’re driven off of what is probably a parallel port on a 386 running windows 98. I’m not sure if you’ve noticed, future reader, but most computers these days don’t come with parallel ports. So I go through the thought process of ‘how could I go about this’; serial ports don’t really work, as at most you might be able to control voltage on two lines; we could go through the trouble of finding and installing a parallel port expansion on a testing computer, and try to write a program that would drive the port/board. And then I thought “wasn’t there something Kyle mentioned not long ago; an Arduino?”.
It fits the bill perfectly. So the short ending to this is: the first day I got it, I broke it out, did the standard “Make an LED flash” thing to see if everything was working; and the second day I built a controller for the sign boards. A bit later I added some simple configuration bits, a button to switch between testing modes, and hooked up the 9V battery so the computer became completely unnecessary. My brother has since stolen it for testing, until he can get his own.
So, I feel good about that. One thing I’ll probably post soon is a list of projects to go along with it. Y’Know, to go along with the other list of projects I’m not making progress on. I might also post more details about the sign, as it was a fun first project/jaunt into Computer Engineering.
Deutschland
I’m also planning to go to Bonn next Summer as part of a study abroad program. I’m trying to learn some German for that; and it’s coming along slowly. And that’s it. That’s all. See y’all later.




