Question about the Count Command.


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Tear's Avatar
    Tear Guest

    Default Question about the Count Command.

    I have a complex audio signal that I am passing through a full-bridge rectifier to turn it to a DC signal. I am then limiting the the signal to 5V max. After rectification and limiting the signal will range from 0 to 5V and 20 Hz to 20,000 Hz. Using a 4Mhz crystal it can count up to frequency at 25,000 Hz.

    My question is using the count command which counts the amount of times a low to high transition is made can be used on this complex DC signal? Or does the command only work for a pulse wave?

    I would be happy to provide a schematic of the full-wave rectifier and limiting circuit that I am using to the send the input signal to the microcontroller from if anyone would like to look at it.

    Thanks for the help,
    Michael

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i doubt you really need to rectify the audio signal... well tell us what you exactly want to do with the audio signal.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I am rectifying the audio signal as part of my circuit to control the voltage and current the microcontroller will see, so as not to send it to much voltage or current. I forgot to post yesterday that the rectification happens after passing the audio signal through an opticalisolater. This is to seperate it from the stereo deck for safety.

    What I want to do is simply have the microcontroller see is there is the signal present at an input pin and if so then it will turn on an output pin which will turn on my amp through a transistor circuit.

    I think that the count command should be able to detect that the audio signal is there if/when it is. I was just hoping for some feedback that I am correct in this assumption.

    This is a link to more information on what I am trying to do:
    http://www.picbasic.co.uk/forum/showthread.php?t=2033


    Thanks,
    Michael

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    NAH!

    To turn on an amplifier you just need an 50 cents Voltage comparator. Or if your really want to use a PIC, use the a/d or analog comparator input and do the according stuff when the voltage is over XYZ voltage.

    What PIC do you plan to use??? PIC12F629,12F675,12F683 will be more than enough
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Using the ADCIN command allows for the use of an analog signal to the microcontroller. Looking at the example code on the webpage the whole PORTA is set as analog inputs. Is this because each I/O pin holds a bit? And if so which pin do you wire the input analog signal to? Also since I am measuring an analog signal that will range from 0-5V how many bits do I need to set the ADC to when all I want to do is measure if it is above 0V?

    I plan to use the PIC12F629 since I plan to add more utility to this little piece at a later date.

    Is there any other commands that I can use for an analog voltage comperator in PBP?


    Thanks,
    Michael
    Last edited by Tear; - 25th July 2005 at 16:41.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's no built-in command to read a comparator status. you need to read the register.
    this something to start...
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _MCLRE_OFF  
    
    TRISIO = %11001111 ' GPIO.4, GPIO.5 as output
    CMCON  = %00000010 ' COUT=1 when Vin+(GPIO.0) > Vin- (GPIO.1)
    		           ' comparator mode :comparator without output
    
    Clip     var   GPIO.4
    Normal   var   GPIO.5
    Speaker  var   byte
    
    start:
    	  speaker=CMCON.6 ' read from internal comparator
          Select case speaker
                 case 0
                      clip=0
                      normal=1
                 case 1
                      clip=1
                      normal=0
                      pause 100
                      Clip=0
          end select
    	  goto start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Active low input?
    By CosMecc in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 8th August 2010, 20:31
  2. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  3. Can I do this???
    By noobie in forum mel PIC BASIC
    Replies: 2
    Last Post: - 10th June 2006, 18:57
  4. Bootloader + EEPROM / DATA Command Question
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th September 2005, 20:01
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04

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