• AVR Freaks

Hot!Hearing tone

Author
Rafia
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2019/09/06 10:11:48
  • Location: 0
  • Status: offline
2019/09/12 10:23:13 (permalink)
0

Hearing tone

Hi, 
How can I  generate tone by PIC24 and want to hear the tone by using any pin( GPIO) ?
 
I am very new. Please help. 
 
Rafia
#1

14 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6258
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Hearing tone 2019/09/12 10:34:51 (permalink)
    +1 (1)
    Toggle the pin at a frequency you can hear.
    #2
    katela
    Super Member
    • Total Posts : 1411
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: Hearing tone 2019/09/12 11:53:32 (permalink)
    +2 (2)
    Use PWM to generate an audible tone. You can search the forum or on Google how others have done it before.

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #3
    Rafia
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/09/06 10:11:48
    • Location: 0
    • Status: offline
    Re: Hearing tone 2019/09/12 12:05:11 (permalink)
    0
    Hi, 
    By the following code I can see the Square wave on OSC. But how can I generate a tone and see that on the OSC ?
     
    #define LED_BLED _RD8
    #define ConfigureBacklight() _TRISD8 = 0
    #define DELAY 25000000UL / 256/8
    int main( void )
    {
    // 1. init I/O and timer
    ConfigureBacklight(); // configure I/O as output

    T1CON = 0x8030; // internal clock/2 /256

    // 2. main loop
    while (1)
    {
    TMR1 = 0; // delay
    while ( TMR1< DELAY);

    LED_BLED = 1 - LED_BLED;// toggle LED_BLED output
    } // main loop
    } // main
    #4
    Rafia
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/09/06 10:11:48
    • Location: 0
    • Status: offline
    Re: Hearing tone 2019/09/12 12:08:20 (permalink)
    -1 (1)
    Hi Katela, 

    By the following code I can see the Square wave on OSC. But how can I generate a tone and see that on the OSC ?
     
    #define LED_BLED _RD8
    #define ConfigureBacklight() _TRISD8 = 0
    #define DELAY 25000000UL / 256/8
    int main( void )
    {
    // 1. init I/O and timer
    ConfigureBacklight(); // configure I/O as output

    T1CON = 0x8030; // internal clock/2 /256

    // 2. main loop
    while (1)
    {
    TMR1 = 0; // delay
    while ( TMR1< DELAY);

    LED_BLED = 1 - LED_BLED;// toggle LED_BLED output
    } // main loop
    } // main
    #5
    katela
    Super Member
    • Total Posts : 1411
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: offline
    Re: Hearing tone 2019/09/12 12:48:36 (permalink)
    +1 (1)
    Do you want to see or to hear that tone?
    As Jim explained above, toggle your pin to a frequency you can hear. Put a sounding device on that pin like a buzzer.
    Not all frequencies are audible by a human hear, you can hear roughly 20 Hz - 20 kHz

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #6
    1and0
    Access is Denied
    • Total Posts : 9747
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Hearing tone 2019/09/12 12:58:42 (permalink)
    +1 (1)
    As said, audible frequency range of human ear is roughly 20 Hz - 20 kHz. So generate a wave with frequency in this range, output to an audio amplifier, then to a speaker. A buzzer has a very narrow frequency range; there is also self oscillating buzzer too.
     
    Edit: A square wave will sound harsh to the ears. You can also use the PWM for waves generation, output to a low pass filter to form a sine wave, before feeding the audio amplifier.
    post edited by 1and0 - 2019/09/12 13:02:15
    #7
    Rafia
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/09/06 10:11:48
    • Location: 0
    • Status: offline
    Re: Hearing tone 2019/09/12 13:08:05 (permalink)
    0
    Hi,
    I want to hear the tone. Also want to use a GPIO pin to see the wave. I am verynew. I need this for my research. I have generated tone with codec ( 2 frq). Now want to use two GPIO pin to see the 2 tone timing. So that can measure the EEG signal with openBCI. Can u please give me your email ?
     
    It will be a great help. 
    #8
    Rafia
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/09/06 10:11:48
    • Location: 0
    • Status: offline
    Re: Hearing tone 2019/09/12 13:19:47 (permalink)
    0
     
     
    Here two tone is  generating. I want to assign two pin for this two tones. So that I can detct the timing of  2 tones by 2 channel of Osciloscope.  Atthe same time I will measure the EEG signal by OpenBCI.  
     
    Please see the attached file. I want to assign pins to see "Beep" and "Boop" in two channel. 
     
     
    } // SineTest
    #define DELAY 25000000UL / 256/8
    unsigned v;
    void main( void )
    {

    while( 1 )
    {
    MP3Init( MP3_MODE_TEST); // TEST MODES enabled
    testMP3Sine( 0x69); // tone1
    DelayMs( 100);

    MP3Init( MP3_MODE_TEST); // TEST MODES enabled
    testMP3Sine( 0x44); // tone2

    } // main loop


    }
     

    Attachment(s)

    Attachments are not available: Download requirements not met
    #9
    ric
    Super Member
    • Total Posts : 23849
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Hearing tone 2019/09/12 13:22:35 (permalink)
    +1 (1)
    Rafia
    Hi,
    I want to hear the tone.

    So what are you going to connect to the pin to make it audible?
    A PIC pin is not powerful enough to drive a speaker directly. You either need to buffer it with some external components, or feed it into something like an "amplified speaker" that has the electronics already inside it.

    Also want to use a GPIO pin to see the wave.

    What do you mean "see". Please stop using such ambiguous terminology and actually EXPLAIN what is required.

    I am verynew. I need this for my research. I have generated tone with codec ( 2 frq).

    How? With some other device?
     

    Now want to use two GPIO pin to see the 2 tone timing.

    Again, we don't know what you mean by "see" in this context.
     

    So that can measure the EEG signal with openBCI.

    Do you mean you're using one of the boards from this website?
    https://openbci.com/
     

    Can u please give me your email ?

    That is not how forums work. That is like asking for free personal help, and is likely to make people leave you alone.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    Rafia
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2019/09/06 10:11:48
    • Location: 0
    • Status: offline
    Re: Hearing tone 2019/09/17 03:46:59 (permalink)
    0
    In arduino I have seen some "speakerPin" is used to hear sound. In Mplab Xc16, pic24, is there any function required to hear tone with two frequency?
    Thsnks..
    #11
    ric
    Super Member
    • Total Posts : 23849
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Hearing tone 2019/09/17 04:00:59 (permalink)
    +1 (1)
    You can use a Timer peripheral to generate a square wave at various frequencies.
    That is a failry harsh sound, but easy to generate.
    With a couple of external components (e.g. an RC filter), you can use a PWM/CCP module to output sine waves or more complicated waveforms. That requires software to actively write data to it in real time.
    As I already said, this is a weak signal. You can't drive a speaker directly with it.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    ric
    Super Member
    • Total Posts : 23849
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Hearing tone 2019/09/17 04:04:03 (permalink)
    +1 (1)
    Do you mean two tones at once?
    That's possible with PWM, but makes the software to drive it a bit more complicated.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    PStechPaul
    Super Member
    • Total Posts : 2394
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Hearing tone 2019/09/19 22:18:35 (permalink)
    +1 (1)
    Do you mean dual tone multi-frequency (DTMF)? Here is a video of that, using a HT9200A:
     
    https://www.youtube.com/watch?v=33mNSbI-OZg
     
    DTMF dialer using a NTE1690 DTMF dialer chip and a PIC16F690 microcontroller.
    http://avtanski.net/projects/phone_dialer/
     

     
    #14
    PStechPaul
    Super Member
    • Total Posts : 2394
    • Reward points : 0
    • Joined: 2006/06/27 16:11:32
    • Location: Cockeysville, MD, USA
    • Status: offline
    Re: Hearing tone 2019/09/19 22:29:02 (permalink)
    0
    Also, it may be possible to hear a signal on a GPIO pin using high sensitivity headphones. 20 mA and 5 volts is 100 mW (probably only about 20-50 mW RMS), but that is loud enough to be heard on a small speaker. But it will be only about 3 mW with 20 mA into an 8 ohm speaker.
     
    High impedance headphones:
    https://www.mikeselectronicparts.com/product/high-impedance-headphones/
     
    Earphone:
    https://www.amazon.com/Cr...ce-3-5mm/dp/B0052EE0AU
    post edited by PStechPaul - 2019/09/19 22:35:01

     
    #15
    Jump to:
    © 2019 APG vNext Commercial Version 4.5