Shop OBEX P1 Docs P2 Docs Learn Events
communication between computer using sound waves — Parallax Forums

communication between computer using sound waves

gaurav89gaurav89 Posts: 4
edited 2012-12-17 04:54 in General Discussion
I am trying to wrapping information in sound waves and then playing sound then recording and unwrapping information using fft.
for this i am using 3 frequencies 5000hz, 6000hz, 7000hz and sampling frequency 16000hz.
5000hz frequency for value '0', 6000hz for value '1' and 7000hz for seperating two values and playing each frequency for 100ms.
example for sending '110' the sound wave will be having frequency in order
(6000hz for 100ms) then (7000hz for 100ms) (6000hz for 100ms) then (7000hz for 100ms) then (5000hz for 100ms)
for unwrapping information i am using fft.
for the duration of 100ms of each frequency it is giving correct result but
for 10ms duration of each frequency it is giving errorneous result.
it is giving errorneous result for recorded sound wave and also for original signal.
what can be the reason behind this. i am using matlab.

thanks
gaurav

Comments

  • Mark_TMark_T Posts: 1,981
    edited 2012-12-17 03:25
    FFT processes blocks of samples - if you want to follow a _rapidly_ changing single tone then an FM demodulator would use
    a different approach such as a PLL, or some tuned filters.
  • Heater.Heater. Posts: 21,230
    edited 2012-12-17 03:47
    How on earth are we supposed to answer a question like this with no details what so ever?
    How big is your FFT? What is your sample rate? Are you actually transmitting and receiving sound, if so what's the hardware set up. If not is coming from a file or what?
    Having some code to look at might help but as it is MATLAB this is not the right forum for that discussion. And so on and so on.

    Is this a homework exercise?

    Because using an FFT to do this is not the way to do it.

    A simple way to do this, given that you have an signal with the tones in it is:
    1) Have the receiver code generate an internal sine and cosine wave form at one of those tones frequencies and the same sample rate.
    2) Multiply each incoming signal value by the current value of the sine function being generated. Do the same for the cosine function.
    3) Keep a running total of the results of those multiplications.
    4) Calculate a magnitude from the running totals by dividing each one by the number of samples received so far, squaring each one, adding them together and taking the square root.

    You will find that if the tone is present in the signal that magnitude will grow to a positive value representing the amplitude of the signal.
    If the tone is not present, or some other tone is in the signal the magnitude will go to be zero. So you can detect if the tone is present or not.

    Do the same steps for the other two tones and you have your decoder.

    This is effectively what the FFT does, except it does it for all frequencies in the signal not just the tones you are looking for. Hence is a very inefficient way to do it. Overkill.

    You will find your running totals will start to run toward infinity and your number system overflows. When you get that far it's time to discuss that issue.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-12-17 04:20
    It is an interesting concept, but not so sure about its success.

    One could use ultrasonic devices intended for ultrasonic rangefinders. You need a carrier frequency and a lower data rate. So if your carrier was something like 35,000Khz, you might just plug along with 19,200baud in an asynchronous format and the whole would be rather easy to build as your serial would be done for you.

    Still, it isn't very dazzling spend when IR data will go much faster, and BlueTooth can sizzle 3Gbits.

    Besides, your dog might become quite offended and leave for quiter surroundings, though I hear that you won't have mice, gophers, or cockroaches.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-12-17 04:42
    gaurav89 wrote: »
    3 frequencies 5000hz, 6000hz, 7000hz and sampling frequency 16000hz.
    .. and playing each frequency for 100ms.
    for the duration of 100ms of each frequency it is giving correct result but
    for 10ms duration of each frequency it is giving errorneous result.
    it is giving errorneous result for recorded sound wave and also for original signal.
    what can be the reason behind this.

    Hi gaurav

    Cool project. Please be patient with heater, he is a local expert on fft, but forgets that some of us (in fact most of the planet) is not. Otherwise he is very nice and helpful.

    If it works after 100ms, but does not work after only 10 ms, doesn't that say that the minimum sample time is greater than 10ms?

    After the above, if you are having a problem with the original sound, could it have something to do with the physical placement of the transducers? The waves reflected off the table and walls?

    From the information given I guess minimum sample time and room geometry are candidates for investigation.
  • Heater.Heater. Posts: 21,230
    edited 2012-12-17 04:47
    For sure it will work, don't forget we used to store data on audio cassette tape. A zero was 1200Hz and a one was 24000Hz. Data was recorded at 300 baud.
    http://en.wikipedia.org/wiki/Kansas_City_standard
    Acorm computers managed to get this down to

    Acorn computers managed to get this down to 2 cycles of 2400 for a 1 and 1 cycle of 1200 for a zero and a data rate of 1200 baud.
    Besides that's how good old modems work.
    Not sure why he needs three tones though the separator is redundant.
    This is the same but working through air, which will bring the attendant problems of noise etc.

    I always wanted to do computer to computer comms with Morse code just for the heck of it:)
  • Heater.Heater. Posts: 21,230
    edited 2012-12-17 04:54
    There was no FFT in their Braino,

    Just the school maths result that if you multiply two sine waves of frequencies F1 and F2 together and average the result over an infinite amount of time you will get zero, except when F1 = F2 at which point you will get 1.

    So if F1 is your reference tone and F2 is your incoming signal you can use the above to tell if the incoming tone is present at the reference frequency or not.
Sign In or Register to comment.