Adjustable DC input for ADC reading - Page 1
Forum section: electronics / beginners

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 04:02:09 pm
content: Hi,I'm attempting to design an analog input for a specific purpose.The requirements are as follows:It can handle 0-48V.During normal operation the input voltage will be close to the the middle of the range spanWhen deviating from the normal value, the input voltage will go either to ground or to rail voltage (disregarding any noise)Frequency of input change is less than 1HzProtection against over voltage on the inside is neededTo accommodate this I've been thinking about a circuit like in the image. The potentiometer functions as a voltage divider and I can set it to a level where the current voltage range (0-5V, 0-12V, 0-24V or 0-48V) represents 0-3.3V on the output with protective clamping thanks to the zener diode. The 1M resistor represents the high impedance ADC.Am I missing something that will prevent this from working in practice? The incoming voltage may have some noise (long cables in a house) so I need to add some lowpass/highpass filters too and I'd appreciate any hints on this.Right know the output has a range of 0-3.3V, but it may be that I need to go down to 0-1V which makes the span much narrower which in turn will make it much more sensitive to noise. How should I handle such a case?Is there a better way to scale 0-48V down two a voltage measurable by a uC? Can an Op Amp be configured to use negative gain (I tried but did't get it to work)?Thanks!PS:For those wanting to try this circuit in a simulator, load this piece of text athttp://www.falstad.com/circuit/Code:$ 1 0.000005 8.281975887399955 56 5 43z 128 272 128 208 1 0.805904783 3.3172 -128 128 -176 128 0 6 44.64 48 0 0 0.5 Voltageg 128 288 128 336 0w 128 288 128 272 0r 48 160 128 160 0 1000174 -80 128 -32 192 0 10000 0.9356000000000001 Resistancew 128 160 128 208 0w -128 128 -80 128 0g -80 240 -80 256 0w -80 240 -80 192 0w 48 160 -32 160 0r 160 160 208 160 0 1000000w 128 160 160 160 0O 208 160 240 160 0x 147 246 196 249 4 24 3.3Vo 13 64 0 4098 5 0.1 0 1

author: BrianHG
author_rank: Super Contributor
timestamp: May 14, 2017, 04:41:14 pm
content: Fixed resistors in place of your trim-pot will offer precision repeat-ability from circuit to circuit & without a trim-pot, you may get rid of the 1K. It you want the adjustable range, keep everything as-is.For filtering, since you are only worried about frequencies below 1Hz, adding a 1uf cap across the ADC input and GND will work fine.Don't worry about noise, for this instance, resistors are pretty quiet. Just make sire the GND sided resistor and 1uf cap is next to the aGND on your ADC.

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 05:04:37 pm
content: Awesome, thanks Brian!

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 06:07:08 pm
content: Oh - about the 1K resistor. I've but it there to prevent accidental short circuits so I'll be keeping that.Now I just need to figure out a way to handle the 0-1V output case. Anyone with ideas?

author: danadak
author_rank: Super Contributor
timestamp: May 14, 2017, 06:27:37 pm
content: Your 1M at input, generally not a good idea because of leakage, andpossibility of not getting the ADC sampling cap fully charged/dischargedto the next sample value. Look at tech manual and datasheet for leakagevalue and ADC front end considerations. However all this being said youmight be able to get away with it because of the very low frequency/rate ofchange at input.One other on the 1M, it presents a high Z node subject to noise pickupin the layout and environment design operated in.If you leave 1M in and place a cap at ADC input of 1 uF, you have a time constantof 1 sec. To charge to 1 lsb, 8 bits (assumed for UP) then it takes ~ 3 secsto charge. At 12 bits it takes ~ 8 sec.http://www.analog.com/media/en/technical-documentation/application-notes/AN-1024.pdfRegards, Dana.

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 06:31:33 pm
content: The 1M won't be part of the design, it is onlyrepresentingthe ADC in this schematic.

author: Ian.M
author_rank: Super Contributor
timestamp: May 14, 2017, 06:35:19 pm
content: The zener doesn't turn on as sharply as you think it does and will cause non-linearity as you approach the upper end of the range. You should use a precision clamping circuit that clamps to a voltage derived from the 3.3V supply rail (without dumping current into the rail.How many bits is your ADC and what value is its internal sampling cap? With that information you can determine how much capacitance you need at the ADC pin for the voltage not to shift more than 1/2 LSB during sampling.

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 06:58:24 pm
content: Quote from: Ian.M on May 14, 2017, 06:35:19 pmYeah, I know it doesn't cut off sharply, but as the input signal will only go to either rail or ground voltage when not being stable in the middle of the range that shouldn't e a problem. that said, if I can design it to be more multi-purpose that'd be a good thing.So you're recommending something based on an Op Amp, like they show here?https://en.wikipedia.org/wiki/Clamper_(electronics)The ADC has 12 bit, not sure of the internal sampling cap right now. If I knew it, how'd I go about calculating the capacitance not to shift?

author: Ian.M
author_rank: Super Contributor
timestamp: May 14, 2017, 07:35:00 pm
content: We had a clamping discussion a few months ago:https://www.eevblog.com/forum/beginners/overvoltage-protection-with-a-twist/For less than 1/2 LSB shift:Cext > Csamp*2(N+1)where N is the number of ADC bits.

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 07:36:53 pm
content: Ah, thank you.

author: permal
author_rank: Regular Contributor
timestamp: May 14, 2017, 09:06:57 pm
content: Well, after reading though the thread you linked, Ian.M, I realize that I know less about electronics than I thoughtand I'm out on deep water. Thankfully I've only myself to answer toWhile I don't reallyneedthe inputs to be general purpose, i.e. I can probably go for my original design for my application, now that my curiosity has been piqued I'd really like to make them so. Both for the learning and the usefulness of such inputs.I tried to make sense of the schematics in that linked thread but they're unfortunately too complicated for me at this stage so I'll have to start reading up on the different component and circuit types that were used.Can I ask you to explain what "dumping current into the rail" actually means? As I understand it, the problem is that the voltage of the rail would fluctuate, possibly going above Vdd_max, but how? Does it have to do with charges in capacitors being released into the rail or something along those lines?

author: Ian.M
author_rank: Super Contributor
timestamp: May 14, 2017, 09:45:32 pm
content: Most regulated supply rails are provided from either a linear regulator with a series pass element or a switching regulator with diode rectification. Both are designed to supply current and neither has any provision to accept current from the load if the voltage rises above the setpoint. As such, if your clamping circuit dumps current into the supply rail, the regulator output current will reduce to compensate. However if it dumps more current into the rail than the loads on that rail are currently using, the regulator output currernt cant reverse to absorb the excess so the rail voltage will rise and bad things happen to voltage sensitive loads on that rail, usually resulting in critical loss of magic smoke.

author: danadak
author_rank: Super Contributor
timestamp: May 14, 2017, 10:56:01 pm
content: In CMOS there are parasitic diode structures inherent in the technologythat can dump current into the supply rail if the diodes are forward biased.Vin >= Vcc + Vdiode or Vin <= Vss - Vdiode will trun on these diodes.Same for outputsVout >= Vcc + Vdiode or Vout <= Vss - VdiodeSee CMOS section of thishttp://www.ti.com/lit/an/sdya009c/sdya009c.pdfRegards, Dana.