Using Sound cmd on 16F88


Closed Thread
Results 1 to 24 of 24
  1. #1
    Gator_sound's Avatar
    Gator_sound Guest

    Default Using Sound cmd on 16F88

    Hi all,

    I've been trying to generate a sound on the 16f88 for the past couple of weeks and have no luck generating a good sound. I'm using a piezo speaker, I can get a sound but nothing significant enough to wake a person up. I looked through the various threads on this forum but no luck. I've looked through the PBP manual and I set it up to the dot. I used the code:

    sound portb.1 [127,1]

    I want to be able to generate a loud enough alarm buzzer to wake a person up. Any help would be greatly appreciated. Thank you so much in advance.

    gator_sound

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Consider this schematic.
    If it works for you, you need to pull the buzzer pin low after each sound command.
    For example:

    sound portb.1, [127,10]
    low portb.1




    <img src="http://img8.picsplace.to/img8/21/buzzer.GIF" alt="Image Hosting by PicsPlace.to" >
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Knowing your piezo-speaker resonnant frequency you should be able to produce a louder sound. Use a simple High/pauseUS/low/pauseUS loop or HPWM to produce the right resonnant frequency.

    Experimentation will give you the right resonnant frequency, kinda piezo g-spot. Closer you are, louder it is
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    ... piezo g-spot. Closer you are, louder it is
    Hi Steve,

    Is it true in other cases, too?



    ---------------
    Last edited by sayzer; - 7th October 2006 at 20:56.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    LMAO! i guess it would depend of the hardware
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply sayzer and mister_e. I've tried both of your methods but but just the capacitor is louder then the npn transistor unless I am connecting it incorrectly. Any other suggestions? Thanks again for your ideas and help.

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Provide your piezo part # so we could try to find the g-spot of it !
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Most piezo's oscillate at their resonant frequency when a DC voltage is applied.

    The SOUND command outputs a complex form of PWM that is intended to produce a sudo Sine Wave when used with a Low Pass Filter. This won't allow the piezo to oscillate very well at all.

    To get the Loudest sound, use sayzer's circuit (with 12V) then set the pin HIGH. (Don't have your ear too close or you'll lose it).

    Of course, I wouldn't want to wake up with that sound. It's more like a Smoke Detector high pitch blast.

    If you want a better sound using the SOUND command, run it through a low pass filter, then amplify it, then use a normal speaker instead of a piezo.
    <br>
    DT

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gator_sound
    I'm using a piezo speaker, I can get a sound but nothing significant enough to wake a person up.
    That raise a question about the part you're using...Is that a simple Piezo or a transducer? If you put 5V across.. what happen? continuous sound or nothing else than a single 'tick'...


    Piezo buzzer
    piezo sounder
    piezo transducer
    ....
    ....
    ...

    Part # will be handy.
    Last edited by mister_e; - 8th October 2006 at 09:33.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    Its a cheap Radio Shack Piezo Element 1500-3000Hz Buzzer (#273-073):

    I get a working continuous buzzing sound in it but its not loud enough. I used a function generator and it produced a better sound than what I'm getting from my PIC. Hope this info helps.

  11. #11
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gator_sound
    ...1500-3000Hz.. I used a function generator and it produced a better sound than what I'm getting from my PIC...

    Since you are using Note 127, you are driving your piezzo by 10,000Hz.
    Check Sound command details to find the correct Note number which should give you a frequency between 1500-3000Hz. So g-spot of this piezzo has been found & touched!


    Quote Originally Posted by mister_e
    LMAO! i guess it would depend of the hardware
    Quote Originally Posted by mister_e
    Provide your piezo part # so we could try to find the g-spot of it !
    The hardware is ticking like a Swiss clock. No doubt on that!
    But, sometimes when you know for sure that you are not even close to g-spot, you still get a loud sound. How about that?




    -------------------------------
    Last edited by sayzer; - 8th October 2006 at 19:58.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  12. #12
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sayzer
    But, sometimes when you know for sure that you are not even close to g-spot, you still get a loud sound. How about that?
    I could disgress and talk about using the right i/o but...

    Gator, use HPWM and a loop like that
    Code:
    Freq var Word
    
    Start:
        For Freq=1500 to 3000 step 100
            HPWM 1,Freq, 127
            Pause 200
            next
        Goto Start
    You'll notice some 'volume' change on every different frequency, choose the louder one. Using the Sayzer driver circuit will add to your pleasure.

    OR use your function generator, measure the frequency once you hit the louder frequency, and apply it on the HPWM command.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  13. #13
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Hi mister_e,

    Are you talking about using the HPWM on the 16f88 or a PIC with a physical PWM pin?

  14. #14
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Both.. THE PIC16F88 have a built-in PWM module... also named CCP.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  15. #15
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    mister_e,

    Thank you and sayzer for the information. If its not too much of a hassle is it possible to provide an example for the PWM using the CCP register. I'm still trying to get used to programming in basic. Programming in assembly has thrown me off when I'm thinking about programming in basic. Thanks in advance.

  16. #16
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    HPWM will handle it for you. if 8 bit resolution is enough, it's the easiest way.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  17. #17
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    I've tried a lot with piezo-summers... (without any circuit in them!)!

    Forget it !

    Buy readymade Piezo-beepers for intrusion-detection !

    Piezo-beepers are allowed to have 24 Volt accross them. So I have used a circuit to double the power (5V -> 10V) with one pin of the PIC and loaded a 1000uF condensator. Then I use a MOSFET-driver ICL7667 to drive the beeper from this 10V. It is loader, but using some cheap magnetic beepers from digisound is much more easy....

    ;-)
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  18. #18
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    BigWumpus,

    Do you have a part number or a particular place where I can purchase a ready made piezo-beeper? thanks.

  19. #19
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Digisound F/UCW 03 or ...06
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  20. #20
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Hi everyone,

    I finally got a PIC with HPWM. Is there anything else I have to setup aside from the ccp1con? Thanks

  21. #21
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Which pic is it?

    PR2, T2CON are others most likely.


    ----------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  22. #22
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Hi sayzer,

    its a 18f1320 with the HPWM without the HPWM 16f88. thanks

  23. #23
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi Gator,

    18f1320 has "Enhanced CCP module" which is more complicated then the others.
    Also it has four PWM outputs, P1A through P1D, and this makes CCP1CON register more complicated to be set.

    It is over my head, and I have zero experience in it. I am eager to learn it though as I will have to work with 6pwm channels soon.

    May be our highly experienced members can give you hand on that? and you can post the ongoing progress here...


    -----------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  24. #24
    Gator_sound's Avatar
    Gator_sound Guest


    Did you find this post helpful? Yes | No

    Default

    Its finally working. The code (sound command) was right but not sure why it did not work. I changed the output pin and now its working. Thanks for those who have replied. I really appreciate it.

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  3. Alfat Sd/mmc
    By eoasap in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 24th July 2006, 06:10
  4. Sound and sound control with minimal parts
    By bartman in forum General
    Replies: 23
    Last Post: - 18th January 2005, 14:08
  5. Re: quick fix for sound command?
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 9th July 2004, 01:44

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