# DC volts and A/D converter

Discussion in 'The Projects Forum' started by michel, Jul 19, 2008.

1. ### michel Thread Starter New Member

Jul 15, 2008
2
0
DC volts and A/D converter
I'am using a 16F877A for my project...and I need to get the DC voltage from and other circuit (0 to 100 volt dc). This voltage is use for my calculation and results are shown on display.

I have found schematic for voltage 0 to 5 volts. The idea is to bring the 0 to 100 volt to scale 0 to 5 ( only one scale, no pot or resistors with selector).

A schematic that i have found is
http://www.electronics-lab.com/proje...14/ilc7107.pdf

But i don' t need the display. I need to get voltage the same way but instead of the ilc7107 it would be with my 16f877a.

Can anyone help me with this.

Tanks

2. ### SgtWookie Expert

Jul 17, 2007
22,183
1,729
Hi Michel,
Have a look at the attached schematic. It's a voltage divider comprised of two resistors and a potentiometer that is wired as a rheostat.

R1 limits the current from the 100v side to 1mA maximum.
The combination of R2 and R3 allows you to calibrate the divider. Adjust R3 so that when the input voltage is exactly 20V, you get exactly 1v out.
D1 is a "clamp" diode. This is to protect your PIC in case R2 or R3 should open up. It will limit the maximum output voltage to 5v+Vf of the diode, roughly 0.7v. Don't omit this part.

A better choice for D1 would be a Schottky diode like a 1N5817, which would clamp the voltage to +5.34v

File size:
60.7 KB
Views:
45
3. ### michel Thread Starter New Member

Jul 15, 2008
2
0
Hi SgtWookie!

1- I see on your schematic that the 0 to 100 volts is AC....on my project it will be DC...just to confirm with you...guess it doesn't mater.

2- I know I asking lot's...I trying to learn! self teaching. But , D1, how can it limit the voltage to 5v + Vf?

Tanks again

4. ### SgtWookie Expert

Jul 17, 2007
22,183
1,729
No, it doesn't matter - I simply used a sine wave because that's the default type of signal that the simulated "signal generator" makes within CircuitMaker. It would've worked with a plain DC level just as well, but that would've been rather boring, don't you think? Besides, I wanted to show that it would work over the entire range of 0-100v.

Take a look at the cathode side of D1 - it's connected to a simulated perfect 5V supply. D1 has a forward voltage of around 0.7v.

So, if for some reason either R2 or R3 breaks, burns up, or in some other way become electrically "open", R1 wouldn't have anything but your PIC uP input to keep the voltage level from rising to 100V, quite possibly damaging the uP input pin. But once the voltage rises to 5V+0.7v, or the Vf of D1, then D1 starts conducting, sending current into the 5v supply. Once the current flowing through R1 gets near a milliamp, the voltage can't rise any more. It's 'clamped' to 5V+D1's Vf.

Another way to do something similar would be to use a 5.6v Zener diode from the output side of R1 to ground. However, Zeners often start conducting small amounts of current well below their rated voltage, and that would interfere with the accuracy of the scaling of the voltage.

Some uP's might not have the input to their ADC protected with a clamping diode. Your PIC does. However, it's best to not stress the uC any more than you really have to.

5. ### nanovate Distinguished Member

May 7, 2007
665
1
For D1 I'd use a schottky diode.

6. ### SgtWookie Expert

Jul 17, 2007
22,183
1,729
I mentioned that as the last line in my 1st reply.

7. ### nanovate Distinguished Member

May 7, 2007
665
1
Oh yes you did ... I did not see that. I guess the only comment I can add is that the reason the Schottky is better is that it will turn on first thus preventing the uC's internal diodes from even turning on -- rather have an external diode take the brunt of the overvoltage than the expensive uC. But in Sgt Wookie's circuit there is a 100K resistor so unless the voltage goes way above 100V you "could" get away without the diode.

Could you also tell us what the frequency of the input is? If it is not DC then you may need to modify Sgt Wookie's circuit.