Ice Tube Clock using atmega 328

For RTC breakouts, etc., use the Other Products from Adafruit forum

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
wbp
 
Posts: 260
Joined: Mon Mar 07, 2011 1:18 pm

Ice Tube Clock using atmega 328

Post by wbp »

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
grumpygasbag
 
Posts: 33
Joined: Fri Mar 30, 2012 5:28 pm

Re: Ice Tube Clock using atmega 328

Post by grumpygasbag »

'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.

User avatar
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm

Re: Ice Tube Clock using atmega 328

Post by n6rob »

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

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

Re: Ice Tube Clock using atmega 328

Post by wbp »

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
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 10:06 pm

Re: Ice Tube Clock using atmega 328

Post by revnull »

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

Thanks!

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

Re: Ice Tube Clock using atmega 328

Post by wbp »

revnull - was that you that sent the email?
William

User avatar
revnull
 
Posts: 22
Joined: Mon Aug 30, 2010 10:06 pm

Re: Ice Tube Clock using atmega 328

Post by revnull »

Maybe. I send so many emails, I can't recall. :)

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: Ice Tube Clock using atmega 328

Post by jarchie »

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

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

% 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!

User avatar
jarchie
 
Posts: 615
Joined: Sun Jun 24, 2012 2:16 pm

Re: Ice Tube Clock using atmega 328

Post by jarchie »

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...

Locked
Please be positive and constructive with your questions and comments.

Return to “Clock Kits (discontinued)”