Music Input


Closed Thread
Results 1 to 22 of 22

Thread: Music Input

Hybrid View

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

    Default Music Input

    Hi,

    I'm developing a disco light rig and need some advice. I want to connect the device to the line out from a CD player (typically 1v RMS peak to peak) via a lowpass filter that is then fed through a peak filter (CCt can be supplied if required) to pin RA2 of a 16F628a PIC

    As I already have switches on some PORT A so I only want to set AN2 (RA2) to analogue.

    Now I did try and use the POT comamnd, but realised that this wouldn't work as there is no real means of charging acapacitor, so I looked at the ADCIN command, and this is where my lack of experience shows. Here is the top section of my code

    Code:
    PORTA = 0 ' declare port level BEFORE port direction = safe power-on
    CMCON = 7 ' PortA Digital inputs
    DEFINE ADC_BITS 8
    CCP1CON = 0 ' PWM off
    VRCON = 0        ' Voltage reference disabled
    OPTION_REG.7 =    0
    ADCIN 2, M
    As I was using switches on port A I had used CMCON = 7 to make all ports didgital, so how do I change this so that RA2 is analogue and the rest digital. I also assume that I have the correct syntax ADCIN 2, M to put the resulting value (0 - 255) into M? The idea then is to include a line that states if the value of M is above a threshold it will run to the step in the pattern, if its below it simply loops until M is above the threshold.

    I welcome your comments

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Hi Malcolm. I did something similar a while back with a 12F675 and a portable radio. This program flashes several LED's with the beat of the music. Audio was taken from the audio feed to the volume control. The use of the ADC command automatically converts the port to analog.

    ANSEL = 0 'all inputs digital
    CMCON = 7 'comparators off
    DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device to accurize osc
    @ DEVICE MCLR_OFF, INTRC_OSC, WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON
    TRISIO = %11111111 ' all inputs for now
    'high & low commands convert to outputs
    X VAR BYTE 'adc variable

    START:
    ADCIN 0, X
    IF X > 2 Then High GPIO.2 'TURN ON LED'S ON GPIO.2
    IF X <=2 Then Low GPIO.2 'OFF LED'S
    GOTO START

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


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply,

    Sounds good (sorry no pun intended), I'll have a play and see what I can do.

    Cheers

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If and when you get ADCIN to work with a 16F628A, come back and tell us how you did it. That PIC hasn't got any ADC's...

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


    Did you find this post helpful? Yes | No

    Default

    Sorry I dow to your superior knowledge.. so what's an analogue comparator input then.. will it not do the same thing... ??

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Cool Already cooked example

    Hi, Malc

    Some years ago, Elektor committed such a project with a 16F84 ... you could have a look to their input stage ...

    16F628 is a "bigger" '84 ...no ???

    Alain

    PS : Project 000107 ... note everything Downloadable ...
    Last edited by Acetronics2; - 21st June 2006 at 10:20.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  2. floating A/D input
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th April 2009, 13:21
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19

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