Simple question about "Sound" command


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582

    Default Simple question about "Sound" command

    Hi !
    I made one thermostat, with PIC16F628A and LCD display, for using as thermo-regulator. All works fine, but ... I want to have an audible "mark" when temperature is bigger/smaller than setting.
    I wrote this :
    Code:
     If Temperature > Temp_Up then          ' Above Target temperature 
      PORTA.2=0                             ' Deactivate Warm output
      PORTA.3=1                             ' Activate   Cold Output
    SOUND PortA.7, [107,50]
     EndIf
    But in this way the buzzer sound WHILE Temperature > Temp_Up ... How can be setting to sound just 5 seconds, for example ?
    Thanks in advance !

  2. #2
    Join Date
    Dec 2011
    Location
    IO93ok
    Posts
    190


    Did you find this post helpful? Yes | No

    Default Re: Simple question about "Sound" command

    I'm thinking this must be in a larger loop structure to keep returning to the routine.

    How about this as an idea only:

    Code:
    If Temperature > Temp_Up then           ' Above Target temperature
      PORTA.2=0                             ' Deactivate Warm output
      PORTA.3=1                             ' Activate   Cold Output
    SOUND PortA.7, [107,50]
    temp_up = temp_up +5                     'or 10 or whatever
    endif                                    'as long as reset elsewhere

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Simple question about "Sound" command

    You need a flag to remember that you've already sounded the alarm.

    Code:
    AlarmDone VAR BIT
    
    IF Temperature > TempUp THEN
      PortA.2 = 0
      PortA.3 = 1
      IF AlarmDone = 0 THEN          ' Only activate alarm if not already activated.
        SOUND PortA.7, [107, 50]
        AlarmDone = 1                   ' Alarm has been activated.
      ENDIF
    ELSE
      AlarmDone = 0                   ' Temperature is not over the limit, rearm the alarm.
    ENDIF

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Simple question about "Sound" command

    Thanks for reply !
    The second variant work verry fine. THANK YOU, Mr.Henrik ! As usual, You're a Great Gentleman !
    Last edited by fratello; - 10th July 2012 at 11:13.

Members who have read this thread : 0

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