Shop OBEX P1 Docs P2 Docs Learn Events
BOE mircophone — Parallax Forums

BOE mircophone

brandanbrandan Posts: 52
edited 2014-05-20 11:34 in Propeller 1
On the Board of Education how I use the microphone on it? I was thinking would an analog pin. It seems to be on a digital pin. I didn't see anywhere say how to use it? I'm using c/c++ not spin.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-05-17 09:43
    The microphone is connected to P20 and P21 with components which allow the output from the mic to be monitored with a sigma-delta algorithm.

    attachment.php?attachmentid=108742&d=1400344717

    Above is the microphone section of the PropBOE's schematic (page 6).

    It's possible to record sound to the SD card on the PropBOE using the mic. I used a program (in Spin) from the OBEX to test out recording audio to the uSD card. The sound quality wasn't great but I could understand the recorded speech when it was played back.

    I'm pretty sure you'll need PASM to monitor the mic fast enough to record or monitor sound. There are several examples in the Propeller Tool library of using the sigma-delta technique. ADC.spin can be used as a child object to monitor the mic (you'll need additional code to do something with the data). There are two programs in the "Demo" folder which use the microphone; "microphone_to_headphone.spin" and "microphone_to_vga.spin".

    Sorry, but I'm not aware of any programs in C using the mic. Hopefully someone more familiar with using C on the Propeller can help.
    304 x 305 - 15K
  • brandanbrandan Posts: 52
    edited 2014-05-17 10:26
    what demo folder?
  • PublisonPublison Posts: 12,366
    edited 2014-05-17 10:59
    brandan wrote: »
    what demo folder?

    I believe Duane is referring to the demos that are in the Propellor Tool:

    http://www.parallax.com/downloads/propeller-tool-software

    "File>Open From> Propeller Library -Demos"
  • brandanbrandan Posts: 52
    edited 2014-05-17 17:22
    I can't get it to work. Maybe it would be easier to get a microphone and connect to an analog pin
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-05-17 18:00
    brandan wrote: »
    I can't get it to work. Maybe it would be easier to get a microphone and connect to an analog pin

    What does "I can't get it to work" mean? What is you try? What where you expecting? What happened? What code did you use?

    By connecting a mic to an analog pin, do you mean connecting to the I2C ADC?

    I think I used this object (yes, it's written in Spin), to record audio. I used this one to play it back.

    Make sure any sigma-delta programs you try have the correct I/O pins set for the mic.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-05-18 10:04
    The SimpleIDE libraries currently only include an ADC from the MCP3208 chip, but the Propeller also can do an ADC with a Sigma-Delta algorhtm and a few components. That is what your BOE board is wired to support. And all the currently available code is in OBEX or the Propeller Tool Examples that are SPIN and PASM.

    For GCC, it seems we need some one to write a Sigma-Delta driver.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-05-19 08:18
    Duane Degn mentioned a couple of SPIN objects that work with the existing setup. There is also a bit of software called Spin2Cpp that can convert Spin code to C++

    Using that might be the least effort.
    http://code.google.com/p/spin2cpp/
  • dgatelydgately Posts: 1,630
    edited 2014-05-19 09:44
    Duane Degn wrote: »
    I think I used
    Duane Degn wrote: »
    this object (yes, it's written in Spin), to record audio. I used this one to play it back.

    I ran spin2cpp on the recorder object's code, but spin2cpp thinks the following lines in WAV-Recorder_ADCEngine.spin are syntax errors and will not complete a conversion:

    [COLOR=#000000]ERRORS:
    
    WAV-Recorder_ADCEngine.spin:304: syntax error
    WAV-Recorder_ADCEngine.spin:305: syntax error
    WAV-Recorder_ADCEngine.spin:306: syntax error
    
    
    
    FOR THIS CODE:
    
    [/COLOR]DAT WAVFileHeaderData ' DO NOT EDIT!
    
    ' /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    [COLOR=#000000]byte byte "RIFF" ' "RIFF" chunk header.
    byte long 0 ' "RIFF" chunk size = (fileSize - 8). Offset 4.
    byte byte "WAVE" ' File type.
    [/COLOR]
    

    The code compiles with openspin in SimpleIDE without issue, so there's something about ' byte byte' and 'byte long' that spin2cpp is not happy with. Kye quotes in the code NOT to edit these lines, so I'm not sure how to get around these errors...


    dgately
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-05-19 23:43
    Hmmm... I had high hopes that the Spin2Cpp tool would simply work in this context. It certainly would appeal to those that already use the Aduino and want to run all and anything in OBEX ... just as long as it can be migrated to C++.

    I suspect there still is a lot of OBEX code that will migrate without needing either a new verision of Spin2Cpp or a revision in the code. Catalina C also doesn't seem to have a Sigma-Delta driver in C.
  • kuronekokuroneko Posts: 3,623
    edited 2014-05-20 00:04
    dgately wrote: »
    The code compiles with openspin in SimpleIDE without issue, so there's something about ' byte byte' and 'byte long' that spin2cpp is not happy with. Kye quotes in the code NOT to edit these lines, so I'm not sure how to get around these errors...
    Temporarily - until spin2cpp catches up - use this:
    byte "RIFF"   ' "RIFF" chunk header.
      byte 0[4]     ' "RIFF" chunk size = (fileSize - 8). Offset 4.
      byte "WAVE"   ' File type.
    
      byte "fmt "   ' "fmt " chunk header.
      byte 16, 0[3] ' "fmt " chunk size.
      byte 1, 0     ' Audio format.
      byte 1, 0     ' Nuber of channels.
      byte 0[4]     ' Sample rate.EDITED by setup function!
      byte 0[4]     ' Byte rate. EDITED by setup function!
      byte 2, 0     ' Block align.
      byte 16, 0    ' Bits per sample.
    
      byte "data"   ' "data" chunk header.
      byte 0[4]     ' "data" chunk size = (fileSize - 44). Offset 40.
    
  • dgatelydgately Posts: 1,630
    edited 2014-05-20 08:41
    kuroneko wrote: »
    Temporarily - until spin2cpp catches up - use this:
    byte "RIFF"   ' "RIFF" chunk header.
      byte 0[4]     ' "RIFF" chunk size = (fileSize - 8). Offset 4.
      byte "WAVE"   ' File type.
    
      byte "fmt "   ' "fmt " chunk header.
      byte 16, 0[3] ' "fmt " chunk size.
      byte 1, 0     ' Audio format.
      byte 1, 0     ' Nuber of channels.
      byte 0[4]     ' Sample rate.EDITED by setup function!
      byte 0[4]     ' Byte rate. EDITED by setup function!
      byte 2, 0     ' Block align.
      byte 16, 0    ' Bits per sample.
    
      byte "data"   ' "data" chunk header.
      byte 0[4]     ' "data" chunk size = (fileSize - 44). Offset 40.
    

    Thanks, Kuroneko!

    That gets me further, but the spin2cpp .c version of SD-MMC_FATEngine.spin does not compile without errors in a .s file created during the build process. That file is a temp file buried in /var/folders that disappears after the build attempt. I'll try to get a .c version of SD-MMC_FATEngine working separately...


    dgately
  • dgatelydgately Posts: 1,630
    edited 2014-05-20 11:34
    dgately wrote: »
    That gets me further, but the spin2cpp .c version of SD-MMC_FATEngine.spin does not compile without errors in a .s file created during the build process. That file is a temp file buried in /var/folders that disappears after the build attempt. I'll try to get a .c version of SD-MMC_FATEngine working separately...

    Ah, to find the build failure, I used the "--dat --gas" commands together to create a .S file for the ASM code in "SD-MMC_FATEngine". Trying to compile (assemble) that code showed the errors (yay!)

    I fixed the inline ASM code that was created in D-MMC_FATEngine.c and now can compile the whole project...

    I modded the project to use the pins of the Propeller BOE rather than the Prop Demo board (mostly just changes to WAV_Recorder_Program.h) and removed code that looked for toggling of pin 31 to stop recording. I set the recording period to a static 4 seconds for testing. The program starts up and runs until the record cog is started. It hangs there. I put in some code to blink the _stoplight LED (pin 26 on the Prop BOE) between calls to the SD & WAV engine code, still get no further than the first cognew in what I now have labelled as "main()".

    It's possible that the code is not compatible with the Prop BOE in some other way as I was not able to get the .spin version to work either :smile:...


    I zipped the project in SimpleIDE for anyone to look at and help debug:

    WAV_Recorder_Program.zip



    dgately...
Sign In or Register to comment.