Question about the Count Command.


Closed Thread
Results 1 to 15 of 15
  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.

  7. #7
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Hi mister_e,

    After looking through pages of information on rectifyingand using the PIC I am not sure it is the correct or easiest way to handle what I am trying to accomplish.

    What I want to do is take the AC signal from the speaker wires and then use this to turn on an aftermarket amp. I was originally thinking that rectifying the circuit would do the trick, however I am not so sure anymore.

    I am now thinking about using a comparator circuit like you have mentioned to do. However, I have two concerns with this though:

    1. All the comparator circuits that I have looked at use one wire as input, whereas, it is two wires that come from the speaker. Do I simply ground the negative wire from the speaker and run the comparator with the positive wire?

    2. Since the voltage on the speaker can be as low as 50 mV can an op-amp comparator circuit use this low of a reference voltage for comparing? (To keep the amp on when there is a 50 mV or higher signal present)

    Thanks for the help,
    Michael

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Any simple single supply OpAmp would do the job.

    Configure it for a gain of 50+ and supply it with 5V

    an input signal of 50mV would result in an output of >=2.5V
    (which is interpreted as HIGH in TTL)

    But Steve is our Car Audio Expert,
    so I'll leave it to him to find the final and perfect solution.

    ;-)
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



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


    Did you find this post helpful? Yes | No

    Default

    Ralph suggestion is quite good, the only problem i see, is when the audio signal will cross the Zero, the amp could turn off.

    mmm... in conjunction with the ralph suggestion, connect the op-amp output to the PIC, check the signal, wait let's say 100 ms or more and redo the test. If both tests are positive, turn on the amp, if both negative, turn off the amp.

    Now it's time to do some home work guy. We provided more than enough stuff to do the whole thing... even on more than one thread
    1. You have a snip of code
    2. you have a heap of idea how to do it
    3. the circuit is virtually in the air... look !!! you see it??

    Probably... the op-amp could be skip if you use the PIC comparator. If you keep the op-amp, you can do the whole project with a simple nifty 10F serie without analog stuff on
    Last edited by mister_e; - 26th July 2005 at 17:36.
    Steve

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

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Hi

    I think a simple LM3915 or 3916 could do most of the job, offering moreover a superb "christmas tree " ... to your child's eyes.

    just select the open collector output for the level to trigger!!!

    National datas offer the drawings for full wave rectification, averaging, peak detection ... Heaven !!!

    No, Analog circuits are not dead ...

    Alain

    PS : France : 1 point ... Canada : Boooooo....

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics
    No, Analog circuits are not dead ...
    That's for sure, return to basic, it's still a good pratice. Let`s see
    1. PIC 12F629 => 2,28$ each in really small Qty will fit in half of matchbox
    2. LM3914,LM3915,LM3916 => 3,15 - 3,75$ + external capacitors, extra board space + chances to do some erratic turn off when signal is a bit low, and blah blah blah


    Quote Originally Posted by Acetronics
    PS : France : 1 point ... Canada : Boooooo....
    j't'emerde... c une farce... humour Québécois

    Is the score is still the same... BAH who cares!!!

    Mes amitiés à la France!
    Steve

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

  12. #12
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Talking

    Hi, steve

    I've paid my LM 3915 1.80 Euros ...

    If it's a problem for you, a gang of transistors ( 5 to 6 ? ) plus some R and C can fit into a sugar lump ...

    I already did that for a sound animated christmas star ... ( 16 Leds, 4 channels !!! )

    Here, Relay will have to keep outside ... too bad !!!

    But, Why not to use a PIC ???

    Cheers to la belle Province !!!

    Alain

  13. #13
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Ralph suggestion is quite good, the only problem i see, is when the audio signal will cross the Zero, the amp could turn off.
    Steve, I was assuming there is a small PIC at the output of the OpAmp.
    (This was why had suggested to supply the OpAmp with 5V)
    (The positive Rail of the OpAmp would limit the voltage you feed into the PICs)

    However,
    let's stop here, TEAR has probably got more info than he'll ever need or he can cope with.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  14. #14
    Join Date
    Oct 2004
    Location
    Porto - Portugal
    Posts
    28


    Did you find this post helpful? Yes | No

    Default

    Hi Michael and of course all the others

    I supposed that in your post #3 you said that you intend to get the audio signal from the link between the stereo deck and the amplifier, and in post #7 you wrote about getting the signal from speakers wires, which one is the correct one?

    Besides a lot of other things, at my company we produce audio amplifiers (OEM regime) from 100W to 3000W (2 channels). One thing I've learned, turning on a amplifier with signal present at the inputs when the amplifier has no soft-start feature or other kind of (BUMP) protection will surely damage the speakers, please take care in your aproach regarding the method of turning on the power while monitoring the ammount of signal at the inputs.

    I suppose that you are really determined to use a PIC, because as all the others had already said there are "other" ways to get the same result.

    Keep us informed
    nomada

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


    Did you find this post helpful? Yes | No

    Default

    Nomada have a good point about the soft start for sure, this is why we suggest a op-amp at the input with a wide gain to compensate, but i do understand your point.

    BTW last suggestion, since more than everything has been covered, and we still don't know in wich car it will be installed...

    Most of those deck have a turn-on lead for factory amp and/or electric antenna and such. The use of a volmeter on the back connector of the radio will show you the truth. The easy solution of using the ignition/accessory wire it's still working too.


    http://www.installdr.com/QuickWiring.html or www.google.com for radio pinout

    And of course, the best one that need a few experience.. open the radio and probe the circuit to find a remote, use a MOSFET, Transistor ,CMOS buffer to provide your turn-on.

    That's all for me too
    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 : 1

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