PDA

View Full Version : Question about the Count Command.



Tear
- 21st July 2005, 22:55
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

mister_e
- 22nd July 2005, 03:03
i doubt you really need to rectify the audio signal... well tell us what you exactly want to do with the audio signal.

Tear
- 22nd July 2005, 15:15
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

mister_e
- 23rd July 2005, 10:02
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

Tear
- 25th July 2005, 15:15
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

mister_e
- 25th July 2005, 23:58
There's no built-in command to read a comparator status. you need to read the register.
this something to start...


@ __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

Tear
- 26th July 2005, 16:11
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

NavMicroSystems
- 26th July 2005, 17:05
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.

;-)

mister_e
- 26th July 2005, 17:32
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 :)

You have a snip of code
you have a heap of idea how to do it
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

Acetronics2
- 26th July 2005, 17:33
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....

mister_e
- 26th July 2005, 18:01
No, Analog circuits are not dead ...

That's for sure, return to basic, it's still a good pratice. Let`s see

PIC 12F629 => 2,28$ each in really small Qty will fit in half of matchbox
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





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!

Acetronics2
- 26th July 2005, 18:31
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

NavMicroSystems
- 26th July 2005, 18:50
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.

nomada
- 27th July 2005, 01:11
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

mister_e
- 27th July 2005, 03:52
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 :)