Thursday, February 24, 2011

Can't Have Too Many Clocks

This is the clock that started it all, the Heathkit GC-1005 Digital Alarm Clock. I build one back in the mid -70's but unfortunately I no longer have it.



Then I needed a portable time source, so I purchased a Hamilton LED watch (I still have this!)




This is the clock that restarted my interest in micro-controllers. I found it while reading a Slashdot article about open source hardware.




Since you can not have enough clocks, I got this next.



But it doesn't stop there, another clock was added to my collection.



Then Sparkfun free day came along and I won $20!

I purchased:
The display has an ATMega328 which controls all the serial communications and the 4-digit 7-segment display.


Mmmmm, I can re-purpose it and make it a clock!


The ATMega328 on this device did not have an external crystal and instead uses the built-in 8MHz oscillator. Because of this the time keeping was unstable. I connected the RF Transmitter to my Ice Tube clock and the RF Receiver to the 7-Segment display. The Ice Tube clock transmits time on the hour keeping the 7-Segment Display clock in sync.


Here is the code for the 7-Segment Clock:
Here is the code snippet for the Ice Tube clock firmware update:


void time_braodcast_init(void)
{
#define BAUD_RATE    1200
#define BAUD_REG_VAL   (F_CPU/16/BAUD_RATE-1)

  UBRR0H = (BAUD_REG_VAL >> 8);
  UBRR0L = (BAUD_REG_VAL & 0xFF);
  UCSR0B = _BV(TXEN0);
  UCSR0C = _BV(UPM01) | _BV(UCSZ00) | _BV(UCSZ01);
}

void usart_putchar(char c)
{
  while (!(UCSR0A & _BV(UDRE0)));
  UDR0 = c;
}

void broadcast_time(void)
{
  //  Broadcast time
  char buf[7];

  buf[0] = 0x00;        // sync usart
  buf[1] = 0xFF;        // sync usart
  buf[2] = 0x47;        // timeset
  cli();
  buf[3] = (time_h > 12) ? time_h - 12 : time_h;
  buf[4] = time_m;
  buf[5] = time_s;
  sei();
  buf[6] = buf[3] +buf[4] + buf[5];  // checksum
  for (int idx = 0; idx < sizeof(buf); idx++)
  {
    usart_putchar(buf[idx]);
  }
}


Add this code snippet just before the first button check in main():


    //  Broadcast time on the minute
    if (!time_s && !time_m)
    {
      broadcast_time();
    }


Add the call to time_braodcast_init() before the while(1) loop in main().


I started thinking that clocks are taking over my life, so... I built a clock that plays life! I modified the Adafruit Monochron clock code with changes I made to David Gustafik's work.


You can find the details about this modification in my May 7, 2011 blog post.


Honey I just want one more clock... Please...

So for Fathers Day I got the Nixie Transistor Clock which can be found on the Kabtronics Website.


You can find the details about this clock in my August 11, 2011 blog post.

Clock Links:
Tube Clock Database
Transistor Clock

Yet Another Balancing Robot

This is one of my first robotics projects, yet another balancing robot.


After that, I gave it some freedom to move about.



Here is the code: YaBalBot.zip