Maker Pro
Maker Pro

Peak detector to A/D of PIC

Hi all
I have a peak detector circuit below. However when i connect this to the A/D pin of the PIC i get a flat line ie 0V
Could this be an impedance matching issue?
I have aldo noticed the same thing happen if i attach a low pass RC filter to the PIC A/D ie 100K and 220nF
I have thought about putting a voltage follower to the end of both these circuits but i am restricted for PCB space.
Can anyone help?
Thanks in advance
 

Attachments

  • Peak Detector Circuit-1.pdf
    10.1 KB · Views: 52
If you can measure the voltage at the output, (presumably, the node marked cathode D1,) but the PIC is not reading it, I think it is your program that is in error.

Try measuring a stable voltage with the same code and see what you get.

Bob
 
What is the peak voltage of the pulse? 333uV? The resistors R1 and R2 reduce it to 100uV that feed the diode but the diode has a voltage drop of 600000uV so its output is zero. Amplify the pulse signal a few thousand times then use an active precision peak detector circuit that cancels the diode voltage drop.
 
Hi
The peak voltage of the pulse is 7V.
I have also deleted the A/D code. On normal power up the A/D pin is an input. However, I am still not seeing any signal. If i disconnect
the output frim the A/D pin i can see the signal. Could this be a loading issue?
 
Of course the output from the peak detector will be gone if it is loaded with 5k ohms or less. Usually an opamp is used for a peak detector because it has a low output impedance.
 
Hi thanks for your reply.
I am measuring the signal using a oscilliscope. I did consider an opamp voltage follower but do not have enough PCB space to fit it hence trying to use discrete components.
How can i over come this issue. Shall try and tweak the RC values? See i need to measure the output of the peak detector as soon as the first edge, with the RC network i have to wsit around 18ms befire the average voltage is reached. I need to reduce this further. Any ideas would be appreciated. Thanks in advance.
 
The capacitor is charged slowly through the high values of your 20k to 10k voltage divider.
An opamp would charge the capacitor mat least 100 times faster.
You do not want a simple voltage follower, instead you want a precision peak detector with the diode voltage drop cancelled because it is inside the negative feedback loop of the opamp. Use a single supply opamp like this:
 

Attachments

  • precision peak detector.png
    precision peak detector.png
    16.3 KB · Views: 113
I am still not buying it. With a 220nF cap, the ADC should have no problem with sampling the output of your peak detector. Basically, the ADC is simply putting a much smaller capacitor in parallel with that capacitor when sampling, which should have no effect.

The datasheet says 10nF is sufficient to allow sampling of high impedance sources (> 10K).

If this were the problem, you would not get 0, you would get something lower than the actual voltage, but never 0.

I am willing to bet your code is wrong.

So, I ask you again: Have you tried sampling a stable voltage with the same code? Just make a voltage divider from Vcc to ground with two 10K resistors and you should get a 1/2 scale reading if you are setting up the ADC correctly.

My guess is that the pin is being configured as an output.

Bob
 
Hi Bob,
I am investigating this at the moment.
I removed all the A/D code initially, thinking thst this was an easier test. I think by defaiult the PIC A/D is an input I/O pin. But i was still not seeing the signal at the pin.
I am going to look at the A/D code again by just puttjng a stable voltage from a psu ir ad you say via a voltage divider cirvuit arrangement.
I might be wrong but i thought that having a high resistance going into the PIC A/D would cause a voltage drop, hence this is what i was seeing? But then with the addition of the 220nF i thought that any voltage drop would be negated and it might take longer for hhe PIC A/D to read the input (due to the extra capacitance) abd hence to overcome this the acquisition time if the A/D could be increased.
I will keep you informed.
Thanks for the help.
 
You have 10k and 20k effectively in parallel at 6.66k reducing the 7V input to 2.33V. The diode drops 0.6V to 1.733V. The capacitor charges in one time period to 1.16V in the time of 6.66k x 220nF= 1.5ms and almost the peak in 7.3ms. The 43k load and PIC input resistance also reduce the voltages.
 
Top