temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Feb 13, 2019 9:19 pm |
|
|
Before cutting ANY code, get the hardware right !!
Audio (your 800 Hz to 1200 Hz) is probably a SINE wave, going + AND - from zero volts. The PIC's ADC will ONLY accept a POSITIVE voltage ! ( it's in the specs....way at the bck of the 400-500 pages no one reads...well, few read.
So for the ADC to NOT be destroyed, and to read the signal you need to 'offset' the incoming sine wave so that it's zero cross is 1/2 Vref. If Vref is VDD, then the 'offset' zero will now be 2.5 volts. You also have to calculate the correct gain of the amplifer so that you don't go over the Vref value. So the most positive level can't be above 5 volts in this case.
This can all be done with one opamp and a few resistors, a pot of coffee and some 'math'. Normally Vref will be from a very stable precision source not VDD. Remeber to measure VDD as it won't be 5.00, could be 4.97, 5.24,??
as for code,CCS supplies a basic program ex_freq.c I believe.
Jay |
|