Jump to content
43oh

MSP430G2xxx Tea Timer


Recommended Posts

Here is my entry for the November 2010 Project of the Month Contest, an MSP430G2xxx based tea timer!

 

I love tea, and thought this contest was an excellent reason to actually get off of my lazy behind and put this together.

 

Below is my blog post on it, modified slightly to show the pictures and code here rather than just link to them as on my blog. Blog post is available here: http://blog.suspended-chord.info/?c=27

 

Below this point is the post:

------------------------------------------------------

Hello all,

 

I am an avid tea drinker. As such, I make many cups of various kinds of tea, each with their own optimal steep times. Usually, I just keep track of the time, but I have found that I can make the best cup of tea by setting a timer to go off after a certain amount of time, depending on the style of tea that I am brewing. I find the best results come from going by the following table (based on personal preference and experimentation):

 

 

Tea Variety => Recommended Steep Time

White tea => 2 minutes

Green tea => 3 minutes

Black/Oolong tea => 4 minutes

Herbal tea/infusions (most varieties) => 5 minutes

Rooibos tea (African redbush) => 6 minutes

Chai tea (regardless of base) => 8 minutes

Kukicha twig tea and other varieties => in intervals of 1 minute

 

 

With this in mind, I decided that I should make a tea timer. This seems simple enough, and it has been on my to-do list for a while anyway, and 43oh! is having an MSP430 Project of the Month Contest, so I decided to hack it together. Turned out rather simple.

 


  • The full part count is as follows:
    [*:3snbat08] 3 toggle switches (or a 3-switch DIP, as I used)
    [*:3snbat08] 4 10k resistors
    [*:3snbat08] 1 5mm green LED
    [*:3snbat08] 1 piezo buzzer with integrated driver circuit
    [*:3snbat08] 1 tact switch/push button
    [*:3snbat08] wire
    [*:3snbat08] Any MSP430 uC with at least 1k flash and a TimerA module (though I could have hacked the WDT to work)

 

So, I assembled the circuit on my breadboard, following the schematic at the end of my post, and programmed the MSP430.

 

For the code, I borrowed beretta's TimerA code example, and tweaked it to fit the needs of my timer. The timer is to read the input value of the three switches as a binary value to determine tea type, set a "goal" amount of half-second ticks based upon the user's request, and when the user presses the "start" button, go into a waiting period. While the uC is waiting, the LED will be flashed slowly at first, but increasingly faster as the timer ticks closer to the goal. Once the goal amount of ticks has been reached, the LED will be turned on, and the buzzer will sound (mine sounds reminiscent of an old-fashioned tea kettle, so it's suitable). The buzzing can be stopped by pressing the "start" button again to reset the device, and allow another time to be set. Simple enough, right?

 

The code is available:

// MSP430 based Tea Timer
// Sets off a buzzer to let you know when your tea is done steeping
// Supports several types of tea

// suspended-chord (http://blog.suspended-chord.info)

/* Tea steeping chart
  Tea type             Time         DIP Code
  ------------------------------------------
  White                2 minutes         000
  Green                3 minutes         001
  Black/Oolong         4 minutes         010
  Herbal               5 minutes         011
  Chai                 8 minutes         100
  Rooibos              6 minutes         101
  Other                1 minute          110
  Other 2              30 seconds        111
*/

// circuit:
// LED on P1.0
// Piezo buzzer with driver on P1.1
// 3-switch dip (or 3 toggle switches) on P1.4, P1.5, and P1.6
// push button tact on P1.3, pullup resistor

//#define DEBUG

#define __MSP430G2231__
#include 

// pin for status LED
#define LED BIT0
// pin for buzzer
#define BUZZER BIT1
// pin for start switch
#define START BIT3
// three consecutive pins for mode selection
#define INPUT1 BIT4
#define INPUT2 BIT5
#define INPUT3 BIT6
// numeric value of the first pin
#define SHIFT 4
// unused bits
#define UNUSED BIT2 + BIT7

// variables
unsigned int goal = 0;
unsigned int tickCount = 0;
unsigned char statusCount = 0;
char statusMode = 0;
char mode = 0;
char reset = 0;
volatile unsigned int i = 0;

void main() {
 while(1) {
   WDTCTL = WDTPW + WDTHOLD; // kill wdt
   P1OUT = 0; // clear outputs
   P1DIR = LED + BUZZER + UNUSED; // setup outputs and unused to out/low to reduce power consumption


   BCSCTL1 = CALBC1_1MHZ; // setup DCO
   DCOCTL = CALDCO_1MHZ;

   // setup TimerA
   TACCR0 = 62499; // .5s cycle with 1MHZ clk and /8 divider

   // delay a few cycles to debounce
   i = 0;
   while (i < 50000) i++;

   while ((P1IN & START) == START) { // keep setting mode until start switch is pressed
     // setup mode
     mode = (P1IN & (INPUT1 + INPUT2 + INPUT3)) >> SHIFT;

     // setup goal
     switch (mode) {
       case 0: // white tea
         goal = 240; // 2 minutes
         break;
       case 1: // green tea
         goal = 360; // 3 minutes
         break;
       case 2: // black/oolong tea
         goal = 480; // 4 minutes
         break;
       case 3: // herbal tea
         goal = 600; // 5 minutes
         break;
       case 4: // chai tea
         goal = 960; // 8 minutes
         break;
       case 5: // rooibos tea
         goal = 720; // 6 minutes
         break;
       case 6: // other
         goal = 120; // 1 minute
         break;
       case 7: // other2
         goal = 60; // 30 seconds
           break;
         default:
           goal = 0;
      }
    }

#ifdef DEBUG
   goal = 30; // 15 seconds
#endif  

   // reset the TAR, and finish setting up TimerA
   TACTL = TASSEL_2 + ID_3 + MC_1 + TACLR; // select SMCLK/8, up mode, and clear the TAR
   TACCTL0 = CCIE; // enable interrupts

   // enable interrupts
   _enable_interrupt();

   // turn on LED
   P1OUT |= LED;

   // reset variables
   statusCount = statusMode = tickCount = reset = 0;

   // enter LPM1
   //LPM1;
   while (reset == 0);
 }
}

// timerA interrupt for CCR0
#pragma vector = TIMERA0_VECTOR
__interrupt void CCR0_ISR (void) {
 tickCount++; // increase tick count

 // toggle LED increasingly faster as the time counts towards the end
 statusCount++;
 if (tickCount >= goal/4) statusMode = 1;
 if (tickCount >= goal/2) statusMode = 2;
 if (tickCount >= 3*(goal/4)) statusMode = 3;
 switch (statusMode) {
   case 0:
     if (statusCount >= 4) { // blink every 2 seconds
       P1OUT ^= LED; // toggle LED
       statusCount = 0;
     }
     break;
   case 1:
     if (statusCount >= 3) { // blink every 1.5 seconds
       P1OUT ^= LED; // toggle LED
       statusCount = 0;
     }
     break;
   case 2:  
     if (statusCount >= 2) { // blink every 1 second
       P1OUT ^= LED; // toggle LED
       statusCount = 0;
     }
     break; 
   case 3: default: // blink every .5 second
     P1OUT ^= LED; // toggle LED
     statusCount = 0;
     break;
 }

 if (tickCount >= goal) {
   _disable_interrupt(); // kill interrupts
   TACCTL0 &= ~CCIE; // disable TimerA CCR0 interrupt
   //LPM1_EXIT; // exit LPM1
   P1OUT |= LED + BUZZER; // buzzer + LED on
   while ((P1IN & START) == START); // if START pressed, return to main()
   reset = 1;
 }
}

 

Basically, as I stated above, the user selects a mode (tea type) by way of the three switches, and then presses a button to start the timer. When the tea is done steeping, the buzzer goes off, and the user can press the button again to reset it. The switch positions corresponding to the tea types are as follows:

 

6, 5, and 4 refer to P1.6, P1.5, and P1.4

6 5 4 Tea type (time)

0 0 0 White Tea (2 minutes)

0 0 1 Green Tea (3 minutes)

0 1 0 Black/Oolong Tea (4 minutes)

0 1 1 Herbal Tea/Infusions (5 minutes)

1 0 0 Chai Tea (8 minutes)

1 0 1 Rooibos Tea (6 minutes)

1 1 0 Other1 (1 minute)

1 1 1 Other2 (30 seconds)

 

 

Now, this isn't the most accurate timer, as I'm not using the crystal, but it's accurate enough to steep a good cup of tea (believe me, I've used it a lot since I hacked it together), and my stopwatch tells me it's accurate to within around 6 seconds on average.

 

In the future, I'd like to use a better input mechanism (I might be geeky enough to remember binary codes for tea types, but most are not, so a rotary switch or something would be perfect), maybe a cheap LCD for a status indicator, even showing how much time remains, and potentially having the last two codes (110 and 111) be user programmable for any time in second increments up to half of an unsigned long (as the ticks are half-second ticks). Maybe even shove it all into an Altoids tin for portability and the geek-chic factor. Who knows?

 

Anyways, here's the schematic, and a photo of it in action:

 

teatimer.png

Tea-Timer in action! (notice the LaunchPad is only used as a power supply here... I don't have a battery clip yet.)

 

schematic.png

schematic

 

Thanks for reading!

 

Keep tweaking~

 

EDIT: I'm an idiot sometimes... I forgot the code and images.

Link to post
Share on other sites

A very innovative use for the MSP430, gatesphere. Did you make use of the MSPHere library in this one.. just curious.

White tea => 2 minutes
Green tea => 3 minutes
Black/Oolong tea => 4 minutes
Herbal tea/infusions (most varieties) => 5 minutes
Rooibos tea (African redbush) => 6 minutes
Chai tea (regardless of base) => 8 minutes
Kukicha twig tea and other varieties => in intervals of 1 minute

Although I like tea, I haven't heard of these many.

Link to post
Share on other sites
A very innovative use for the MSP430, gatesphere. Did you make use of the MSPHere library in this one.. just curious.

Actually, I did not. I was considering it, but I haven't written the WDT/TimerA functions for MSPhere yet (they're next on my list) so it would have been an ugly hybrid of vanilla C and MSPhere. I tend to not like blending APIs like that, just personal preference.

 

White tea => 2 minutes
Green tea => 3 minutes
Black/Oolong tea => 4 minutes
Herbal tea/infusions (most varieties) => 5 minutes
Rooibos tea (African redbush) => 6 minutes
Chai tea (regardless of base) => 8 minutes
Kukicha twig tea and other varieties => in intervals of 1 minute

Although I like tea, I haven't heard of these many.

Like I outlined in my post... I really like tea. :P I highly suggest trying some rooibos tea some time. It's often sold in the US as "African redbush" or just plain "red tea". It's a bit spicy, really energizing and mind-revitalizing, and with a bit of a naturally sweet aftertaste. It's great. I know that Yogi Tea sells it in bags (check your local Wegman's or the like), and most organic food stores sell it loose in bulk, for use with a tea ball. It's great.

 

Thanks for the comments!

Link to post
Share on other sites
great work

but i will stick with my ginger lemon and honey tea :)

:) That falls under Herbal tea/infusions. I got you covered :P

 

Instead of 3 switches, why not a linear pot, using the adc to sample the voltage?

I wanted precise control over which of the 8 times would be selected. Like I said, in the future, I'll probably use an 8 position rotary switch to change the input mechanism.

Link to post
Share on other sites
how did u show the picture of your project via a link? my photos weren't showing and i uploaded some but non-members can't see them.

You can use the "Img" button (or just insert tags of that name) and a URL for the image to link a photo. Not sure if they'll show for guests that way either, though.

Link to post
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

×
×
  • Create New...