My Doctor Who MonoChron Clock

Tick Tock Clock Kits

Moderators: adafruit_support_bill, adafruit

My Doctor Who MonoChron Clock

Postby DanSlage » Fri Feb 03, 2012 1:19 pm

I am working on a Doctor Who inspired clock for the MonoChron. A video can be seen here. http://youtu.be/DHecR3Matss

The TARTIS travels through an wiggly wormhole. Pressing a button or switch (except "Menu") will cause the TARTIS to dematerialize and rematerialize a moment later in a random spot. My daughter plans on using this as her primary alarm clock once I figure out how to replace the alarm siren with the Doctor Who theme song.

I had to rewrite the wormhole code a few times to get it fast enough render correctly. The GLCD.h drawing routines are way too slow instead the wormhole uses glcdDataWrite()s directly to draw everything.

To speed things up I also EXTERMINATEd all division and modulus operations. For example to separate the hour into a high digit and low digit:

Traditional

Code: Select all
high_digit = hour/10;
low_digit = hour%10;

I found this to be much faster

Code: Select all
high_digit = 0;
low_digit = hour;
while (low_digit >= 10) {  // Count tens
  high_digit++;
  low_digit -= 10;
}

When you have as much motion as this clock does every clock cycle counts.
DanSlage
 
Posts: 3
Joined: Thu Jan 26, 2012 3:29 pm


Re: My Doctor Who MonoChron Clock

Postby odometer » Sat Feb 04, 2012 4:12 pm

What datatype is "hour"?

This is good up to 99:
Code: Select all
high_digit = 0;
low_digit = something;
if (low_digit >= 60) {high_digit += 6; low_digit -= 60;}
if (low_digit >= 30) {high_digit += 3; low_digit -= 30;}
if (low_digit >= 20) {high_digit += 2; low_digit -= 20;}
if (low_digit >= 10) {high_digit += 1; low_digit -= 10;}
odometer
 
Posts: 91
Joined: Sun Aug 21, 2011 10:01 pm

Re: My Doctor Who MonoChron Clock

Postby DanSlage » Sat Feb 04, 2012 5:11 pm

Nice Odometer! The datatype is uint8_t but never goes larger than 59 in my program. My gut tells me your code would be faster than mine. I wonder if anyone has ever done any speed trials.
DanSlage
 
Posts: 3
Joined: Thu Jan 26, 2012 3:29 pm

Re: My Doctor Who MonoChron Clock

Postby Nicodemus_NJ » Wed May 23, 2012 11:20 am

I hate to be "that guy" but... It's TARDIS! (Time and Relative Dimension in Space)

:)
Nicodemus_NJ
 
Posts: 1
Joined: Wed Apr 27, 2011 10:36 am

Re: My Doctor Who MonoChron Clock

Postby kscharf » Wed May 23, 2012 12:29 pm

DanSlage wrote:I am working on a Doctor Who inspired clock for the MonoChron. A video can be seen here. http://youtu.be/DHecR3Matss

My daughter plans on using this as her primary alarm clock once I figure out how to replace the alarm siren with the Doctor Who theme song.


Sounds like you need to interface a wave shield to the clock some how.
User avatar
kscharf
 
Posts: 136
Joined: Wed Sep 10, 2008 9:29 am

Re: My Doctor Who MonoChron Clock

Postby JakeS » Wed May 23, 2012 4:41 pm

Hi-

Saw your project featured in the Adafruit blog- nice!

We did a Dr. Who song through a piezo speaker an on Arduino. I used an existing program for the piezo frequencies and sound generation, which I have forgotten and can't attribute, sorry! We only figured out the melody and the timing.

Code: Select all
const int  b=     4056;    // 261 Hz
const int  c=     3830;    // 261 Hz
const int  d=     3400;    // 294 Hz
const int  e=     3038;    // 329 Hz
const int  f=     2864;    // 349 Hz
const int  g=     2550;    // 392 Hz
const int  a=     2272;    // 440 Hz
const int  B=     2028;    // 493 Hz
const int  C=     1912;    // 523 Hz
const int  D=     1700;    // 523 Hz
const int  E=     1508;    // 523 Hz
const int  F=     1432;    // 523 Hz
const int  G=     1278;    // 523 Hz
const int  A=     1136;    // 523 Hz
// Define a special note, 'R', to represent a rest
const int  R=     0;

int speakerOut = 13;

int melody[] = { b,  C,  B,  D,  a,  B,  B, g,  d,  b,  d, c, b,R } ;
int beats[]  = { 8,  8, 48,  8,  8, 64,  8, 8,  8,  8, 16, 16,16,96 } ;
int MAX_COUNT = 14; // Melody length, for looping.

// Set overall tempo
long tempo = 10000;
// Set length of pause between notes
int pause = 1000;
int rest_count = 100; //<-BLETCHEROUS HACK; See NOTES

for(int js=0; js<20; js++) {
   for (int i=0; i<MAX_COUNT; i++) {
    tone_ = melody[i];
    beat = 4*beats[i];

    duration = beat * tempo; // Set up timing

    playTone();
    // A pause between notes...
    delayMicroseconds(pause);
   }
}

void playTone() {
  long elapsed_time = 0;
  if (tone_ > 0) { // if this isn't a Rest beat, while the tone has
    //  played less long than 'duration', pulse speaker HIGH and LOW
    while (elapsed_time < duration) {

      digitalWrite(speakerOut,HIGH);
      delayMicroseconds(tone_ / 2);

      // DOWN
      digitalWrite(speakerOut, LOW);
      delayMicroseconds(tone_ / 2);

      // Keep track of how long we pulsed
      elapsed_time += (tone_);
    }
  }
  else { // Rest beat; loop times delay
    for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count
      delayMicroseconds(duration); 
    }                               
  }                                 
}
JakeS
 
Posts: 10
Joined: Tue Feb 22, 2011 11:15 am

Re: My Doctor Who MonoChron Clock

Postby adafruit » Thu May 24, 2012 5:31 pm

I second using the piezo to just play the theme, it sounds good on Tesla coils so a piezo should be fine too :)
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc


Return to Clocks

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
Android[6]
 
BeagleBone[24]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]