Monday, March 26, 2012

Wise Clock 4 with ATmega1284

I thought that replacing the ATmega644P with its bigger brother ATmega1284P in Wise Clock 4 would be trivial. How wrong I was.

The first step was to burn the bootloader. After a bit of research, here is what I found out:
  • USBtinyISP from adafruit cannot program chips with more than 64K of flash (see this thread);
  • if you don't want to start from scratch (that is, compile the source code and figuring the fuses) there are at least 3 sources: ryanmsutton, maniacbug and calunium;
  • USBtinyISP half-works: it writes to the flash, but reading back for verification purpose fails because of a bug in the firmware; I ignored the verification error;
  • although burning the bootloader (any of the three mentioned above) seemed successful, uploading any sketch afterwards always failed;
  • the setup from ryanmsutton did not work for me (I guess the fuses are wrong; then the core files also point to the arduino folder, instead of the sanguino, as it should be);
  • with the bootloader from calunium (atmega1284p_16MHz.hex) I was able to upload sketches; these are the settings in boards.txt I used:

atmega1284.name=Sanguino W/ ATmega1284p 16mhz
atmega1284.upload.protocol=stk500v1
atmega1284.upload.maximum_size=129024
atmega1284.upload.speed=57600
atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0x98
atmega1284.bootloader.extended_fuses=0xFD
atmega1284.bootloader.path=atmega
atmega1284.bootloader.file=atmega1284p_16MHz.hex
atmega1284.bootloader.unlock_bits=0x3F
atmega1284.bootloader.lock_bits=0x0F
atmega1284.build.mcu=atmega1284p
atmega1284.build.f_cpu=16000000L
atmega1284.build.core=sanguino

Note the upload protocol (stk500v1), note the fuses and note the core folder (last line).
  • in the end, since the booloader from calunium worked for me, I did not try the one from maniacbug, which (from what I read on the arduino.cc forum) seems to be very popular and work very well;

To compile the code for Sanguino with ATmega1284P, some macros must be updated as well, by adding
defined(__AVR_ATmega1284P__)  to any defined(__ATmega644P__)

like this:

#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__) // sanguino

In the end, the program space is about 126K (compared to 62K in ATmega644P) and the available RAM is 16K (compared to only 4K in Atmega644P). Not a bad upgrade for only a few bucks more.


Note: ATmega1284 is not defined in avrdude.conf shipped with Arduino 22 or 23 (folder \arduino-22\hardware\tools\avr), but it is defined in Arduino 1.0.


Sunday, March 25, 2012

Troubleshooting guide for Wise Clock 3/4

This should really be a chapter of the assembling instructions for Wise Clock 3/4. Until I integrate everything into a single document, it is just another post that begged to be written (long ago, as a matter of fact).


1. Right after power up, the clock should make a beeping sound. If that does not happen, here are possible causes:
  • missing input 5V power; the optional power LED may be useful in this case, turned on when the power is present;
  • reset pin may be shorted to ground (the processor won't execute any code);
  • processor may not be powered: check that pin 10 has 5V and pin 11 is connected to ground;
  • faulty or missing the 16MHz clock for the processor; check crystal connections to the pins; if everything looks good electrically, try to upload a sketch; it that still doesn't work, test by replacing the processor or replacing the crystal;
  • buzzer may be disconnected; check connections between processor's pins and buzzer, shorts to the ground, terminal soldering.


2. The display does not light up at all (assuming the display is not defective):
  • faults in the connections to the display (right-hand header): look for shorts between neighbor pins in the display header; look for shorts between any signal pins in the display connector and ground;
  • output header (left-hand) display header may have shorts between neighbor pins or pins shorted to the ground;
  • the board's female connectors may be misaligned (shifted by one) when plugged in the display's male headers.


3. Getting SD card error in "Quote" mode:
  • faulty SD card; check the SD card itself by reading it in a PC; must be formatted FAT16 (therefore 2GB or smaller);
  • the required text files may be missing; check for their presence in the root directory;
  • SD card may not be powered; check 3V3 power on the third pin from the left (second pin from the left is connected to the ground);
  • check voltage divider resistors R5, R6, R7 (under the processor) and make sure they are 4K7.


4. Pressing a buttons (Set, Menu or Plus) does not trigger the expected action:
  • button itself may be defective, either always open (there is no contact between button's terminals when button is pressed) or always closed (short between terminals); verify with a multimeter that the button works correctly;
  • look for potential shorts between the "active" terminal (connected to the processor pins D0, D1 and D2/D3, see schematic) and ground.


5. Communication error when trying to upload a sketch:
  • make sure you plugged the FTDI cable/breakout the correct way/orientation, with the Ground/Black terminal to the right;
  • check the Rx/Tx connections to the processor (pins 14 and 15); make sure that they are not cut or shorted to the ground;
  • "stk500_getsync(): not in sync: resp=0x00 error" usually indicates that the upload speed is incorrect; for the ATmega644P processor, the upload speed must be 38400 (defined as atmega644.upload.speed=38400 in boards.txt); for the ATmega1284P processor, the upload speed is 57600;
  • if you get "avrdude: Yikes!  Invalid device signature. Double check connections and try again, or use -F to override this check", temporarily modify the signature in file hardware/tools/avr/avr/etc/avrdude.conf with one of these (depending on your processor):
    • signature = 0x1e 0x96 0x0a;   //  for ATmega644P
    • signature = 0x1e 0x97 0x05;   //  for ATmega1284P

Monday, March 19, 2012

Stand for ClockTHREE

Some time ago I received, as a gift, this smart and very useful stand from fellow clock enthusiast Nicholas in San Diego. He designed it and made it specifically for ClockTHREE. Simple yet elegant, this is essential if you want your C3 on the desk or table.















I did not have the chance to appreciate it until now, with an older ClockTHREE borrowed from a friend (I gave it to him as a gift). Here is the C3 on the stand, a perfect fit!


















Thank you Nicholas! Keep up the great work!

Sunday, March 18, 2012

Wise Clock 4 - "Time Lived" menu option

At the request of AlexT, I implemented a new feature in Wise Clock 4, which allows the display of time lived (since birth) in different formats (years/months/days/hours/minutes/seconds, days only, hours only, minutes only).


















The above photo shows the year/month/day on the top row and the hours/minutes/seconds on the bottom row.


Lifetime in Wise Clock 4 from florinc on Vimeo.

The birth date and time are read from the file message.txt on the SD card.

I was inclined to use the Time library, but I found it a little bulky for my needs and also unsuitable for dates before 1970. Then, I copied and modified the function makeTime() to convert a datetime to seconds, and I wrote my own diffTime() function to calculate the difference (in years, months, days etc) between two dates.

Alternating between display modes is done by pressing the SET (middle) button.

This code will be included in the next release of Wise Clock 4 software.

Tuesday, March 13, 2012

Wise Clock 4 Dual screen chronometer

Update (June 30, 2014): This chronometer clock is complete now. It is also available in the two-sided (two-faced) version, aka "Kandinsky", as shown in these photos.

This chronometer, inspired by the Doomsday clock by Wyolum, is made with a Wise Clock 4 board (available for sale here) and two 3216 displays from Sure Electronics.



Its main feature is the odometer-style rolling of the digits when they change.
The time is updated once a second, based on the 1Hz interrupt signal from DS3231, as described here.



















As shown in the video, one button is used to change the display brightness, another button is used for changing the font, and the third is used for switching between rolling style and static style.

By using the bigger (5mm) 3216 displays with the same setup and software, this clock can be easily read from a distance of at least 100 feet (30 meters).

Source code is available here. The current version does not allow setting up the time and date from buttons.

Sunday, March 4, 2012

Details on assembling ClockTHREE v2

I just finished assembling another ClockTHREE v2 and I realized that there are details that need a bit of clarification (and not captured in the original building instructions). These are related to the orientation of the RGB LEDs and the battery holder for RTC. Not a lot of info, but I felt I have to record these, since I will have to go through the exercise of figuring it out again next time I assemble another C3.

Here are the pictures worth a thousand words.

First the LEDs, shown laying down in the correct orientation. The longest pin, the common node, is closer to the bottom of the PCB (where the ATmega328 is).


















Because the LED pins are only 0.05" apart (as opposed to 0.1" in a normal LED, or most other components for that matter), special attention must be paid when soldering these RGB LEDs. There is a tendency of shorting two adjacent pins, so make sure that doesn't happen, by checking with a magnifying glass (or with the ohmmeter). To avoid the possible shorts, I bend the pins outwards, away from each other, as shown below.



















Note: One of the advantages of C3 v2 over C3 v1 is that the RGB LEDs can be inserted directly, all the way through, without the need to use the bending tool (as shown in the tutorial for v1).

Second, the battery holder. If you use one like mine, here is how it should be placed.


















Note that the board was smartly designed to allow the use of many types of battery holders, including those all-metal ones (either SMD or through-hole).

Also shown are the pull-up resistors required if you solder the DS3231 RTC chip directly to the (back of the) board (and not use the ChronoDot).

Another detail worth mentioning is that the buzzer I am currently using in Wise Clock 3/4 gives a very faint sound when used in C3/C3Jr.