producing sound using STM32

Discussion in 'The Projects Forum' started by pistons4550, Sep 28, 2013.

  1. pistons4550

    Thread Starter New Member

    Jul 8, 2013
    6
    0
    Hello,

    Im in the middle of a project, building RC cars that fight each other. The cars try to target switches on the other cars to lower their health status. Ive already got some LEDs to indicate a hit and now Id like to add some noise. Im wondering how I can create a sound after a hit using a small speaker. I know that the speakers on my stereo have two different wires to complete a circuit. Im wondering if hooking up a small speaker to my stm32F407VG board would be as simple as hooking up an LED, one leg to an output pin and another to ground. Any ideas on speakers, programming sound, or comments in general?
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    STM32F407 has DAC outputs and loads of memory.
    It depends on the duration of the sound and quality.
    You can get fairly decent quality with just 8-bit data and low data rates such as 10ksps.

    How long a sound bite do you want to create?
     
  3. pistons4550

    Thread Starter New Member

    Jul 8, 2013
    6
    0
    2-3 seconds
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    STM32F407VG has 1MB flash and 192KB SRAM.

    4 seconds at 10Ksps requires 40KB which is easily accommodated.

    Now what you need to do is create the sound bite on a PC and then burn this into the STM FLASH memory.

    I can show you how to set up the DMA to output the sound wave to a DAC.

    What IDE platform are you running?
     
  5. pistons4550

    Thread Starter New Member

    Jul 8, 2013
    6
    0
    Its from CooCox, CoIDE
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,363
    How far have you come along in the software development?
     
  7. pistons4550

    Thread Starter New Member

    Jul 8, 2013
    6
    0
    this is my first time messing with this board, other than the LED network and some external switches, I haven't done much else with it
     
  8. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    By the way. If you want to attach a speaker directly to a DAC output, you should consider using a electrolytic capacitor for DC decoupling, in series with the speaker.
     
Loading...