# Scan 100 to 500v at input of PIC microcontroller

Discussion in 'General Electronics Chat' started by innovetion, Oct 16, 2015.

1. ### innovetion Thread Starter New Member

Oct 16, 2015
4
0
Hi,

I am using PIC18f4550 micocontroller. Right now I am using inbuilt ADC to check input voltage i.e. 0 to 5v.
But now as per my application I need to scan 100V to 500V DC input voltage at ADC. How can I do ?

2. ### GopherT AAC Fanatic!

Nov 23, 2012
6,326
4,055
You can use an optocoupler with a high value resistor. That way it is electrically disconnected from the PIC.

Of a voltage divider (divide by 100) with two resistors. A 22k ohm from ground to input and a 2.2M from input to your 500V source.

3. ### Kermit2 AAC Fanatic!

Feb 5, 2010
3,854
968
A high resistance voltage divider with a 100:1 ratio.
Use several 20 Meg ohm resistors in series to make a 100 Meg ohm resistance. Use a single 900k resistor and a 100k pot together as the bottom leg of the divider and adjust the pot to fine tune the divider for exactly 1 to 5 volts.

4. ### joeyd999 AAC Fanatic!

Jun 6, 2011
2,758
2,937
This is not as simple as the posts above make it seem.

Look at page 270 of the datasheet. This show you how to calculate the maximum source impedance of your signal source for maximum resolution. For 10 bit resolution (as per the example in the datasheet), the source impedance (the parallel resistance of your input divider) must be 2.5K ohms or less.

To meet this criteria, you could use a voltage divider with fixed 1% resistors: 243K and 2.49K. The 243K resistor will dissipate 1W with a 500V input, and the maximum current will be 2mA to ground.

For safety, I'd split the 243K into two resistors, 121K 1% 1W (for a total 242K) -- wire wound would be preferable for safety, and use 2.43K 1% 1/4W for the resistor to ground. Nominal error will be 0.6%. If this is ok, no pot necessary.

Some further input protection and noise filtering would be required if this is for public consumption.

If you want to use lower power resistors*, you will need a front end buffer.

*Edit: and higher input impedance.

Last edited: Oct 16, 2015
bwack and ericgibbs like this.
5. ### joeyd999 AAC Fanatic!

Jun 6, 2011
2,758
2,937
Finally, *even if* you require better accuracy, I would not use a pot. I'd do the calibration in firmware. Firmware is always cheaper than a pot -- even if you get the pot for free.

6. ### MikeML AAC Fanatic!

Oct 2, 2009
5,451
1,066
Another question: can the HV power supply's 0V terminal be connected to the microcontroller's GND terminal, or do you need to keep the two systems galvanically isolated?

7. ### joeyd999 AAC Fanatic!

Jun 6, 2011
2,758
2,937
Good question, Mike.

Hopefully, he affirmatively knows the answer (and why). If not, I'll take the opportunity here to advise him that he is playing with some dangerous stuff and to be really, really careful.

Death is irreversible.

8. ### ScottWang Moderator

Aug 23, 2012
4,933
777
Vo1=1/5(Vi)=1/5(500V)=100V
Vo2=1/5(Vi)=1/5(100V)=20V
Vo=1/5(Vi)=1/4(20V)=5V

Vo1=1/5(Vi)=1/5(500V)=100V
choose 0.1mA for the input current.
R=E/I=500V/0.1mA=5M

Vo2=1/5(Vi)=1/5(100V)=20V
choose 0.1mA for the input current.
R=E/I=100V/0.1mA=1M

Vo=1/5(Vi)=1/4(20V)=5V
choose 0.1mA for the input current.
R=E/I=20V/0.1mA=200K

joeyd999 likes this.