Thursday, April 29, 2010

Laser cut acrylic cover for ClockIt

Laser cutters are awesome. They can cut and etch a variety of materials including wood, acrylic, and leather. Laser cutters are one of the favorite tools of makers, artists and engineers alike. I used a laser cutter at to make an acrylic cover for the SparkFun clockit kit. I used 1/3" clear acrylic to sandwich the circuit board. The cutout design is based off the original PCB design done in Eagle CAD. I replaced the original push-button switches with switches that extended up through the cover (about 1/4 inch). The design file (done in Corel Draw as that is the preferred file format used to drive the Epilog laser cutter) can be found here: Clock-v12_brd_laser.cdr.

Thursday, October 8, 2009

Dimmer for the Adafruit Ice Tube Clock

The Ice Tube Clock is a vacuum fluorescent display clock kit from Adafruit industries. I recently put one together and have been enjoying its calming blue glow. Unfortunately at night the calm blue glow is a little on the bright side. While there is a menu option to adjust the brightness it would be better if the clock dimmed automatically. Fortunately, the clock came with a few unused pins on the microcontroller and a space on the circuit board to add a sensor.

I added a resistor and a photocell to act as an automatic dimmer. The microcontroller provides power from one of its pins (which is turned off if the clock is running on battery backup) and senses the voltage across the photoresistor using its analog to digital converter. I added a menu option to turn the dimmer on and off. Its operation is pretty simple. If the room is pretty dark, the display is at minimum brightness. If the room is light, the display is at the brightness set by the user. For extra credit I could add some sort of sensitivity option to the menu but I figured I would start simple and see how well it works. A modified firmware to enable the dimmer control (based off of Adafruit's Sept 30th firmware) is available there.

Friday, October 2, 2009

Blinkin' Basics: The 555 timer.

I recently took the electronics safety and basic usage (SBU) class at TechShop so I could make use of the soldering equipment. After making some paperclip men we built a simple blinky using a 555 timer, an assortment of resistors and capacitors, and an LED.

The 555 is a basic building block of many digital circuits. According to wikipedia (555_timer_ic), over a billion were manufactured in 2003 alone. The timer can be used to implement basic logic functions like an inverter or a flip-flop. It can also be used to blink an LED or drive a speaker.

Its operation as an LED blinker is pretty straight forward. The 555 monitors the voltage across a capacitor as it charges and discharges. When the voltage across the capacitor reaches 2/3 the power supply voltage, the 555 flips its output state and also discharges the capacitor. When the capacitor's voltage drops to 1/3 the power supply voltage, the output is flipped again and the capacitor starts charging. The values of the capacitor and some current limiting resistors (to slow down the charging and discharging) control how fast the 555 changes state and blinks the LED. "The Electronics Club" has a nice write up of 555/556 timer circuits.

One drawback of the 555 is that it isn't very power efficient. It's constantly charging and discharging the capacitor and all that energy is thrown away. My blinky ran for about 12 days off of a 9V battery. These days a cheap 8-pin micro-controller (like the ATTiny13A) could perform the same function, with only one resistor to limit the current through the LED (and if you used pulse-width modulation you wouldn't even need that resistor) for a much longer time. You could also control 5 LEDs with the microcontroller like the Tiny Cylon Kit. Still the 555 has been a workhorse component since it came out in 1971 and many blinking things wouldn't exist without it....and that would be sad. :(

Incidentally, the battery clip in the picture was made from an old 9V battery. I soldered a couple wires to the connections (remember, they are backwards on the clip, the big one is positive) then I used a hot glue gun to stick the bottom of the dead battery to cover up the solder connections.

Friday, August 14, 2009

ClockIt with s3kr3t text mode

From the "Pointless but why not?" department comes a tweaked firmware for the ClockIt clock by SparkFun that adds a plain text mode (see video). The new firmware adds a hidden mode to show the time in English using an alphabet created for 7-segment displays. To change modes, press and hold DOWN then press and hold SNOOZE for two seconds (do the same to change back). The other change from the default firmware is that the display will dim between 8PM and 7AM. The modified code is here: It's also linked from the code page.

Wednesday, August 12, 2009

Blinkin' LED with an ATTiny13A

The Arduino development platform makes it easy to get started using microcontrollers to do all sorts of things. The libraries make it easy to use an LCD display, interface with the joystick (and accelerometer) on a Nunchuck for the Nintendo Wii, and even fetch data from the WWW. While this is all well and good I wanted to get a better idea of what the Arduino library code was actually doing behind the scenes.

I decided to forgo the Arduino library and write some code using avr-libc directly. Instead of programming an ATMega168 or ATMega328p, that are standard uC with Arduino boards, I decided to start simple, with an ATTiny13A. This microcontroller is a small 8-pin IC with 1KB of flash memory (for storing programs), 64 bytes of RAM, and 32 8-bit registers. This chip also has a 10 bit analog to digital converter (ADC) for reading voltages and a timer/counter capable of driving two IO pins with pulse-width modulation (PWM).

The "Hello World" equivalent program in the realm of microcontrollers is a program to blink an LED on and off. I thought I would write a jazzed-up version that smoothly transitioned between on and off using PWM. I'd also use the ADC to read in the voltage from a variable resistor to control the speed of the flashing.

The circuit is pretty straightforward (see the picture). An LED (blue of course!) is attached via a 1K current-limiting resistor to pin 5. The center pin of a 10K pot is connected to pin 3 (the 'ends' of the pot go to Vcc and GND). The other wires are used for programming and are connected according to the pinout diagram on the ATTiny13A's datasheet. The red AVR adapter board from SparkFun makes it easy to plug the programming cable into a breadboard. The programmer I use is the inexpensive and easy to use USBTinyISP from AdaFruit Industries. The programmer provides 5V to the circuit via USB.

I found a few great tutorials that helped me understand how to use the ADC and PWM functions of the microcontroller. These tutorials were written for different Atmel parts, but as the different parts operate similarly I was able to figure out the differences by referring to the ATTiny13A's datasheet.

Newbie's Guide to AVR PWM (Incomplete)

Using AVR PWM Modes (PDF requires registration to download).
Newbie's Guide to the AVR ADC

The blinky light code is on the code page. I put in some lengthy comments to explain what is going on.

Friday, July 17, 2009

Ambient Nextmuni Monitor Prototype

I take the bus at least once a week to get around San Francisco. There is a local bus stop a block from the house that gets me to the Castro muni station where I can then go downtown on the inbound K, L, or M lines. I use to find out when the next bus will be at my local stop. However, as I'm running around in the morning getting ready, I tend to loose track of exactly when I need to get my butt out of the front door.

I figured all I really needed was an ambient device that I could glance at so I'd know when to leave. As a first step I built a prototype using an Arduino microcontroller board, an Arduino Ethernet shield, and a BlinkM smart tri-color LED.

The LED flashes green when it's the perfect time to leave (which for me is about 5-6 minutes until the bus arrives). The LED flashes orange then red as the bus gets closer. If the bus is more then 15 minutes away the LED is solid red. It then turns solid yellow then solid green before flashing green as the bus approaches. The LED turns blue when it's updating.

The Arduino sketch for the monitor is available on my source code page. The monitor's IP address and bus stop information are currently hard coded. For a next version I'd like to add a webserver so settings like the bus stop and update frequency could be altered and stored in EEPROM without needing to recompile the code. Ultimately I also want to build a dedicated version that has just the needed components. Perhaps I could fit it inside a small toy bus?

Tuesday, July 7, 2009

ClockIt - 7-segment strings

My unhealthy obsession with the ClockIt clock from SparkFun continues. I like how simple it is. It's a microcontroller directly wired to a 4 digit LED display, a piezo speaker, and a few switches. I'm finding it a good project for getting used to working with gcc-avr directly without the "training wheels" offered by the arduino platform. In the video you can see that I've written some code to display alpha-neumeric strings. I followed suggestions on Wikipedia on how to represent some of the more complex characters. It's a little weird, but you get used to it. My end-goal for this project is to have the clock spell out the time in English. Pointless, but instructive.

I'm thinking I could also have it tell me what electricity rate we're currently on as part of PG&E's net metering scheme (peak, partial peak, or off peak). In order to do this properly I'd have to support the date as there are different daily schedules for the summer and the other seasons. The same functionality might work better as an ambient orb like device. It could be red for peak, yellow for partial peak, and green for off peak. I'll have to think about which I'd like to do.

Some other project ideas I have for the clock are a kitchen timer (obvious I suppose), and a thermometer using a 1-wire digital thermometer IC connected to the one free I/O pin on the microcontroller. I already have some code written for the kitchen timer idea although it needs some clean-up before I post it.

Incidenally, SparkFun recently published the PCB layout files for ClockIt under a creative commons share-alike license making it one of their first open hardware projects. The layout files are for the Eagle layout software by CadSoft. There is a free version of Eagle for non-commercial use that allows you to create 2-sided PCBs up to 4x3.2 inches in size. SparkFun offers a PCB fab service to implement your design for $2.50 per square inch.