Guys, I'm getting a little out of my depth and would like some feedback here.
From my previous posts some of you (two Steves !) will remember that I'm playing with a 16F873 to come up with a better version of some disco lights based on an 16F628a. I'm now looking at hooking up the audio output from a CD player but I've never played with A - D conversion and not sure what I need to do. I've used the example varibles in the manual so I have
Code:
B0 VAR BYTE
ADCIN 0, B0 ' Read channel 0 to B0
I want to use RA0/AN0 (pin 2) for the input, and I've used a win-scope to obtain the voltage levels that the CD player is kicking out (see attached). How do I go about calibrating the A-D so that I can display the values of B0 on port B relative to the music level ?
EDIT:
I tried the obvious:
Code:
ADCIN 0, B0 ' Read channel 0 to B0
Portb=B0
RETURN
However even with no music present the first 5 bits of Port B seem to display a random pattern, rather than just PB0 being lit. There is however a noticable change of state when a music signla present, I get more LEDs light up and it extends over the full port.. but it's not seqentially lighting them up like a VU meter.
EDIT:
Sorry should of added that I copied the settings form the manual too
Code:
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
And have the following config:
Code:
ADCON1=$07
CMCON = 7 ' Digital inputs
CCP1CON = 0 ' PWM off
TRISA=%11111111 'set PORTA as all input
Bookmarks