I would like to measure a voltage between VCC and Mosfet's drain. How can i succeed with a PIC? I couldn't know where i put the deviders and how i write the codes. I can use adc functions well.
I would like to measure a voltage between VCC and Mosfet's drain. How can i succeed with a PIC? I couldn't know where i put the deviders and how i write the codes. I can use adc functions well.
Last edited by showtime; - 27th November 2007 at 23:43.
I see two problems here -
First, you can't measure voltages that have a reference more than about .5 V above or below GND. To solve that problem you can either:
A. Build a one or two op-amp level shifter or
B. If the 20 V is stable, then just measure the drain voltage with a GND referenced PIC
and the voltage across the load will be (20V - Vdrain).
The second problem is that you appear to be using PWM to drive the gate. The voltage
across the load will be something like a square wave with a near 0 to 20V swing.
Your A/D will need some heavy filtering to give a meaningful result. And of course, the input of the A/D will need some sort of voltage divider to make sure that it doesn't see a voltage higher than Vref.
Charles Linquist
I couldn't understand that opamp level shifter circuit. Please give me an example
You need to set up the op-amps as a differential amplifier, and I don't have time to go into the full design right now. If you aren't already familiar with differential amplifiers, I think that my suggestion of measuring the drain voltage and subtracting it from 20 is the easiest approach for you. If the 20V isn't stable, you could even use a second channel of the A/D to measure that voltage exactly. Four resistors (for two voltage dividers), two capacitors (for filtering) and a little code and your are done. Everything would be ground-referenced.
Charles Linquist
Bookmarks