The Godfather talking
You think I am funny guy huh?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 27, 2024, 08:49:53 08:49


Login with username, password and session length


Pages: [1]
Print
Author Topic: Resistor divider error  (Read 3832 times)
0 Members and 1 Guest are viewing this topic.
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« on: December 20, 2013, 08:41:07 20:41 »

I've been playing around with a pic18F45K80 as a meter 12bit resolution 4.096 V Ref  0-40 volts , It's all working but there is a small issue but it's with the resistor divider in real time. My resistor divider consists of (R1) 43K & (R2) 4K7 and if you enter the voltage EG 13.43V input then the output from the resistor divider  you get 1.323 not quite 1:1 but close enough.  This reads close enough on both meters as the real meter reads 13.43V pic meter reads 13.42V A/D raw 1328 and input on RA0 is 1.320 volts. I have got a little calibration routine to correct this. If I measure 12.31V on a battery both meters read the same even when I apply a small load(4 x 12V fans). The trouble starts when I try to read higher voltages as follows
RA0     R/M     P/M    Raw value   (RA0 pic input, R/M real meter, P/M pic meter, Raw value)
.102V   1.04V   1.09V   108
.645V   6.57           6.59      996
1.007V   10.05   10.06      (Forgot to write down)
1.320V   13.43V   13.41v     1328
?          18.51    17.39   1722
1.911   21.91   19.38V      1918 (this where the trouble starts)
2.411V   31.09   24.48 2438 (this it gets worse)
If you enter the 31.09V on resistor divider calculator you get 3.063V out but in real time you can see that it reads 2.411 on RA0 but the raw value is 2438 and pic meter reads 24.48 the raw value is close enough but compared to the real meter it's nearly 6 volts out. My gut feeling is that this is caused by the current draw on 4K7, I've tried 6K8(R2) and 10K(R2) along with the corrected values of R1 with each change but get much of the same results the higher you go the worse the readings get. I thought I would of got pretty much the same reading 31.09 input output should be 3.063 (+/- littler for error) but not 2.411V  as to me that's a 65% error ??
Is there a better way of doing it or where I'm going wrong ?
any help/advice would be grateful
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
optikon
Cracking Team
Hero Member
****
Offline Offline

Posts: 853

Thank You
-Given: 1106
-Receive: 2007


« Reply #1 on: December 21, 2013, 01:46:33 01:46 »

I am not looking into the PIC datasheet but here are some things to consider.

1) Consider the input bias current to the pin as well as the max input voltage it can tolerate before turning on a diode and ruining your whole linear divider. If you dont know what these are, that should be a red flag right there.

2) For the resistor loading effect if the pic is drawing current, consider an opamp buffer to isolate.



Logged

I can explain this to you. I can't comprehend it for you.
solutions
Hero Member
*****
Offline Offline

Posts: 1826

Thank You
-Given: 656
-Receive: 905



« Reply #2 on: December 21, 2013, 03:46:35 03:46 »

Not familiar with the part, too lazy to look at the datasheet, but it sounds like you have a pulldown resistor on the port  being activated by the higher input currents. Check your port bit settings. I'm assuming you are using the internal Vref?

If that doesn't do anything, try a 430k/47k divider first. Maybe a voltage follower as a buffer off the divider, or an op amp 10:1 attenuator, second?
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #3 on: December 21, 2013, 07:20:57 07:20 »

I am not looking into the PIC datasheet but here are some things to consider.

1) Consider the input bias current to the pin as well as the max input voltage it can tolerate before turning on a diode and ruining your whole linear divider. If you don't know what these are, that should be a red flag right there.

2) For the resistor loading effect if the pic is drawing current, consider an op-amp buffer to isolate.
That I will look into and have already considered using an op-amp for buffering,

solutions I have thought about that and will check the Dev board in case that port as other loads on it (so will try another port)and no I'm using and external Vref of 4.096 but have also tried it with VDD as Vref but get the same results. I have a few things/thoughts to check now but you know how it goes the harder you think about things the worse it gets and you can think to deep plus you really want it to be perfect and accurate might be a bit to much to ask of a PIC but the ICL7106 is 10bit same as pic, I know 7106 is designed for it and PIC is really not. I've not really has this issue before as I got them working by just reading a set voltage say like 12V or 24V and altered the values to suit but this is for a friend who wants to measure different levels of voltage/current and needs it to be fairly accurate. The trouble is I like perfection and settle for nothing less  Grin
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
PaulC
Active Member
***
Offline Offline

Posts: 170

Thank You
-Given: 3935
-Receive: 133


information is free and should be shared for free


« Reply #4 on: December 21, 2013, 07:11:40 19:11 »

is there a thermal resistance causing the differential between the "real time" and software readings, maybe location or loading, temperature near resistors under load..
just to throw a spanner in the works..
Logged

find it , read it , share it .
ptr
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 17
-Receive: 2


« Reply #5 on: December 21, 2013, 08:21:51 20:21 »

Your problem has to do with recommended impedance of analog voltage source.

Check parameter A30 in the datasheet: A30 ZAIN Recommended Impedance of Analog Voltage Source 2.5 kohm.

Maybe it helps a bit if you put a 100 nF cap from the analog input RA0 to GND also consider lowering your voltage divider.

« Last Edit: December 21, 2013, 08:24:21 20:24 by ptr » Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #6 on: December 21, 2013, 09:03:01 21:03 »

I have done a bit of playing and used the op-amp to buffer the signal and the voltage out of the resistor divider as now stabilized and using the median filter method the voltage is now stable and no jumping up and down which you can is the raw value is jumping up and down 3 or 4 counts but reading stable. Still working in the precision though as I still think it could with been better. will let you know how it goes

wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Vineyards
Active Member
***
Offline Offline

Posts: 168

Thank You
-Given: 64
-Receive: 37


« Reply #7 on: December 21, 2013, 10:28:11 22:28 »

How much current can you withdraw from resistors with such high values and what happens when some or all of the current available is consumed? I wouldn't take any measurements unless I use some sort of a buffer stage because otherwise you can't expect stability. The current available would not be enough to drive the ADC. What you will get will be wild fluctuations.

The rules of Physics are iron clad. (I hope I am not totally at loss)
« Last Edit: December 22, 2013, 10:05:10 10:05 by Vineyards » Logged
bigtoy
Active Member
***
Offline Offline

Posts: 238

Thank You
-Given: 337
-Receive: 297


« Reply #8 on: December 22, 2013, 12:47:29 00:47 »

Good move on switching to the op-amp. Just keep in mind that everything has a tolerance - the resistors are only accurate to a certain percentage, and the op-amp will have a finite non-zero offset error (small, but measurable with a decent A/D converter). Improving precision or accuracy by choosing "better" components is extremely expensive - look at the price of 0.01% resistors on digikey as an example. A far cheaper way to achieve improved accuracy is simply to calibrate your circuit. A 2-point calibration (where one point can be ground, ie zero volts) and the other point would be a known voltage (measure it with a borrowed high-quality multimeter for example) allows you to determine both offset and gain accuracy for your overall circuit (y = mx + b).
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #9 on: December 22, 2013, 01:40:24 13:40 »

In one application I've used 43K 1% resistor with a 10K 25 turn pot(I know it's not 1% and its bad) with a 4.096V Vref with 12bit A/D, which I set the voltage to 15:00V input and calibrated with 10K to give 1.500V out of it and feed this through an MCP6002 op-amp as the buffer and now both PIC meter and real Meter reads 15:00 and when I adjust the PSU from 0 to 32V it reads +/-0.05V either way which I'm pretty happy with and don't think I can get it any better and the only down fall using Vref at 4.096V the unit will only measure 40V which is ok as PSU for my friend only goes to 32V so the AD RAW would be 3200 counts (12bit). Another application I worked on the voltage readings where not stable on the last 2 digit's so true calibration was not possible but now I've used the same routine in it but this only reads 12V I've used for the divider 0.1% fixed resistors for R1&R2 through the MC6002 now the voltage is now rock solid stable. Picture attached. Just after I took the photo the fluke meter read 12.00 but the voltage readings are stable which is what I wanted. Once I get a bit more time if people are interested in it I will throw a 2 mini versions together and up-load with code and with schematic but you will have to use your own hardware and tweaking as ISIS is not good enough for it. I will make it 10bit PIC for those who do not use 12bit pic's.
« Last Edit: December 22, 2013, 01:44:19 13:44 by Wizpic » Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC