Lab 3

Page Modified on: 05/07/04

Home
Lab 1
Lab 3
Fire Fighter Project
Knight Rider Project
MCP Project
Egghunt project
Photo Gallery

 

Write up for lab # 3

I created a VU display that displays the intensity of the music signal that is fed into it.

The pic16h876 chip has a built in analog to digital converter. It also has a built in digital to analog converter. In theory we could play a sample sound in and convert it to digital streams then take the digital streams and convert it back to analog signal and it should be the same sound we sent in.

 

 

Music

>>>

analog to digital converter

>>>

digital storage

>>>

digital to analog converter

>>>

analog playback

Analog signal source

 

 

 

 

 

 

 

Same signal as the source

 

 

I only used the analog to digital converter part of the PIC:

 

Music

Analog signal source

 

>>>

analog to digital converter

 

>>>

display the intensity of the music with LEDS 

 


 

There are three different types of audio meters common in analog audio: VU (Volume Units) which go to +3dB on the scale with anything over 0 dB showing in red; PPM (Peak Program Meter), which go to + 6 dB; and digital audio meters which behave like PPM but do not go above 0 dB. I created a VU meter -


I used the A0 as an input and all of B as an output. I reused part of the code found in the manual. The code in the manual was doing just a straight analog to digital conversion:
It turned all of the B ports into outputs*, then it shifted the converted digital number two positions and send it to the 6 B ports as outputs. I hooked each output to an LED. The chip will take in analog signal and will convert it into a digital number. The problem was that the LEDs were turning on and off so fast that for the human eye they appeared to be dimly lit and on all the time or most of the time.
 

*I know that port B 0 is supposed to be used for the communication bus, but it was easier to use it instead of the other outputs
 

 

My code:

 

global [r]

constants

[[portb 6][portb-ddr $86]]

to sample-signal

write portb-ddr 0

loop

 [

  setr ((read-ad 0) / 6)

 

  if (r / 32)

  [

    setbit 5 portb

  ]

  if (r / 16)

  [

    setbit 4 portb

  ]

  if (r / 8)

  [

    setbit 3 portb

  ]

  if (r / 4)

  [

    setbit 2 portb

  ]

  if (r / 2)

  [

    setbit 1 portb

  ]

  if (r)

  [

    setbit 0 portb

  ]

  if timer > 200

  [

    write portb 0

    resett

  ]

]

end

 

To correct that I assumed the following: each bit corresponds to a frequency. If the bit is on and that is the highest bit on that must mean that all the bits underneath are on. Just think of a sine wave.

 

 

Your browser does not support lines. Please get an update from your software vendor.

 

                               
                             
                           
                     
               
       
 

The ☺represents a single LED and each bar represents how many LEDs are on at that given time given the intensity of the music. In a VU meter all the LEDs have to be on up to the highest level LED one that corresponds to the highest amplitude.

 

    Bibliography:

Hugh Robjohns: METER RULES

Frequently Asked Questions: Metering

http://www.soundonsound.com/sos/jun00/articles/metring.htm