AtoD - first attempts


Results 1 to 12 of 12

Threaded View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default AtoD - first attempts

    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
    Attached Images Attached Images  
    Last edited by malc-c; - 29th December 2006 at 14:04.

Similar Threads

  1. Averaging AtoD samples
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 39
    Last Post: - 29th September 2011, 21:51
  2. 16F684 AtoD problem
    By hell_pk in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 20th February 2009, 06:59
  3. Atod Digital Filter
    By GeoJoe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd April 2008, 17:04
  4. 877A AtoD config problem?
    By ttease in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st April 2007, 16:57

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts