Re-Programming ClockTHREE and ClockTHREEjr

At some point, you may wish to re-program your ClockTHREE or ClockTHREEjr or maybe you are building a clock from scratch.  This post will walk you through the steps.

(Sorry, the formatting is not behaving.  Try this file if you are having trouble.)

Outline:

  1. Download and install Arduino for your target platform.  (More details can be found here.)
    • Navigate to the Arduino download site: http://arduino.cc/en/Main/Software
    • Download Arduino for your platform.
    • Unzip the file to the directory of your choice.  (We will refer to whatever directory you choose as <arduino_dir>).  I use c:\arduino\ on Windows or /home/justin/arduino/ on Linux so that (for arduino 22 for instance) the path extracted executable is c:\arduino\arduino-0022\arduino.exe on Windows or /home/justin/arduino/arduino-0022/arduino on Linux.
  2. Download and install ClockTHREE source code
    • Download the latest ClockTHREE library source code file from here: http://code.google.com/p/clockthree/downloads/list
    • Unzip the library source code file in your home directory. I use “My Documents\sketechbook\” on windows and /home/justin/sketchbook/ on linux.  We will refer to the directory you choose as <sketchbook>.
  3. Point Arduino to your newly extracted library files.
    • Start arduino (look here if you have trouble with this step)
    • Click File->Preferences to pull up the preferences menu.
    • Leave “Use external editor” unchecked if you plan on using Arduino as your editor.
    • Click the “Browse” button and navigate to your <sketchbook> directory from step 2.
    • Click “OK”.
    • Close and restart Arduino
    • Click “File->Sketchbook->libraries”.  If “ClockTHREE” is listed you’ve done well.
  4. Using a text editor, edit source code: set compile options and language
    • On or about line 55 in the file <sketchbook>/libraries/ClockTHREE/ClockTHREE.h, uncomment (for ClockTHREEJr) or comment out (for ClockTHREE) the following line.
    #define CLOCKTHREEJR // uncomment this line for ClockTHREEjr
    
    • On or about line 32 of <sketchbook>/libraries/ClockTHREE/examples/ClockTHREE_02.pde, comment out all but one of the following lines depending on language and hardware.
    // #include "english.h" // only need one language at a time
    // #include "german.h"
    #include "english_jr.h"
    // #include "german_jr.h"
    
    • On or about line 292 of <sketchbook>/libraries/ClockTHREE/examples/ClockTHREE_02.pde, comment out all but one of the following lines depending on language and hardware.
    // English faceplate = English();      // Only need one at a time
    // German faceplate = German();
    EnglishJr faceplate = EnglishJr();
    // GermanJr faceplate = GermanJr();
    
  5. Compile and upload
    • Connect the FTDI cable to ClockTHREE (mind color labels) and to your computer.
    • Click Tools->Boards->Duemilanove
    • Select USB port Tools->Serial Port (this may take some trial and error if you have several devices connected).
    • Compile and upload <sketchbook>/libraries/ClockTHREE/examples/ClockTHREE_02.pde.
      Click the arrow button, second from the right.  Right when the black message area at the bottom of the Arduino window displays the message “Binary sketch size:…” click the reset button on ClockTHREE.  The timing can be tricky so you may have to experiment. 
  6. Congratulations!  That is it.  Now you can customize the code to your hearts content!

Announcement: I2SD, A disk drive for Arduino

WyoLum is proud to announce I2SD which provides disk drive storage to your Arduino based project.

I2SD is an I2C interface for an SD card compatible with ClockTHREE and ClockTHREEjr.  The idea behind I2SD is to allow easy read/write access to files stored on an SD card.  If the I2C bus is already part of a circuit, I2SD does not require any extra pins, therefore optimizing pin usage on the micro.

Thanks to AdaFruit and SparkFun for sharing there SD designs!

Why I2SD? Good question!  After all there are a few boards that allow you to connect an SD card to your project: AdaFruit’s data logging shield, and SparkFun’s MicroSD shield are two stand outs in this category.

There are three reasons you should consider I2SD:

  1. ATMEGA328 memory limitations.
  2. ATMEGA328 pin count.
  3. You want a small form factor stand alone data logger.

On ClockTHREE we are both pin count and memory limited and we wanted to be able to store lots of cool animations.  We designed for the stand alone data logger as a target of opportunity.

 

The next rev will sport optional locations for an RTC chip and battery back up.

Details

Components:

  • ATMEGA328
  • SD card
  • 2 LEDs
  • ChronoDot or DS3231 (optional)

Interfaces:

  • 6-pin ISP
  • FTDI
  • 2x C3SB (see below)
  • Buckler (see below)

Using I2SD from an Arduino Master (Buckler interface see below)

Currently there are five methods implemented for simple file reading and writing.

  ping(uint8_t* ping_data, uint8_t n_byte);
  seek(unsigned long addr);
  open(char* filename, uint8_t mode);
  read(uint8_t *data, uint8_t n_byte);
  write(uint8_t *data, uint8_t n_byte);
Which can be used to read and write a small file:

 //Write a file
 i2sd.open("NEW_FILE.TXT", FILE_WRITE);
 char* msg="Hello from I2SD_Client.pde. "
           "Please note this is longer than 32 chararters.";
 i2sd.write((uint8_t*)msg, strlen(msg) + 1);

//Read it back
 i2sd.open("NEW_FILE.TXT", FILE_READ);
 uint8_t msg_back[100];
 unsigned long n_byte = i2sd.read(msg_back, 100);
 msg_back[n_byte] = NULL;
 Serial.println((char*)msg_back);
 write(uint8_t *data, uint8_t n_byte);

C3SB (preview)

This is the first peripheral to implement the ClockTHREE Serial Bus interface which deserves a post of its own (coming).   Its like USB for Arduino which allows the connection of many peripherals without increasing pin usage.  C3SB is build on I2C

 

C3SB physical interface, 4 pins with 0.1″ spacing:

  1. VCC — 5V min 100mA
  2. SCL — I2C Clock pin
  3. SDA — I2C Data pin
  4. GND — +0V

C3SB software Master interface:

I2C transfers are limited to 32 bytes.  The C3SB allows up to 255 bytes by breaking them up to 32-byte I2C packets for you.  Two read/write functions.

uint8_t read_from(uint8_t device_id,
                  uint8_t* dest,
                  uint8_t n_byte);

boolean write_to(uint8_t device_id,
                 uint8_t *payload,
                 uint8_t n_byte);

Buckler form factor (preview)

A “buckler” is a small shield, 15 to 45 cm (6 in to 18 in) in diameter , gripped in the fist (From Wikipedia).  I2SD is a small shield so we thought this was a clever name for this form factor.

ClockTHREEjr give-away answers.

Here are the answers to the ClockTHREEjr give-away challenge.

On the challenge sheet, puzzlers were challenged to find and solve five puzzles around the Maker Faire NC venue.  The “hint” was that there were a few logos on the clue sheet that indicated which booths are presenting challenges.  In no particular order the five booths were:

  • Shopbot
  • opensource.com
  • Harris Educational
  • Bull City Craft
  • wyolum.com

On the back of the challenge sheet, were 100 2-digit numbers, each associated with a code word or phase.  These were the 100 possible answers of the five booth puzzles.

Shopbot was giving away QR code pendends.  If you took a picture of the QR code with your smart phone, you ended up a a webpage that listed the uses for “CNC”.  One of the uses was “the answer to the ClockTHREEjr challenge”.  The answer was was of course “CNC”.

Opensource.com had another tough challenge.  One of thier designers was there in the morning and drew documents with red hair (like Little Orphan Annie) on thierr whiteboard. For anyone who needed more help, Ruth explained what orphan works are (http://opensource.com/business/10/12/cookbooks-orphans-and-out-print-books). Nevertheless, one guy decided the answer was “butter cream.” 😀

Harris Educational had another pictogram puzzler:  They had a picture up of: a baseball cap, the letter “A”, and sitting dog.  The answer was cap+A+sitter or capacitor.

The clue for Bull City Craft was just a list of numbers.  If you looked around their booth they had a numbered color chart.  If you took the first letter from each of the colors indicated by numbers, you came up with “kangaroo”

The WyoLum puzzle was similar.  We had a string of numbers and letters: “A13B3C10D13E2”.  We were passing out business cards with the ClockTHREEjr faceplate printed on the back with the time “Its four o’clock” displayed which was also the time that the final clue was to be given out.  If you noticed the letters increasing from “A” to “E” in the string, it might have occured to you that the letters were indicating a row of the ClockTHREE faceplate.  The numbers by default would be the column.  The answer was “laugh”.  My 11 year old daughter Elizabeth came up with that great challenge.

If you solved all five puzzles you ended up with five answers and five two digit numbers.  A couple of clever teams realized that the initial letter of each answer was an anagram for “Clock” and were convinced that that was the answer to the whole puzzle.  We assured them that they would know when they won and that they should “keep going”.

At 4:00 we revealed the final clue.

_ _ _ _ _THREEjr.

Almost everyone filled in the blank with “Clock” but were flummoxed when we encouraged them to keep going.  Our winners realized very quickly the numbers still have not been used and that they were not a red herring.  “Clock” indicated the order to put the 10 digits in which gave a phone number.  When they called the number, they won!!!

Thanks to everyone who participated!  We had a great time putting it together!