Ice Tube Clock using atmega 328
Moderators: adafruit_support_bill, adafruit

Ice Tube Clock using atmega 328

by wbp on Wed Aug 01, 2012 1:37 pm

I got it working! With the right fuse settings and some minor code changes (interrupt names), I was able to use an Atmega328 in my Ice Tube clock. No more worries about memory, at least for a while (grin). The 328p is actually cheaper now than the 168V so why not use it?

I will post a new firmware version that runs on either a 168 or 328 in a little while.

William
User avatar
wbp
 
Posts: 226
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube Clock using atmega 328

by grumpygasbag on Thu Aug 30, 2012 3:12 am

'Tis true!

My IceTube now has a 328p installed, flashed with William's new firmware, and it's going like the clappers.

Nice one, William.
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm
Location: Sydney, Australia

Re: Ice Tube Clock using atmega 328

by n6rob on Sun Sep 23, 2012 8:07 pm

wbp and grumpy;

I am attempting to put William's firmware in a '168; its the version you released in July of 2012 (posted to the forum). I can't get the microcontroller to take it*. Can you confirm which version is compatible with which chip? I have some '328p's on order.

I am really excited about adding GPS to my Ice Tube Clock. Thanks for updating the firmware.

*see post here: http://forums.adafruit.com/viewtopic.php?f=20&t=33015
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Ice Tube Clock using atmega 328

by wbp on Wed Sep 26, 2012 3:35 pm

n6rob, I'm in Palo Alto. I've got spare 328p chips. I can program one for you. Maybe that's the quickest fix?
William
wm (at) usa (dot) net
User avatar
wbp
 
Posts: 226
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube Clock using atmega 328

by revnull on Sun Nov 04, 2012 3:38 pm

Where can I find the current version of the 328(p) firmware? I'd love to give it a try.

Thanks!
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 10:06 pm

Re: Ice Tube Clock using atmega 328

by wbp on Mon Nov 12, 2012 4:20 pm

revnull - was that you that sent the email?
William
User avatar
wbp
 
Posts: 226
Joined: Mon Mar 07, 2011 1:18 pm

Re: Ice Tube Clock using atmega 328

by revnull on Tue Nov 13, 2012 2:23 am

Maybe. I send so many emails, I can't recall. :)
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 10:06 pm

Re: Ice Tube Clock using atmega 328

by jarchie on Tue Mar 12, 2013 7:44 pm

I would like to elaborate on the changes required to port an Ice Tube Clock firmware to the ATMEGA328P-PU, since that would have been useful to me a while back. Perhaps others will find this information useful.

After updating the code to compile on recent versions of GCC, the firmware should compile for both the ATMEGA168V and the ATMEGA328P-PU. To compile for the ATMEGA328-PU, change target MCU in the Makefile to
Code: Select all | TOGGLE FULL SIZE
MCU = atmega328p


Delete any code compiled for another chip with the "make clean" command.

Pop an ATMEGA328P-PU into the clock, then compile and install the new firmware with "make" and "make full" as described in another post.

Finally, the ATMEGA328P-PU requires different fuse settings, so those should be changed. If using the Adafruit USBtinyISP, the command would be

Code: Select all | TOGGLE FULL SIZE
% avrdude -p atmega328p -P usb -c usbtiny -u -U lfuse:w:0xE2:m -u -U hfuse:w:0xC1:m -u -U efuse:w:0x06:m


Happy hacking!
--John <www.jarchie.com/email>
jarchie
 
Posts: 419
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States

Re: Ice Tube Clock using atmega 328

by jarchie on Sun Mar 24, 2013 4:00 pm

If anyone has trouble with quartz oscillator stability after upgrading to an ATMEGA328P, replacing C8 and C9 with 10 pF capacitors might be worth a try.


The reason I specifically recommended an ATMEGA328P-PU in my previous post is that, in my clock at least, an ATMEGA328P-PN was unable keep time. But after a couple months of use, the same clock with an ATMEGA328P-PU chip started losing time also. I suspected unstable oscillation of the quartz crystal.

My clock came with 20 pF capacitors for the oscillator, and the ATMEGA328P datasheet reports pin capacitance on XTAL1 and XTAL2 as 18 pF and 8 pF. Assuming a stray capacitance of 2 pF, the total load would be

{ ( 20 + 18 ) * ( 20 + 8 ) } / { ( 20 + 18 ) + ( 20 + 8 ) } + 2 = 18.1 pF

Since the crystal is designed for a 12.5 pF load, a load of 18.1 pF seemed a bit high. I decided to replace the 20 pF caps with 10 pF caps which would reduce the load to

{ ( 10 + 18 ) * ( 10 + 8 ) } / { ( 10 + 18 ) + ( 10 + 8 ) } + 2 = 13.0 pF

After that change, both an ATMEGA328P-PU and an ATMEGA328P-PN worked perfectly, and I hope the oscillator will continue to run stably.


As a side note, the crystal in the Ice Tube Clock has a frequency tolerance of 20 ppm which amounts to less than 2 seconds per day. But even with the ATMEGA168V, I've notice a time drift of greater than 2 seconds per day, as have others. The ATMEGA168V datasheet, does not state pin capacitance, so using the somewhat standard assumption of 5 pF on each pin, the load would be

{ (20 + 5) * (20 + 5) } / { (20 + 5) + (20 + 5) } + 2 = 14.5 pF

which seems close enough. But if the actual pin capacitance on the ATMEGA168V is more akin to the closely related ATMEGA328P, that might explain why time drifts as much as it does...
--John <www.jarchie.com/email>
jarchie
 
Posts: 419
Joined: Sun Jun 24, 2012 2:16 pm
Location: Santa Cruz, California, United States