Digital Clock with Alarm addressing, help!

Status
Not open for further replies.

tushiro

New Member
A friend of mine is asking me to help her for a project in school. She's planning on working with Digital Clock with alarm addressing. The project will be set that each hour, the bell alarm will turn on and a pre-recorded music will be played. I've search the archieves and there are tons of circuit for a digital clock, the problem is most them are using a Pic which is not available here in our place, if there is, we dont even have a Pic writer. I was planning to build the clock using a LS192 and a 555 timer since we have a very limited resources but a friend called up and offer me if im interested in buying an OOPic 3. The first time I posted a thread here somebody suggest using an OOPic for embedded system design, after that, been searching for it and its uses. my question is, can I use OOPic 3 for the project that my friend is proposing? Thank you.
 
Last edited:

hi,
Use the forum Search for digital clock there are lots of posts/diagrams.
 
@eric:

as i've said, I already have done that and almost everyone is using a Pic. We dont have a Pic writer avaible here. my question is if I can work on the said project in OOPic 3 because as far as I know it comes with a parallel port connection to your PC. Thank you.
 
In my blog I also design Digital Clock with Alarm Function.
Please Check it out



View attachment 62091

$regfile = "m8535.dat"
$crystal = 12000000

'------------------------ lcd -------------------------------------------------
Config Lcd = 16 * 2
Config Lcdpin = Pin , Rs = Pina.0 , E = Pina.1 , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7

'--------------------------- ds 1307 -----------------------------------------
$lib "ds1307clock.lib"
'configure the scl and sda pins
Config Sda = Portc.7
Config Scl = Portc.6
'address of ds1307
Const Ds1307w = &HD0 ' Addresses of Ds1307 clock
Const Ds1307r = &HD1

'------------------------------ key --------------------------------------------
Config Pinc.1 = Input
Config Pinc.2 = Input
Config Pinc.3 = Input
Config Pinc.4 = Input
Config Portd.2 = Output

$eeprom

'-------------------------------------------------------------------------------
Dim Seco As Integer , Mine As Integer , Hour As Integer , , Al1 As Integer , Al2 As Integer

'-------------------------------------------------------------------------------
Cursor Off
'------------------------------------------------------------------------------
Cls
Locate 1 , 1
Lcd " Digital Clock "
Waitms 100
Cls

'-------------------------------------------------------------------------------
Main:
Do
Gosub Ds1307
Gosub 24_12
Gosub Chekkey
Gosub Alarm
Loop

'-------------------------------------------------------------------------------
Ds1307:
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 0 ' start address in 1307
I2cstart ' Generate start code
I2cwbyte Ds1307r ' send address
I2crbyte Seco , Ack 'sec
I2crbyte Mine , Ack ' MINUTES
I2crbyte Hour , Nack ' Hours
I2cstop

Seco = Makedec(seco) : Mine = Makedec(mine) : Hour = Makedec(hour)

Return

'------------------------------------------------------------------------------
24_12:
If Pinc.4 = 1 Then Gosub Disply_24
If Pinc.4 = 0 Then Gosub Disply_12
Return

'------------------------------------------------------------------------------
Disply_24:

Locate 1 , 1
Lcd "Clock = " ; Hour ; ":" ; Mine ; ":" ; Seco ; " "
Locate 2 , 6
Lcd "(24 Hour)"
Wait 1

Return

'------------------------------------------------------------------------------
Disply_12:


If Hour = 0 Then Hour = 12
If Hour > 12 Then Hour = Hour - 12

Locate 1 , 1
Lcd "Clock = " ; Hour ; ":" ; Mine ; ":" ; Seco ; " "
Locate 2 , 6
Lcd "(12 Hour)"
Return

'-------------------------------------------------------------------------------
' Select the settings
'-------------------------------------------------------------------------------
Chekkey:

If Pinc.1 = 0 Then
Cls
Bitwait Pinc.1 , Set
Locate 1 , 1
Lcd "****Setting****"
Locate 2 , 1
Lcd "Time"
Locate 2 , 12
Lcd "alarm"
Do
Loop Until Pinc.2 = 0 Or Pinc.3 = 0

'-------------------------------------------------------------------------------
' Set clock
'-------------------------------------------------------------------------------
If Pinc.2 = 0 Then
Cls
Bitwait Pinc.2 , Set
Locate 1 , 1
Lcd "**Setting Time**"
Locate 2 , 1
Lcd "Time = " ; Hour ; ":" ; Mine ; " "

Do
If Pinc.2 = 0 Then
Incr Hour
Waitms 10
If Hour > 24 And Pinc.4 = 1 Then Hour = 0
If Hour > 12 And Pinc.4 = 0 Then Hour = 0
End If
If Pinc.3 = 0 Then
Decr Hour
Waitms 10
If Hour < 0 And Pinc.4 = 1 Then Hour = 24
If Hour < 0 And Pinc.4 = 0 Then Hour = 12
End If

Locate 2 , 1
Lcd " " ; Hour ; ":" ; Mine ; " "
Loop Until Pinc.1 = 0

Bitwait Pinc.1 , Set
Gosub Hour
Waitms 10

Do
If Pinc.2 = 0 Then
Incr Mine
Waitms 10
If Mine > 60 Then Mine = 0
End If
If Pinc.3 = 0 Then
Decr Mine
Waitms 10
If Mine < 0 Then Mine = 60
End If

Locate 2 , 1
Lcd " " ; Hour ; ":" ; Mine ; " "
Loop Until Pinc.1 = 0

Bitwait Pinc.1 , Set
Gosub Mine
Waitms 10
Cls
End If

'-------------------------------------------------------------------------------
' set alarm
'-------------------------------------------------------------------------------
If Pinc.3 = 0 Then
Cls
Bitwait Pinc.3 , Set
Waitms 10
Readeeprom Al1 , 2
Waitms 10
Readeeprom Al2 , 4
Waitms 10
Locate 1 , 1
Lcd "*Set alarm*"

Do
If Pinc.2 = 0 Then
Incr Al1
Waitms 10
If Al1 > 24 And Pinc.4 = 1 Then Al1 = 0
If Al1 > 12 And Pinc.4 = 0 Then Al1 = 0
End If
If Pinc.3 = 0 Then
Decr Al1
Waitms 10
If Al1 < 0 Then Al1 = 24
End If

Locate 2 , 1
Lcd " " ; Al1 ; ":" ; Al2 ; " "
Loop Until Pinc.1 = 0

Writeeeprom Al1 , 2
Waitms 10
Bitwait Pinc.1 , Set

Do
If Pinc.2 = 0 Then
Incr Al2
Waitms 10
If Al2 > 60 Then Al2 = 0
End If
If Pinc.3 = 0 Then
Decr Al2
Waitms 10
If Al2 < 0 Then Al2 = 60
End If

Locate 2 , 1
Lcd " " ; Al1 ; ":" ; Al2 ; " "
Loop Until Pinc.1 = 0

Writeeeprom Al2 , 4
Waitms 10
Bitwait Pinc.1 , Set
Cls
End If
End If

'-------------------------------------------------------------------------------
Mine:
Mine = Makebcd(mine)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 1 ' starting address in 1307
I2cwbyte Mine
I2cstop
Return
'-------------------------------------------------------------------------------
Hour:
Hour = Makebcd(hour)
I2cstart ' Generate start code
I2cwbyte Ds1307w ' send address
I2cwbyte 1 ' starting address in 1307
I2cwbyte Hour
I2cstop
Return

'-------------------------------------------------------------------------------
Alarm:
Readeeprom Al1 , 2
Waitms 10
Readeeprom Al2 , 4
Waitms 10
If Al1 = Hour And Al2 = Mine Then
Portd.2 = 1
Do
Loop Until Pinc.1 = 0
End If
Reset Portd.2
Return
 
Last edited by a moderator:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…