PDA

View Full Version : Alarms with Mel's "Olympic Timer" based timer - how to?



flotulopex
- 19th June 2007, 06:00
Hi there,

I'm stuck in trying to make a multiple alarms-timer based on Melanie's "Olympic Timer".

Doing it the way it is here, the timer will mess-up and the sound stop only after a little time (20 to 40 seconds).

This is probably due to the SOUND command witch takes to much time to execute and blocks the interrupt count or so.

I have the feeling it is not possible to get this working this way.

Can anybody confirm?

I think, I'll better go for a RTC (yes/no)?


' Fuses
@ DEVICE PIC12F675, XT_OSC ;Xtal 4MHz
@ DEVICE PIC12F675, WDT_OFF
@ DEVICE PIC12F675, PWRT_OFF
@ DEVICE PIC12F675, MCLR_ON
@ DEVICE PIC12F675, BOD_OFF
@ DEVICE PIC12F675, PROTECT_OFF
@ DEVICE PIC12F675, CPD_OFF

'-------------------------------------------------------------------------------
' Registers 76543210
CMCON = %00000111 'Comparator OFF
ANSEL = %00000000 'Analog/Digital ports
OPTION_REG = %00000101 'Pull-Ups ENabled, TMR0 prescaler 1:64=16.384 ms
INTCON = %10100000 'GPIO.2 External Interrupt enabled
GPIO = %00000000 'Ports High/Low
TRISIO = %00000000 'Set Input/Output

'-------------------------------------------------------------------------------
' Variables
Ticks var byte
Second var byte
Minute var byte
Hour var byte
Buzzer var GPIO.2
DOutPin var GPIO.1
Update var byte

second = 0
Minute = 0
hour = 0
Update = 0

'-------------------------------------------------------------------------------
' Program
On Interrupt Goto tick_int
MAIN:
if Update = 1 then
update = 0
if second = 0 and minute = 9 and hour = 0 then goto beep1
if second = 0 and minute = 27 and hour = 0 then goto beep1
endif

BEEP1:
sound buzzer,[100,10,50,10]

goto main
end

'-------------------------------------------------------------------------------
' Time Counter - Interrupt Service Routine to handle each timer tick
disable ' Disable interrupts during interrupt handler (or ISR)
TICK_INT:
Ticks = Ticks + 1 'Count pieces of seconds
If Ticks < 61 Then TICK_INT_RESET 'Continue count
' if Ticks >= 61, 1 second elasped => update time
Ticks = 0
Second = Second + 1
If Second >= 60 Then
Second = 0
minute = minute + 1
If minute >= 60 Then
minute = 0
Hour = Hour + 1
Endif
Endif
Update = 1

TICK_INT_RESET:
INTCON.2 = 0 'Reset timer interrupt flag and continue de Ticks count

Resume
enable

Melanie
- 19th June 2007, 07:12
Do it in stages and learn along the way...

The program text explained that you can't do anything that takes more than about 10mS... so...

rather than this...



MAIN:
if Update = 1 then
update = 0
if second = 0 and minute = 9 and hour = 0 then goto beep1
if second = 0 and minute = 27 and hour = 0 then goto beep1
endif

BEEP1:
sound buzzer,[100,10,50,10]

goto main


If you simply did this...



Main:
if (minute=9 and hour=0) then
Buzzer=1
else
if (minute=27 and hour=0) then
Buzzer=1
else
Buzzer=0
endif
endif


Then for one whole minute at those two designated Hours and Minutes the Buzzer pin will go high. This assumes you put Buzzer=0 somewhere at the very start of the program when it first comes alive and initialises.

Check if this works for you FIRST...

Then you can work out how you can move on from there and make the pin modulate something in the available time slot to drive a sounder...

muddy0409
- 19th June 2007, 07:25
Mel. Welcome back! Thought we'd seen the last of you, what with your new Executive job and all.

Is it possible to discuss something with you, outside this forum. Not really about this forum but rather a bit of brain picking on how to go about something.

Melanie
- 19th June 2007, 07:36
I rarely have time Peter, but I do click the link every now and again.

Basically, like the Olympic Timer in this thread, if it's going to take longer than about 10mS (length of time to down half a cup of coffee), then no.

Nestyplus
- 19th June 2007, 08:35
I rarely have time Peter, but I do click the link every now and again.

Basically, like the Olympic Timer in this thread, if it's going to take longer than about 10mS (length of time to down half a cup of coffee), then no.

Wow!, Welcome back Melanie. I thought you transferred to another forum.
Just like what you said, I too rarely do replies however I check and read the mails of those senders that makes impact in this forum and you are one on them.

Nice to hear from you again.

Thanks,
Nesty

muddy0409
- 19th June 2007, 12:17
Since 1973, (old, aint I?) I have been in the security industry. The greater majority concentrating on alarms in Banks.
Even today I find that almost all alarms can be defeated with a couple of bucks worth of components. (which I won't go into here)
Just how does one find and interest a manufacturer to look at a high security module, capable of adding to virtually ANY alarm panel which will go a long way to overcoming the above mentioned shortcomings of existing systems. I am not sure if there is anyone out there with a face I can trust (except for Mel, of course (suck, suck)) who may be in a position to perhaps look at / evaluate this device without me having to worry about it being knocked off, something I have experienced before.

I would be happy to discuss my thoughts, privately off forum with someone who may be interested.

Regards and thanks.

BobK
- 20th June 2007, 22:09
Hi Peter,

I am in the alarm industry with 32 years behind me. I design and manufacture several devices for my clients. I am interested in whatever it is you have. But I must ask you first, does your area use cellular backup systems? Or do you have access to internet alarm transmission devices? The internet seems to be the big thing up here.

If you want PM me and we can talk more. [email protected]

BobK