Configuring A Programmable Gain Amplifier On An ADC
idbruce
Posts: 6,197
Hello Everyone
I am in need of a little guidance, I think I know the answer, but truthfully I am unsure. In the attached image, you will see a schematic of a circuit that I am using and testing. The ADC that I am using is a 12 bit and has a default gain of 2.048V. Considering that I am supplying 3.3V to VDD and 3.3V to VADC, I believe the gain should be set to 4.096V to achieve full scale, but like I said, I am unsure and could use some guidance.
I am in need of a little guidance, I think I know the answer, but truthfully I am unsure. In the attached image, you will see a schematic of a circuit that I am using and testing. The ADC that I am using is a 12 bit and has a default gain of 2.048V. Considering that I am supplying 3.3V to VDD and 3.3V to VADC, I believe the gain should be set to 4.096V to achieve full scale, but like I said, I am unsure and could use some guidance.
Comments
So even if you set the full scale to 4.096, you can only apply 3.6V to the ADC input.
I would use 2.048V full scale and use a resistor divider to scale the voltage going to the ADC input.
P.S. Or raise the value of R2 so the output does not exceed 2.048 volts over the expected temperature range.
Bean
That is certainly not the answer that I expected or wanted to hear, but thanks for responding. I wish I could find some good documentation on the subject, in simple terms of course.
Thanks Bean
The ADC is being supplied with 3.3V and VADC is also being with 3.3V. The 4.7K resistor and the 100K thermistor is a voltage divider circuit, with junction ADC CH being the signal going back to the proper ADC channel for conversion.
If you set the full scale to 4.096, which is convenient for your software because one tick is one mV, then you're going to be only using 3.15/4.096 or 76% of your ADC's range.
If you increase the 4.7K resistor so that the 3.15 falls to 2.0V, you can use the 2.048 prescale and get full range on the ADC. This gives you more precision of measurement. For example, if you change the 4.7K to 68K you'll see a Vmax of 1.96V and with 2.048 full scale, you'll be using 95% of the ADC's range.
To really work out the best solution, we'd need to know the range of thermistor resistance across the range of expected temperatures. Remember, you're likely losing considerable bits on the low end, because the thermistor resistance doesn't go to zero.
There are tweaks to the design that would be beneficial if your ADC has a double ended input option ... does it?
I am not sure how to answer that question intelligently
I believe the resistance at 25 degrees C is 100,000 ohms, where it goes from there, I do not have a clue.
The Part No. is B57560G1104F000, and if I am not mistaken, the R/T No. should be 8304. I have attached the datasheet, due to my uncertainty.
EDIT: Those tables are confusing to me, however I believe the max. temp will be 260C.
EDIT: If I interpreted it correctly, the minimum resistance would be 19.273 ohms.
Thanks for all your input, I truly appreciate it, because I am trying to put this all behind me. I would like to be able to melt some PLA or ABS plastic sometime in the near future.
When you say "double ended input option", I am assuming you mean differential input, if so then yes, the ADS1015 has 2 differential inputs, but my board is already all soldered up for single ended input and I am out of IO pins.
Min. Temp. = 25C
Max. Temp. = 260C
To read the thermistor data sheet, find your part number on page 3 and from that, find the Rt number for your part. It's 8304.
That means that you need to reference the information on pages 5 and 6, under the heading for Rt=8304. That's the right-most column.
The data here are the ratios of Rn/R25, the resistance at temperature N divided by the resistance at 25C. To get the resistance at 25C you need to measure it as each device is different. In the table on page 6, you see that the value for 265C is 0.0017829. So if you measure 50000 ohms (pulled out of my ***) at 25C, then at 265C, you'll have 50000 x .0017829 or 89 ohms. You can see from the coefficients at 260 and 270, that they are changing pretty quickly. This is because your thermistor is non-linear. There's about 8% difference in those coefficients over just 5C.
If your goal is to measure 265C with a high degree of accuracy, you'd use one approach here. If you want to measure a wider range, then you'd use a different approach. Presuming you want to measure 265C, knowing the thermistor would have a resistance of 89 ohms (remember, that's based on the 50000 ohms that I made up), then with your 4700 ohms resistor, you'd have a total resistance of 4789 ohms, a current of 3.3/4789 or 689uA and a voltage across the thermistor of 89 x .000689 or 61mV. If you use 4.096 for your gain, you're using a 12 bit ADC to measure a value of only 6 bits. Also, in this configuration, if your 4700 ohm resistor has 1% tolerance, that's 47 ohms of uncertainty and that's 50% of the 89 ohms you're effectively trying to measure. So you're getting 5 bits of error in a 6 bit result. Not a very good measurement. If your 4700 ohm resistor is a 10% tolerance device, then your trying to measure 89 ohms with 470 ohms of error - no need to build the circuit, just use a random number, I'd recommend 17.
So, if you want to build a reasonable circuit, the devil is in the details. What are you really trying to measure? Do you have the thermistor in your hand and can you measure it's nominal resistance at a known temperature?
It has been a while since I have looked at the datasheet for the breakout board, but I thought it required more pins for differential input. It doesn't matter, because like I said the board is soldered up.
As far as the tolerances go, I was thinking about that before you wrote that. Considering that I will have to order the 68K from Mouse, I might as well get one a low tolerance.
There will be two channels utilized, and 1) will be monitoring the nozzle temperature of a 3D printer extruder, and 2) will be monitoring the heated build platform of a 3D printer.
At approximately 25C the resistance is 98K
100_000 * 0.0019273 = 192.73Ω at 260°C.
So, at 260°C the output to the ADC will be near the 3.3V power supply, in fact Vadc = 3.3 - 192.73/(192.73+4700) = = 3.170V. If the temperature decreases to 250°C, R=226.15Ω and Vadc = 3.148V. A change of 21mV, so if you use the 4.096V range, your resolution of temperature will be about 0.5°C. Is that good enough? The resolution will be best around 110°C where the thermistor resistance is around 4700Ω.
Do you have an option to invert your circuit, that is, put the thermistor on the top and the 4.7K resistor on the top? Or, to follow up on Wayne's question, is does the ADC itself have a differential input (+) and (-)? In either case you could improve the resolution at the high end by using a higher PGA gain.
I use thermistors quite often, and have method like this, using a very similar ADC with a pga and the same gain commands, except 16 bits. In your case the reference voltage Vtotal=3.3V fixed, and Vtherm is the voltage at the junction of the two. ADC#PGA_1 sets the pga gain of the ADC. The child object calculates the resistance, having been initialized with the reference resistance value. Then interpolates in a table of resistance vs temperature and returns the Celsius*10 value.
Bruce, didn't you say you have a 100k @ 25°C thermistor?
Measuring 265C ± 10C with accuracy of ±0.1C requires a much different approach than measuring 265C ±50C with 5% accuracy.
If R(25) is 98000 ohms, then R(265) is about 175 ohms. And your 4700 ohm resistor is not a very good choice as most of the voltage drop will be across the 4700 ohm resistor and your ADC is stuck trying to measure small amounts. If the 4700 is exactly 4700, then the drop is only 0.118 on the thermistor and you should use maximum scaling of ±256mV. You'll still only be using 23% of your range, less than 10 bits.
So, what temperature range are you trying to measure and how much accuracy do you believe you need. The answer to those questions will help you choose a replacement for the 4700 ohm resistor and the tolerance you should specify. Note that the data sheet for your thermistor says it's tolerance is ±1%, you won't do any better than that no matter what. But the tolerance of your 4700 ohm replacement is, essentially, added to that 1%. The difference between 1% and 0.1% is about 3x, but we're only talking 30 cents.
Another consideration is what will the temperature at the 4700 ohm replacement be like? In your photo, it looks like it's near the print head and so its temperature will be going up and down a lot. That's another source of error.
That's not what I see. In his circuit as drawn, most of the drop is over the 4700 ohm resistor, almost none on the thermistor. The measured voltage is close to zero, not close to Vcc. Yes?
How's it going? Have not heard from you in a while.
I must have missed a zero
Yes, that is what I said, but if I was correct, well that is quite a different story
As far as temperature ranges go, it all depends on the type of material that you are printing with. As far as I can determine, without picking any specific type of material to print with, I will need to be able to measure the following ranges:
Extruder 175~230C
Bed 30~79C
And I would assume that this schematic should work reasonably well, since one of the worlds topmost authorities of 3D printing designed it and sells it. I am not saying that it couldn't be better, just that I assume that it will work decent enough for the intended purpose, but I could be wrong.
EDIT: However I should also say that the schematic was developed for use with a 10 bit ADC instead of a 12 bit, but I don't see how that would matter, but once again, I could be wrong
In the ranges of interest, that thermistor is pretty non-linear.
Attached is a little spreadsheet that shows the effects of the non-linearity. Ignoring all the questions of what value you should substitute for your 4700 ohm resistor and the prescale programmed into the ADC, you should be aware that the non-linearity is significant over these ranges. The spreadsheet shows that if you use a linear estimate for R vs T, you'll have almost 20% error in the range 175-230C and a 62% error in the range 30-80C; worst case. In other words, the value that you read from the ADC cannot be converted to temperature across these ranges without some interpolation or math or significant error.
All that not withstanding, do you have sufficient information to solve your problem, or are you looking for someone to solve it for you?
IDBruce.xls
However, your program would have to change ranges in order to measure lower temperatures. At 25°C for example, at 100kΩ, it will have to be back on the 4.096V range. Vadc = 3.3*(100_000 / 104_700). = 3.152V, which has to be acquired on the 4.096V range
The reference resistor at 4.7k is not a bad choice. A higher value will improve resolution at room temperature, but degrade it at high temperature. What is most important? My guess is that the ampp wants best control where the plastic is melting. But maybe 0.03°C is overkill and it could use, say, 15kΩ as the reference resistor and still have 0.1°C on the 256mV range. And improve the resolution at room temperature. In any case, the reference resistor should be a precision type, 1% or 0.1% tolerance.
That determines the temperature resolution too. So 2.2mV per °C becomes a 0.91°C resolution on the 4096mV range and 0.057°C on the 256mV range.
(with the 4.7kΩ reference R)
Sandy
I tried to follow along, but that was way over my head. So the questions become, would you stick with the 4.7K and if so, what range would you use for the extruder, and what range would you use for the bed?
I am a little confused, because I am getting conflicting scenarios.
.re: I wish I could find some good documentation on the subject, in simple terms of course.
Free:Analog Engineer's Pocket Reference eBook (may require TI registration)
Download PDF
(PDF, 7.11MB)
Written by op amp experts Art Kay and Tim Green, the Analog Engineer's Pocket Reference covers a wide variety of popular precision signal chain topics from op amp bandwidth and stability to analog-to-digital and digital-to-analog conversions and more. Download your free copy today to put this handy, tried-and-true reference guide at your fingertips.
https://www.ti.com/seclit/ml/slyw038a/slyw038a.pdf
A/D conversion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
81
Binary/hex conversions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
82
A/D and D/A transfer function
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
86
Quantization error
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
88
Signal-to-noise ratio (SNR)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
Signal-to-noise and distortion (SINAD)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
90
Total harmonic distortion (THD)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
Effective number of bits (ENOB)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
92
Noise free resolution and effective resolution
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
93
I may know a few things, but I am not very knowledgable about the subject One thing that I know for sure is that everyone has different temperature suggestions.
The closest tolerance being when printing ABS at the extruder, which only has +- 5C at the head, the rest of the temps are all over the place, but I tried to narrow it down.
To be able to print a variety of plastics, this is what I gathered:
Extruder 175~230C
Bed 30~79C
However I will most likely be printing with strictly PLA, which has the following requirements:
Extruder 175~200C
Bed 45~70C
The other most common plastic to print is ABS, and it has the following requirements:
Extruder 225~230C
Bed 80~110C
ksltd suggested bringing the VMAX of the signal down to 2.0V or less and using the default 2.048V scale. This actually made a lot of sense to me. However, I would imagine that the closer I get can get to 2.048V without actually going over the better off I will be, and of course with a low tolerance resistor being utilized for less error margin.
Anyhow another issue is this, it is not actually the accuracy of the reading that is important, but actually the consistency, as Sandy pointed out. Of course accurate temps would be nice, but if temperature readings are consistent, they can easily be scaled within the firmware, which is often the case, or so I have read.
BED_TARGET_TEMP = SUGGESTED_BED_TEMP + BED_THERMISTOR_INACCURACY
or
BED_TARGET_TEMP = SUGGESTED_BED_TEMP - BED_THERMISTOR_INACCURACY
/////////////////////////////////////////////////////////////////
EXTRUDER_TARGET_TEMP = SUGGESTED_EXTRUDER_TEMP + EXTRUDER_THERMISTOR_INACCURACY
or
EXTRUDER_TARGET_TEMP = SUGGESTED_EXTRUDER_TEMP - EXTRUDER_THERMISTOR_INACCURACY
Thanks for the link. Looks like a handy reference to stash away and peek at every now and then.
I hate to openly admit it, but I would have to say that is true for the time being. Eventually, depending how things go, I may want to change out the circuitry for something much more accurate.
Two temperature measurements, two thermistors?
Take Wayne's suggestion and leave the ADC on the 2.048V pga setting.
For the extruder, use a reference resistor of 4.12kΩ 1% or 0.1%, tied to 3.3V.
At 100°C the thermistor resistance is 6338Ω and the ADC will see 2 volts. Use the PGA2 setting, 2.048V full scale.
As the thermistor heats up to 260°C, the ADC will report values with a resolution of a bit better than 0.5°C. That should be fine.
For the bed, use a reference resistor of 64.9kΩ 1% or 0.1% tied to 3.3V.
At 25°C, the thermistor resistance is 100kΩ and the ADC will see 2 volts. Again the 2.048V pga scale.
It will still have sufficient resolution for the 110°C hotbed.