Multi alarm clock

gillesp

New Member
Hello,
I would like to preamble that I am a newbie at this so pardon my ignorance.
I want to build a clock that can set off with 6 to 8 alarms at different times of the day. I would like to program it on my PC and then have it run on it's own (independant of the PC) in it's own project box. A message could also be displayed on the LCD as a reminder. I am looking at using the axe033/LCD display along with the DS1307 RTC and a piezo buzzer to sound off the alarm. Maybe also adding a flashing LED.
My questions are:
-Does anyone know of a project like this, already mapped out (parts, programming etc). I have done several searches and did not find anything like it.
-Can this be accomplished with these parts alone or do I need any extra Picaxe chip in the mix. I suspect That I will need a way of driving the buzzer and LED.
-Is the AXE033 just a driver for the LCD display or does it have Pic basic capability.
-Would I be better off using a serial LCD, an 18X or 28X Picaxe and the RTC.
Any extra comment, suggestions would be appreciate. I need to be steered in the right direction and I am sure some of you have the advanced knowledge to help me.
Thank you so much in advance for your help.
Gilles
 

MBrej

Member
Hey, it should be easy enough to do.

You will need another PICAXE, (the lcd screen does have one but it only drives the display), such as a 18x if you intend to use a RTC as it uses i2c, i dont think a bigger pic is necessary, (unless you want a flashy new 28x1, as they are not actually that more expensive).

As for programming the clock with the computer, it could be done 'on the fly' (im not sure if this is what you originally intended) using the serial terminal. It should be straight forward to get the picaxe to serin data, just get the picaxe to wait for a pre "agreed" string, and on receiving that string, it can add the following alarm value. I would suggest you write this value to the picaxe's eeprom memory so its kept when you remove the power.

As a site thought, should you wish to serin alarm data, the serin command waits until it receives data, so if you wanted to program your clock, you would have to reset it, and put it in 'program mode,' perhaps with a little switch or jumper, which is checked at startup so the clock knows what mode to enter, either that or use a 28x1 which has hardware serial in and can background receive and doesnt have this problem :)

Matt
 

hippy

Ex-Staff (retired)
I wrote this ...

http://homepage.ntlworld.com/the.happy.hippy/picaxe/nqds1307.txt

And that has enough I/O to control an AXE033 display but I'm not sure it has enough program and data memory to handle all the alarm functions you need. You'd have to update the code for what you'd want especially if you wanted more than day and time functions or wanted to add automaitic daylight saving adjustment. It doesn't need an additional DS1307 though.

It should give you encouragement though that what you want to do is possible.
 

BeanieBots

Moderator
I've done something similar but only two 'alarms'.
It's an aquarium controller. Two user settable timed light settings. (alarms).
I started the project long before the AXE033 had I2C so I opted to fit the RTC chip on the board with the PICAXE. (a 28X by the way).
My app needed a timing reference as well as the actual real time (for the PID temp control part) so having the RTC on board also made it possible to use the 1Hz output from the chip. A very useful feature.
All that fit nicely into the old 28X.
The RTC chip also has 57 bytes of battery backed RAM which is a useful place to store your alarm settings.
Just three push-buttons to make all the setting. A menu button and two other buttons for "inc" and "dec" of the selected value to be changed.

Certainly a VERY PICAXEable project.
 

mproia

Member
Code request

I've done something similar but only two 'alarms'.
It's an aquarium controller. Two user settable timed light settings. (alarms).
I started the project long before the AXE033 had I2C so I opted to fit the RTC chip on the board with the PICAXE. (a 28X by the way).
My app needed a timing reference as well as the actual real time (for the PID temp control part) so having the RTC on board also made it possible to use the 1Hz output from the chip. A very useful feature.
All that fit nicely into the old 28X.
The RTC chip also has 57 bytes of battery backed RAM which is a useful place to store your alarm settings.
Just three push-buttons to make all the setting. A menu button and two other buttons for "inc" and "dec" of the selected value to be changed.

Certainly a VERY PICAXEable project.
BeanieBots can you post this code??????
 

BeanieBots

Moderator
I did, several years ago. It's in the archives somewhere.
I've had several PC re-builds since then so don't know if I still have it in electronic form. If I can find it then I'll post the relevant part but don't hold your breath.
 

BeanieBots

Moderator
OK, found an early version.
It's too large to post the complete program but here are the relevant sections.

The 'alarm' times are held in the user RAM part of the RTC clock chip.
The first routine gets the time data and displays it on a AXE033 type LCD.
The second routine checks the RTC data to see if an 'event' is required.
Sorry about the lack of comments and variable assignments but it was one of my very early programs and written before symbol and If/then/else structures were available with PICAXE.

Code:
Show_Time:
	readi2c 0,(b0,b1,b2,b3)
	serout 6,N2400,(254,192,"  ")
	branch b3,(RTC_Err,Sun,Mon,Tue,Wed,Thu,Fri,Sat)
RTC_Err:
	'serout 6,N2400,("  CLOCK ERROR   ")
	poke msg_ptr,$10
	Gosub msg
	Return
Sun:
	serout 6,N2400,("Sun")
	goto time
mon:
	serout 6,N2400,("Mon")
	goto time
Tue:
	serout 6,N2400,("Tue")
	goto time
Wed:
	serout 6,N2400,("Wed")
	goto time
Thu:
	serout 6,N2400,("Thu")
	goto time
Fri:
	serout 6,N2400,("Fri")
	goto time
Sat:
	serout 6,N2400,("Sat")
time:
	b3=b2/16
	b4=b2 & $0F
	b5=b1/16
	b6=b1 & $0F
	b7=b0/16
	b8=b0 & $0F
	serout 6,N2400,(" ",#b3,#b4,":",#b5,#b6,":",#b7,#b8,"    ")
Return
'**********************************************************************************
Timer_Events:	'Subroutine to check timed functions
	readi2c 0,(b0,b1,b2)			'get RTC values
	readi2c $10,(b4,b5,b6,b7,b8,b9)

	Event_1:	'Day lights on
	If b2 <> b5 then Event_2
	If b1 <> b4 then Event_2
	If b0 > $10 then Event_2
	High Lights_Day

	Event_2:	'Night lights on
	if b2 <> b7 then Event_4
	if b1 <> b6 then Event_4
	if b0 > $10 then Event_3
	High Lights_Night

	Event_3:	'Day lights off
	if b0 < $20 then Event_4
	if b0 > $30 then Event_4
	Low Lights_Day

	Event_4:	'Night lights off
	if b2 <> b9 then Events_Done
	if b1 <> b8 then Events_Done
	if b0 > $10 then Events_Done
	Low Lights_Night

	Events_Done:
Return
If anything is not clear please don't hesitate to ask.


This is part of the very large interrupt routine used to set all the parameters.
I've only shown the bits related to setting time and alarm times.
Hopefully, it is enough on it's own to get you started without all the other supporting code.
'state' is just a ram location I use for the 'state machine' variable so that the interrupt routine knows what it is supposed to be updating and what the 'display' routine should be showing on the LCD at any given time.

Code:
Set_T_Time_clk:
	poke state,6
	b4=1
	goto Set_T_Time_A

Set_T_Time_On:
	b4=$10
	poke state,7
	goto Set_T_Time_A

Set_T_Time_Off:
	b4=$12
	poke state,8
	goto Set_T_Time_A

Set_T_Time_Off_2:
	b4=$14
	poke state,9

Set_T_Time_A:
	readI2C b4,(b2,b3)
	poke T_Time_MM,b2
	poke T_Time_HH,b3

Set_T_Time:
	peek T_Time_MM,b2
	peek T_Time_HH,b3
	b4=b2/16
	b5=b2 & $0F
	b6=b3/16
	b7=b3 & $0F
	serout LCD,N2400,(254,192,"Done   ",#b6,#b7,":",#b4,#b5,"      ")
	if b1=6 then Int_Loop
	if b1=7 then Int_Loop
	if b1=8 then Int_Loop
	if b1=9 then Int_loop
	goto Int_End

Inc_T_Time:'(BCD)
	peek T_Time_MM,b2
	peek T_Time_HH,b3
	b2=b2+1
	b4=b2 & $0F
	if b4 <= 9 then Inc_T_done
	b2=b2+6
	if b2 <= $59 then Inc_T_done
	b2=0
	b3=b3+1
	b4=b3 & $0F
	if b4 <= 9 then Inc_T_done
	b3=b3+6
  Inc_T_done:
	if b3 <= $23 then Inc_T_done_2
	b3=0
  Inc_T_done_2:
	poke T_Time_MM,b2
	poke T_Time_HH,b3
	goto Set_T_Time

Dec_T_Time:
	peek T_Time_MM,b2
	peek T_Time_HH,b3
	b2=b2-1
	b4=b2 & $0F
	if b4 <= 9 then Dec_T_Done
	b2=b2-6
	if b2 <= $59 then Dec_T_Done
	b2=$59
	b3=b3-1
	b4=b3 & $0F
	if b4 <= 9 then Dec_T_Done
	b3=b3-6
	if b3 <= $23 then Dec_T_Done
	b3=$23
  Dec_T_Done:
	poke T_Time_MM,b2
	poke T_Time_HH,b3
	goto Set_T_Time


Save_T_Time_clk:
	b4=1
	goto Save_T_Time

Save_T_Time_on:
	b4=$10
	goto Save_T_Time

Save_T_Time_off:
	b4=$12
	goto Save_T_Time

Save_T_Time_off_2:
	b4=$14

Save_T_Time:
	peek T_Time_MM,b2
	peek T_Time_HH,b3
	writeI2C b4,(b2,b3)
	goto Int_exit
'************************
Int_Exit:
	poke Read_CTR,1
	poke State,0
	gosub display_temp
	goto Int_End

Int_Loop:
if pin0 <> 0 then Int_End
pause 250
goto Int_Start

Toggle_main:
toggle lights_day
goto Int_End
 
Last edited:
Top