Shop OBEX P1 Docs P2 Docs Learn Events
Looking for help with Prop based VU meter — Parallax Forums

Looking for help with Prop based VU meter

xanaduxanadu Posts: 3,347
edited 2012-12-13 07:54 in Propeller 1
I searched the forums and OBEX for a VU meter and didn't come up with anything. Has anyone ever made a VU meter with a Prop?

For the audio in it can be mono, I have some small mics and A/D chips if needed, or if there is small external circuit to not use a microphone that would be even better. The audio is very low volume, like headphone style amplification.

For the output, 5 LEDs is okay, or anything just so I get an understanding of how the output would work.

Thanks very much for any help!

Comments

  • shimniokshimniok Posts: 177
    edited 2012-12-11 22:49
    Never done it... but... seems like if you can digitize the signal, the rest would be relatively easy.

    This may help: http://www.sparkfun.com/tutorials/120
  • xanaduxanadu Posts: 3,347
    edited 2012-12-11 23:37
    Thank you Mike :)
  • BeanBean Posts: 8,129
    edited 2012-12-12 04:40
    Here is one I wrote in PropBasic for the Propeller Demo Board.
    ' SndMeter.pbas
    ' This program is for use on the Propeller Demo board
    ' It will sample the on-board microphone and light the LEDs, creating
    '   a simple sound meter.
    '
    DEVICE P8X32A, XTAL1, PLL16X
    FREQ 80_000_000
    
    
    ' Define CONs
    POSFB    CON 72      ' Counter mode for POS detect with feedback
    ADCVALUE CON 4096    ' Maximum value of ADC
    
    
    ' Define PINs
    MicFB    PIN 8 INPUT
    MicOut   PIN 9 OUTPUT
    LEDs     PIN 23..16 LOW
    
    
    ' Define HUB variables
    ' none
    
    
    ' Define DATA (DATA, WDATA, LDATA)
    ' none
    
    
    ' Define TASKs
    ' none
    
    
    ' Define variables (LONGs only)
    time       VAR LONG
    offset     VAR LONG = 0
    sample     VAR LONG
    lastSample VAR LONG = 0
    temp       VAR LONG
    
    
    ' Define Subroutines
    ReadADC  FUNC 0
    
    
    ' Start of main code
    PROGRAM Start
    
    Start:
      ' Setup CNTA for ADC mode
      COUNTERA POSFB, MicFB, MicOut, 1, 0
      time = CNT + ADCVALUE
    
      ' Allow ADC circuit to stabilize
      FOR temp = 1 TO 1000
        sample = ReadADC
      NEXT
    
      ' Get sum of 64 samples to get an average offset value
      FOR temp = 1 TO 64
        sample = ReadADC
        offset = offset + sample
      NEXT
      offset = offset >> 6 ' Divide by 64 because we summed 64 samples
    
      ' Get a sample and display on LEDs
      DO
        ' You must make sure you get back here before the next sample is due
        sample = ReadADC
    
        ' Subtract average offset from sample
        sample = sample - offset
    
        ' If sample is negative, then negate it (make it positve)
        sample = ABS sample
    
        ' Only show 8 MSB of sample
        sample = sample >> 4
        
        ' Show sample value on LEDs
        LEDs = sample
    
      LOOP
    END
    
    
    ' Subroutine Code
    FUNC ReadADC
      WAITCNT time, ADCVALUE
      __PARAM1 = PHSA - lastSample
      lastSample = lastSample + __PARAM1
      RETURN __PARAM1
    ENDFUNC
    
    

    Bean
  • xanaduxanadu Posts: 3,347
    edited 2012-12-12 14:09
    Perfect!

    All I need is that and the schematic for a Demo Board which I found here (PDF) http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PropellerDemoBd-RevG-Schem.pdf

    Thanks a lot! I'm going to use it to move a servo, not light LEDs. I'll post my code when finished.
  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-12-13 07:30
    xanadu wrote: »
    Perfect!

    All I need is that and the schematic for a Demo Board which I found here (PDF) http://www.parallax.com/Portals/0/Downloads/docs/prod/prop/PropellerDemoBd-RevG-Schem.pdf

    Thanks a lot! I'm going to use it to move a servo, not light LEDs. I'll post my code when finished.
    Is it for an animatronic prop?
  • BeanBean Posts: 8,129
    edited 2012-12-13 07:54
    One tricky thing I did was that I left the audio level value in binary when I sent it to the LEDs.
    This way the LEDs are displaying a log scale (the audio level voltage has to double before the next LED will light).

    Bean
Sign In or Register to comment.