Dangerous Prototypes

In development => Project logs => Topic started by: Markus Gritsch on April 03, 2011, 06:59:19 pm

Title: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on April 03, 2011, 06:59:19 pm
Hi,

like everyone else, I finally built an alarm clock for my bedside table using an MSP430 which came with the TI Launchpad.

To get hold of the low pin count, I used a 74HC164 shift register for port expansion.  Thus two pins of the MSP430 are used as shift register clock and data yielding eight outputs for the anodes of the 7-segment (plus decimal point) digits.

Another four pins of the MSP430 are used to time-multiplex the four common-cathode digits, using a variable time per digit depending on the LED count, the digit is using.  This is done to get the digits equally bright.

The remaining two pins of the  MSP430 are connected to push buttons for user interaction -- one pin serving double as input and output when playing the alarm tune.

A simple finite state machine is used for the control logic.  I found the available 2048 bytes of program memory a bit sparse, needing to rewrite code sometimes to get a lower memory footprint.  The program plus the data for the tune now use even the last available byte.

In normal standby operation the circuit consumes about 2 µA -- yielding a theoretical lifespan of 10+ years assuming the 200 mAh AAA batteries won't die beforehand :)

The source code is attached below and a video can be found here:
    http://www.youtube.com/watch?v=a6q4vUfasKw (http://www.youtube.com/watch?v=a6q4vUfasKw)

Have fun,
Markus
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: arhi on April 04, 2011, 12:37:42 am
nice use of that small msp :)
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Benj87fr on April 04, 2011, 08:49:34 pm
Hello Markus,
Nice clock !
I am willing to make one.
Do you have the schematics and the BOM?
Thank you in advance,
Ben
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on April 04, 2011, 09:19:54 pm
Most of the stuff came from my junk box.  The 7-segment display is from ITead Studio costing just $2.00 (http://iteadstudio.com/store/index.php? ... cts_id=205 (http://iteadstudio.com/store/index.php?main_page=product_info&cPath=35_39&products_id=205)).  How the shift register, the buttons, the display, the LED, the buzzer, and the debounce caps are connected to the MSP430 is described at the beginning of the source code.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Rando on April 04, 2011, 09:37:27 pm
Wow! So much crammed into 2K. Amazing...

Looks like your using P 1.6, and P 1.7 for double duty as well. SW1 and SW2 and speaker drive and LED is that correct?

I was thinking about using the MSP430G2452, which has 6 more I/O pins, should I be able to get by with out shift register in that case?

Thanks, great project,

Rando
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on April 04, 2011, 09:49:33 pm
Like in the original comment said: "one pin serving double as input and output when playing the alarm tune".  More precisely, P1.6 is used as input and output.  P1.7 is just an ordinary input.

Yes, you are correct.  When I was building the clock, I did not yet have the new MSP430G2452.  If you use this chip, you do not need the shift register.  Also its 8 kB of code memory should make the coding much more relaxed :)
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Benj87fr on April 04, 2011, 10:46:26 pm
Thank you very much Markus !
Once again, congratulations for your clock !
Ben
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: simpleavr on April 05, 2011, 03:07:25 am
nice build markus

[quote author="Rando"]should I be able to get by with out shift register in that case?
[/quote]
actually even w/ the 14 pin G2211 u can omit the shift register.

here is how i had it done.

[attachment=0]

for schematic and code, etc, google "3p4w clock", i am not able to post a link here.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on April 05, 2011, 10:16:06 am
Yes, actually I got inspired to build my own alarm clock by your excellent 3p4w clock (http://www.simpleavr.com/msp430-projects/3p4w-clock (http://www.simpleavr.com/msp430-projects/3p4w-clock)).  It's very cool how you manage to get rid of most connection wires by placing the display directly over the MSP430.  However, as you pointed out, this way the pins for an external crystal are already occupied, and to get a more accurate time base, you added an external RTC chip (http://www.simpleavr.com/msp430-projects/rtc-clock (http://www.simpleavr.com/msp430-projects/rtc-clock)).

For my project, I decided to not use an external RTC chip but connect a clock crystal to the MSP430 and instead add the shift register.  Nevertheless, you were first, and your projects totally rock!
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: simpleavr on April 05, 2011, 02:22:47 pm
thanks marcus.

i have to say that u did an excellent layout, especially like the way u had the battery holder attached to a right size board. the 3p4w clock is not practical (losing time every day) and eventually i had the rtc chip added and i am really using it everyday. i might turn to a pcb / perf board constructions like yours as it looks really good.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: 2lostkiwis on June 23, 2011, 11:29:57 am
[quote author="Markus Gritsch"]Another four pins of the MSP430 are used to time-multiplex the four common-cathode digits, using a variable time per digit depending on the LED count, the digit is using.  This is done to get the digits equally bright.[/quote]

Hi Markus, do you use any series resistors for the LED display?
Cheers,
Ian.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on June 23, 2011, 02:10:57 pm
Of course not.  The average current is limited due to time-multiplexing the leds.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Sjaak on June 23, 2011, 03:20:41 pm
resistance is futile :X
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: jdegl on July 03, 2011, 02:56:10 am
i can't compile source is there any way to get compiled code.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on July 03, 2011, 09:32:22 am
I'm using CCS on Windows, and the output directory does not contain any HEX file.  There is an .out file, but I'm not sure if this of any use to you.

Has someone else here more experience with this?
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: jdegl on July 04, 2011, 12:16:40 am
i'll get it figured out.  ccs and iar are not my cup of tea. i don't like windows either.  thanks for your help.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: arhi on July 04, 2011, 06:28:46 am
by ccs you don't mean the ccs company that makes compilers ( http://www.ccsinfo.com/ (http://www.ccsinfo.com/) ) but that ti's eclipse based closed source code composer thingy?
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on July 04, 2011, 06:50:53 am
Since the CCS company has only a C compiler for PIC MCUs and my alarm clock uses an MSP430, I think there is no ambiguity :)
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: arhi on July 04, 2011, 07:06:51 am
I use a lot of CCS C (for pic) in last few days and when I seen you wrote CCS here I was super confused (as I don't remember they make compiler for anything but pic :D and I never seen code composer being referred as CCS). I tried code composer few years ago and decided that I'm not paying that much money for eclipse gui and gcc compiler when I can get those for free. I will *never* understand why hw manufacturers try to reduce their user base trying to sell dev tools for too much money... I understand 3rd party tools, but darn, both microchip, TI, motorola ... they all try to charge arm and a leg for a darn compiler .. not that I can use TI code composer to write program for PIC or vice versa :( ...
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: aravindh on December 01, 2011, 05:46:45 am
Hi Markus,

That is awesome,.. After seeing ur's i decided to do one with a slight modification. But iv just started learning to program a mocrocontroller. Fortunately i have an MSP430 Launch Pad Kit and also avr too.
Im trying to figure out your code from the scratch. i know its hard if im new to it. though im trying to split them down and identify jigsaw piceses at first then lately to put them together. at certain points i feel completely new/landed on a different planet. will work deadly on it to understand it.

i need help on schematic level like, how u'v connected the shift register to the MSP & crystal oscillator to the MSP & the pdb level layout if possible,.. im sorry if i trouble you by asking silly and dumb questions, but as i mentoned earlier im new to this microcontroller programming and also to build a bord that has a microntroller on it (essential connections to be made like crystal oscillator, capicators, resistors to the device and vcc/GND all etc,.)

As i mentioned at the very begining that a slight modification that clicked my mind, here it goes - known to me a pizo electric senser is aslo a buzzer right ,.?! im not sure its correct but just a sugesstion. pizzo buzzer has a pizo crystal in it - when faces electric field their structure gets disturbed and inturn produces "buzz" - it should also has a reverse process then - prodece some signal when there is a vibration right,.?!? if then cant we make it as an input device as well as output and make them to display time while the clock is in sleep mode by producing some king of sound or noice or any thing,.. I have a very little knowledge about circuits. I dont know that this is correct,.. can u help me to figure out this,..
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: gamer203 on July 05, 2012, 10:14:00 pm
Hello, I am a student and have taken interest in your project. When I tried to use your code to test out my clock, it turned out that I couldn't use it because you did it in C++. I tried to figure out how to make a C++ project but had no luck. Can you please  send me or post a list of instructions to get your code up and running (I am using CCS v5).
            Thanks,
                          Justin
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: henryhe on October 30, 2012, 11:37:53 am
When it comes to our comfort zone, bedside tables are a must. Books, glasses, eye-drops, beautiful alarm clock ect.

Regards,
funique
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: t0mpr1c3 on October 31, 2012, 07:07:50 pm
Looks great Markus, I might have to build this just to find out what the tune is.

Not sure it would help but perhaps replacing the modulo arithmetic might help the code compile smaller.

++hour;if(hour==24){hour=0;}

instead of

hour=++hour%24;

etc.
Title: Re: MSP430 Bedside Table Alarm Clock
Post by: Markus Gritsch on October 31, 2012, 08:58:04 pm
Good idea, thanks.  I tried it, and your suggested change saves about 8 Bytes at each occurrence.  Spoiler ahead: If you look into the source code, there is a YouTube link to the tune used :)