43oh

# Vetinari's Clock

## Recommended Posts

I figured you guys might be interested in some of my tinkering with the Launchpad.  Hopefully by putting a few of my projects up here it will also keep me accountable for finishing them.

This is one a cobbled together a few months ago.  It's been up on the MCU projects page on E2E, so you might have already seen it: http://e2e.ti.com/group/microcontrollerprojects/m/msp430microcontrollerprojects/664670.aspx

PROJECT OVERVIEW

The Vetinari clock is from a book series known as Discworld, where Lord Verinari has a clock in his waiting room which has an irregular tick. The idea of the clock is to add a sense of unease and anxiety to anyone in the waiting room since their brain doesn't filter out the ticks like a normal clock. Here's a video to get a better idea of the result.  The tick is actually a lot louder in person.

SOFTWARE DESIGN

To accomplish this task on a 430, we create an array of possible time frames to tick the clock, and parse through it at 4Hz. The array is 32 entries long, so it equates to 32 seconds in the real world. By randomly setting 32 of the elements high, we create a timing sequence. A high element will generate a tick of the clock. This means a second on the clock can be as little as 250ms, or as long as 24 seconds, and still keep accurate time.  Check the attached software too see how it's all done; I did my best to comment it up.  main.c

HARDWARE DESIGN

The clock coil is driven via an alternating polarity pulse.  The easiest way to change a load's polarity with an MCU is using an h-bridge.

The schematic shown is a simple implementation using two NPN and two PNP transistors.  I had the transistors and drive resistors laying around, so this part was easy to cobble together (along with the half used battery holder).  It would be easy to use a single IO pin per side of the bridge, but the transistors fit better onto the launchpad, as shown in the image.  To add the driving resistors in series, I cut a small gap in the traces, scrapped off the solder mask on either side to make pads, and put down a small SMA resistor.  It's not pretty, but it works.

In the clock mechanism, there is a small control board with a crystal and epoxy glob IC that normally runs the clock.  I just ripped that out and directly attached the coil to the h-bridge.

The resulting clock is actually more maddening than I expected in a quiet environment.  By using 3V rather than the 1.5V that the original movement used, the ticks are much more pronounced and do an excellent job of ruining a person's calm.

• Replies 54
• Created

#### Popular Posts

I figured you guys might be interested in some of my tinkering with the Launchpad.  Hopefully by putting a few of my projects up here it will also keep me accountable for finishing them.   This is o

Brilliant! I made a shameless copy of your design last night by modifying a \$3 clock from KMart. It's tethered to my launchpad at the moment, but a standalone board with one of my spare 2452's will be

I've improved the code a little, so here is my updated version. Fixes include: 1. Using a bit array instead of a byte array, dramatically reduces the amount of RAM used, so that smaller MSP430's can

#### Posted Images

perfectly evil, I will have to make one for work

##### Share on other sites

You're a terrible person for building this!

Why do you use an entire launchpad for this, not just the MSP430? You are currently powering the emulator part as well, so your batteries are probably going to run out relatively fast.

##### Share on other sites

@@roadrunner84 This is part of the accountability.  I had all the hardware built to test the timings and never got around to moving it to a stand alone build.  The clock is sitting on someone elses desk now (I have no idea why he enjoys it so much), so I need to steal it back and finish it.

Edited by bluehash
Placing a ":" after the member name when using @mention does not work. Corrected.
##### Share on other sites

This is worse than an Annoyatron. haha!

##### Share on other sites

You're a terrible person for building this! ;-)

Why do you use an entire launchpad for this, not just the MSP430? You are currently powering the emulator part as well, so your batteries are probably going to run out relatively fast.

The way you have the power hooked up, you could just remove all the jumpers and you would not be powering the emulator circuit.  Since you've modded this LP, might as well just do that and save battery.

BTW: I've been dying to make one of these!

##### Share on other sites

I just noticed yesterday that the clock in my office died....so it looks like this is in my future

##### Share on other sites

The way you have the power hooked up, you could just remove all the jumpers and you would not be powering the emulator circuit.  Since you've modded this LP, might as well just do that and save battery.

BTW: I've been dying to make one of these!

That's a really good point, don't know why I didn't think of that in the first place.

##### Share on other sites

I have wanted someone to make one of these for ages! Fantastic job. I imagined it having a bit less deviation (i.e., each tick being maybe a tenth to a fifth of a second off) but this is just great.

##### Share on other sites

I agree with dannyboy that the unevenness should be more subtle. That was the point of the clock I believe. Maybe have a switch for a subtle and a demo mode. Very nice build though.

##### Share on other sites

It would be fairly trivial to make a more subtle mode.  At the 1sec mark, you just wait a "random" number of cycles before ticking.  The center point of the random number's distribution would be the perceived second.  This would add the jitter and still keep it accurate.

The Launchpad still has the buttons enabled, so those can be used to switch modes if you like.

I think I'll have to grab this back from my coworker when I'm back in the office to add the suggestions you guys have posted.

##### Share on other sites

I've got a clock with a similar mechanism which keep poor time. I was going to replace the mechanism but I'm tempted to make one of these. Than again, I seem to be able to annoy my wife quite enough with geeky stuff without doing it on purpose!

I was also wondering whether the MSP430L092 would be a better fit for working with the existing 1.5V cell and coil. The cost of the dev kit (\$149) compared to the LaunchPad kind of kills that idea though.

##### Share on other sites

Brilliant! I made a shameless copy of your design last night by modifying a \$3 clock from KMart. It's tethered to my launchpad at the moment, but a standalone board with one of my spare 2452's will be in the  not-to-distant future. I would assume the crystal in the clock is 32.768kHz - the one on the clock board has nice long pins, so I'll solder it onto my standalone board to. It only took about half an hour to set this up. This morning, after about 12 hours, the clock is still running accurately. I did have to increase the energize time slightly - at the 0x4000 figure you used, I found the clock would occasionally start running backwards for a few ticks.  My clock doesn't give a very distinct tick - I'm thinking of adding a little speaker to make the tick a bit more noticeable.

Thankyou so much for the idea - my office at work will shortly have a unique timepiece.

##### Share on other sites

Here's a little video of my version of your clock.

Oh, and I forgot to mention in my previous post - I actually pasted your code direct into Energia, because for some reason my CCS is broken and won't start.  I was expecting a fairly major rewrite, but it turned out the only change I had to make was alter the definition of main() to be "int main(void)", apparently mspgcc is quite picky about that.  On Energia it compiled to be a mere 500 bytes. Curiously, changing the tick time from 0x4000 to 0x2000 reduced the compile size to 475 bytes, (0x2000 made my backwards problem worse though).  Increasing it to 0x4800 resulted in a compile size of 495 bytes. Obviously mspgcc is able to make some optimisations in __delay_cycles() depending on the value passed.  Because it is such a small code size, at some stage I might see if I can modify it to use a bit array instead of a byte array, so that the RAM requirement becomes small enough to use on a 2231.

Edited by bluehash
##### Share on other sites

The link you posted is to your uploads section (when I click it, it goes to my uploads section).  Can you give us a link to the video's page?

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
• Blog

• #### Activity

×
• Create New...