Cake Timer

Wichit Sirichote, wichit.sirichote@gmail.com

Build a timer for baking a cake, simple interval settings, single chip MCU PIC16F684


This Cake Timer alarms with light blinking or Buzzer on the preset time has ended. The circuit is built with the Microchip PIC16F684, 14 pin microcontroller. Interval selection is done by single button press. Preset time is 3, 5, 10, 15, 20, 25, 30, 35 mins. The firmware is developed with Mikro-C for PIC.
CAKE Timer v1.0

Schematic (click to enlarge)

The MCU, PIC16F684 is operated with internal 8MHz oscillator. Thus no need external clock source. RC0-RC5 drives LED1 to LED6. RA2 drives LED7 and RA5 drives LED8. These LED is super bright surface mounting device with dimension 3528. The buzzer output, RA0 drives Q1 for either D3 or LS1 selected by SW3 manually. SW1 actives LOW connected to RA4 for interval selection.

An optional OPTO isolator NPN output driven by RA1 is for external device control.

J1,1.7mm DC JACK accepts +5V from any USB POWER socket.

Component layer

 

Bottom layer, where the 3528 LED and SW1 are soldered.

Firmware listing

The timebase is 15Hz, produced by internal timer0 interrupt.

sbit relay at PORTA.B1; // relay output
sbit buzzer at PORTA.B0; // buzzer output                  
sbit key1 at PORTA.B4; // select time
sbit key2 at PORTA.B3; // optional input switch
sbit tick_out at PORTA.B1;
sbit LED1 at PORTC.B0;
           sbit LED2 at PORTC.B1;
           sbit LED3 at PORTC.B2;
           sbit LED4 at PORTC.B3;
           sbit LED5 at PORTC.B4;
           sbit LED6 at PORTC.B5;
           sbit LED7 at PORTA.B2;
           sbit LED8 at PORTA.B5;
         
char tick, tick_led;
           char tick2=0;
char sec;
           unsigned int min=0;
char press=-1;
           char state =0;
char cw=0;
           unsigned int my_sec=0;
unsigned int preset_length=0, save_preset;
           char run=1;
           char test=0;
           char fire =0;
           char programmed=0;
           char set_hour=0;
unsigned int length;
         
unsigned int adc;
           char release=0;
           char select=0;
           unsigned set_time=0;
void read_key()
           {
   if(key1 == 0 && release==0 && fire==0)
   {
   release=1;
   select++;
   
   switch(select)
   {
   case 1: LED1=1;LED2=0;LED3=0;LED4=0;LED5=0;LED6=0; LED7=0;LED8=0; set_time= 3*60; relay=1; break; // 3 mins
   case 2: LED1=1;LED2=1;LED3=0;LED4=0;LED5=0;LED6=0; LED7=0;LED8=0; set_time= 5*60; relay=1; break; // 5 mins
   case 3: LED1=1;LED2=1;LED3=1;LED4=0;LED5=0;LED6=0; LED7=0;LED8=0; set_time= 10*60; relay=1; break; // 10 mins
   case 4: LED1=1;LED2=1;LED3=1;LED4=1;LED5=0;LED6=0; LED7=0;LED8=0; set_time= 15*60; relay=1; break; // 15 mins
   case 5: LED1=1;LED2=1;LED3=1;LED4=1;LED5=1;LED6=0; LED7=0;LED8=0; set_time= 20*60; relay=1; break; // 20 mins
   case 6: LED1=1;LED2=1;LED3=1;LED4=1;LED5=1;LED6=1; LED7=0;LED8=0; set_time= 25*60; relay=1; break; // 25 mins
   case 7: LED1=1;LED2=1;LED3=1;LED4=1;LED5=1;LED6=1; LED7=1;LED8=0; set_time= 30*60; relay=1; break; // 30 mins
   case 8: LED1=1;LED2=1;LED3=1;LED4=1;LED5=1;LED6=1; LED7=1;LED8=1; set_time= 35*60; relay=1; break; // 35 mins
 
   case 9: select=0; LED1=0;LED2=0;LED3=0;LED4=0;LED5=0;LED6=0; LED7=0;LED8=0; relay=0; break;
 
   }
   
   tick =0;
   buzzer =0;
   
   
   }
   
   }
shut_down_buzzer()
           {
   if(key1 == 0 && fire==1)
   {
   fire =0; buzzer=0; relay=0; // turn off buzzer
   select=-1;
   
   
   
   }
 
}
// 15Hz interrupt
           void interrupt() 
           {
   if (TMR0IF_bit) 
   {
   TMR0IF_bit = 0;
 tick++;
             
   tick_out ^=1; // check tick frequency
   
   read_key();
   if(key1) release=0;
   
   shut_down_buzzer();
   
   if(tick2++ >=10 && fire == 1)
   {
   tick2=0;
   buzzer ^=1;
   
   }
         
 if(tick>=15 && select !=0 )
   {
   tick=0;
 if(select==1) LED1 ^=1;
   if(select==2) LED2 ^=1;
   if(select==3) LED3 ^=1;
   if(select==4) LED4 ^=1;
   if(select==5) LED5 ^=1;
   if(select==6) LED6 ^=1;
   if(select==7) LED7 ^=1;
   if(select==8) LED8 ^=1;
 set_time--;
             
   if(set_time== 30*60)
   {
   LED8 = 0;
   select= 7;
 } 
             
   if(set_time== 25*60)
   {
   LED7 = 0;
   select= 6;
 } 
             
   if(set_time== 20*60)
   {
   LED6 = 0;
   select= 5;
 }
   if(set_time== 15*60) 
   {
   LED5 = 0;
   select= 4;
   
   }
   
   if(set_time== 10*60)
   {
   LED4 = 0;
   select= 3;
 }
             
   if(set_time== 5*60)
   {
   LED3 = 0;
   select= 2;
 }
             
   if(set_time== 3*60)
   {
   LED2 = 0;
   select= 1;
 }
 if(set_time==0 && fire==0)
   {
   fire=1;
   relay = 0; // turn off relay
   select=0;
   tick2=0;
   LED1=0; // LED2=0; LED3=0; LED4=0; LED5=0; LED6=0; LED7=0; LED8=0;
 }
   }
   
   }
   
         
}
 
void main() {
             
   OSCTUNE = -3; // get 15.038Hz interrupt calibrated at 5V 28C
   
   OPTION_REG = 0x07; // Assign prescaler to TMR0
   ANSEL = 0; // Configure PORTA to digital I/O
   CMCON0 = 7; // ANSELH = 0;
   
   WDTCON = 0x16; // WDT clock/65536
   
   WPUA = 0xff;
   
   TRISA = 0x18;
   PORTA = 0;
   
   relay=0;
   buzzer=0;
   
   TRISC = 0; // PORTC is output
   PORTC = 0; // Initialize PORTC
 INTCON = 0xA0; // Enable TMRO interrupt


   while(1)
   {
   asm CLRWDT;
   }
         
}
Source code (compiled with Mikro-C for PIC v6.0 )

 

Prototype box is made with Plastwood PVC 4mm

 

Micro slide switch selects between LIGHT blinking alarm or Buzzer

SVG design for dial overlay

 

PARTS LIST

Semiconductors

PVN1 PIC16F684, 14-pin DIP Miicrochip Microcontroller
Q1,Q2 BC337, NPN small signal transistor
U1 4N26, NPN output optoisolator (optional)
D12 1N5221
D13 1N4733

D1,D2,D4,D5,D6,D7,D8,D9, LED
D10, super bright RED color
D3 LED 3528 SMD super bright WHITE color
D11 LED 3528 SMD super bright RED color

Resistors (all resistors are 1/8W +/-5%)


R1,R3,R4 1k
R2 680
R5 20

Capacitors

C1 100nF
C2 220uF +10V

Additional parts


JP1 HEADER 2
J1 DC Input, 1.7mm DC jack
LS1 BUZZER
SW1 SELECT 12mm TACT switch
SW2 12mm TACT switch (optional)
SW3 Micro slide switch
PCB double sides printed circuit board

More information, please contact Wichit Sirichote, wichit.sirichote@gmail.com

Download

Source code, SVG Dial sheet


<


December 5 , 2021