Alarms with Mel's "Olympic Timer" based timer - how to?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default Alarms with Mel's "Olympic Timer" based timer - how to?

    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)?

    Code:
    ' 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
    Roger

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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...

    Code:
    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...

    Code:
    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...

  3. #3
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    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.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Nestyplus's Avatar
    Nestyplus Guest


    Did you find this post helpful? Yes | No

    Thumbs up Nice to hear from you again Melanie

    Quote Originally Posted by Melanie View Post
    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

  6. #6
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Hmm. Ok then Mel. So now aimed at anyone in the manufacturing sector....

    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.
    Last edited by muddy0409; - 19th June 2007 at 12:18. Reason: Spelling again
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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

Similar Threads

  1. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts