how building sound tone and runing other instructions in background


Closed Thread
Results 1 to 5 of 5
  1. #1
    ustredna's Avatar
    ustredna Guest

    Smile how building sound tone and runing other instructions in background

    please help me,


    How building sound tone and runing other instructions in background

    tone duration cca. 5 sec.
    and other program are runing.
    mcu type is 16F84A and xtal is 4Mhz.

    all help in my email:

    tnx.
    Peter / ustredna
    Last edited by Archangel; - 17th January 2016 at 19:56.

  2. #2
    Join Date
    Mar 2014
    Location
    Pakistan
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: how building sound tone and runing other instructions in background

    i have same question any answer ?

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: how building sound tone and runing other instructions in background

    use a timer interupt.

  4. #4
    Join Date
    Mar 2014
    Location
    Pakistan
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: how building sound tone and runing other instructions in background

    here is my code for pic16f72 ,i want to generate a beep for 2 sec without pause inside the inverter loop when program shift from acmode: to inverter: mode or inverter to acmode ,i used sound command but it gives pause of 2 sec,i m using piezo buzzer driven by bc 547 ,hpwm pin is also free any sugestion?

    INVERTER:

    ;---------------------
    b1=1
    pauseus x
    b1=0
    pauseus y
    ;------------------------
    adcin 1,ct
    adcin 2,batt

    if ct > 127 then loadtrip
    if batt < 50 then lowbatttrip


    if batt >127 then
    LED20=1:led40 =1:led60=1:led80=1:led100=1
    endif
    if batt < 127 and batt>120 then
    led20=1:led40 =1:led60=1:led80=1:led100=0
    endif

    if batt < 120 and batt>110 then
    led20=1:led40 =1:led60=1:led80=0:led100=0
    endif
    if batt < 50 then
    led20=1:led40 =1:led60=0:led80=0:led100=0
    endif
    '------------------------
    b2=1
    pauseus x
    b2=0
    pauseus y
    ;---------------------------

    adcin 0,ac
    adcin 3,fixvolt

    if fixvolt > 127 then
    z=z+10
    endif
    if fixvolt < 127 then
    z=z-10
    endif

    while z>9000
    z=9000
    wend
    while z<1000
    z=1000
    wend
    x=9000-z
    y=1000+z
    if ac > 127 then acmode
    If SW = 0 Then SWITCH
    '----------------
    goto inverter

  5. #5
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    198


    Did you find this post helpful? Yes | No

    Default Re: how building sound tone and runing other instructions in background

    I think there are several methods you ay use.

    You could have an interrupt routine that beeps for a short time, repeatedly. In the interrupt set a flag that increments with each very short beep until it has been on long enough then, disable the interrupt. Pseudo code:


    INTERRUPT:

    Flag = flag + 1
    Make short beep
    if flag = 100 then flag = 0 and turn off interrupt

    Main:
    If error then turn on interrupt
    code
    code
    goto Main

    Or, as an alternative, you could make or buy a buzzer module. When you need noise, turn it on with a single pin, when you don't - turn it off same way.

    Or, as you suggest your PWM pin is free, wire up the buzzer there. As PWM runs independently of code...
    Last edited by Amoque; - 15th January 2016 at 13:26.

Members who have read this thread : 1

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