Switchable pullup resistor for analogue inputs

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Afternoon all,

 

Following my previous topic, I'm looking for some input on an element of my data acquisition design. My 32 analogue inputs will be interfaced with 2 16-channel, 16-bit ADS1158 ADCs. The analogue inputs can come in two flavours (depending on how the end user sets up the device):

 

  1. Powered signal line, which is pulled up to 5V via a 1kOhm resistor prior to connecting to my device.
  2. An unpowered signal line, which my device will need to pull up to 5V via a 1kOhm resistor.

 

The following pseudo-diagrams illustrate the two potential input configurations (blue represents my device):

 

Unpowered signal line:

 

 

Powered signal line:

 

 

Note: proper grounding would obviously be taken into account (not shown in the diagrams).

 

I posed this question some time back on another forum, and it was recommended I use a P-channel MOSFET to act as a switch. When the MOSFET is turned on, the line up to 5V via the 1kOhm resistor is enabled, when the MOSFET is off the line up to 5V via the 1kOhm resistor is open circuited.

 

Is this the optimum approach? I've got plenty of spare GPIO on my SoM, so can spare 32 dedicated lines to turn on/off each input MOSFET as required. It looks like 2-channel P-channel MOSFETs are the best bang for buck, so I'd have 16 MOSFETs controlling the 32 analogue inputs.

 

It's worth noting that I have 3V3 GPIOs, so the solution needs to facilitate switching on/off the 5V MOSFET with a 3V3 input.

 

Any confirmation, alternate methods, suggested MOSFETs (or otherwise) would be greatly appreciated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try two of these:

 

http://ww1.microchip.com/downloa...

 

YOu can power them from 5v, and the SPI inputs should work with 3v3 data input.  

 

Set the output register to all ones, connect 1k resistors in series as you show in your diagram.

 

for signals that do not need the pullup you simply set the associated MCP pin to an input and it essentially becomes a Hi-Z taking the 1k out of the picture.

 

two chip and a little bit of code solution

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?  - Lee "theusch"

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not simply put a pull up on all of the lines?  If they already have a pullup, so be it.

Also, pullups are not usually associated with an analog sensor signal going into an adc.  In such a case it is usually part of a divider, or offsetter, rather than a pullup, per se.

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:

Try two of these:

 

http://ww1.microchip.com/downloa...

 

YOu can power them from 5v, and the SPI inputs should work with 3v3 data input.  

 

Set the output register to all ones, connect 1k resistors in series as you show in your diagram.

 

for signals that do not need the pullup you simply set the associated MCP pin to an input and it essentially becomes a Hi-Z taking the 1k out of the picture.

 

two chip and a little bit of code solution

 

Jim

 

That's great Jim, thanks for your input. I've used MCP32x17 devices previously, I'm not sure why I didn't consider them. To confirm, this is how your solution would work (a single input and MCP32x17 channel shown):

 

 

I fully understand how the output mode works (i.e. the sensor is pulled up to the 5V output of the MCP32x17), but I'm not sure about the input mode. By making the MCP32x17 channel an input, the 1kOhm is 'out of the picture'; is that because the input of the MCP32x17 is of sufficiently high impedance that no current flows, effectively open circuiting the 1kOhm line?

 

avrcandies wrote:

Why not simply put a pull up on all of the lines?  If they already have a pullup, so be it.

Also, pullups are not usually associated with an analog sensor signal going into an adc.  In such a case it is usually part of a divider, or offsetter, rather than a pullup, per se.

 

That's certainly an option at this point. I'm trying to avoid that simply to maximise the resolution of the incoming signal. Applying a 5V voltage to an already powered signal will act as a divider and reduce the effective signal range of the input (e.g. 0-5V to 0-2.5V). I'm making up for this to an extent through the use of a 16-bit ADC over a 12-bit ADC, but I'd like to make the most of the input range if possible :)

 

Point taken on the 'pullup' resistor nomenclature :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Applying a 5V voltage to an already powered signal will act as a divider and reduce the effective signal range of the input

 Well, you do have to say what the signal is...if it is a signal from an opamp output, then adding a "pullup" should have no (or extremely minor) effect.   The only time it would have an effect (or divider effect), is proportional to the signal's driver non-zero output impedance.   A pull up would also have a huge effect on a sensor driver that can't sink current  (driver that can't pull towards gnd).  

 

 

Also, looking at your diagram...not sure if it tells the whole story..anyhow you should likely TIE your sensor to +5V  & put your resistor in the gnd lead and measure there, for generally improved accuracy.  It's easier to process 20mv around gnd , than around 5V.   This is more true if the ADC ref is not the exact same supply as the sensors.   A 100mv difference between sensor supply & ADC ref would give a 100mv reading difference near the top end, so a 20mv reading could read 20mv+/-100mv...down near gnd a 20mv reading would read 20mv(4.9/5)  or 20mv(5/4.9)...much better.

When in the dark remember-the future looks brighter than ever.

Last Edited: Thu. Jun 14, 2018 - 04:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Applying a 5V voltage to an already powered signal will act as a divider and reduce the effective signal range of the input

 Well, you do have to say what the signal is...if it is a signal from an opamp output, then adding a "pullup" should have no (or extremely minor) effect.   The only time it would have an effect (or divider effect), is proportional to the signal's driver non-zero output impedance.   A pull up would also have a huge effect on a sensor driver that can't sink current  (driver that can't pull towards gnd).  

 

 

Also, looking at your diagram...not sure if it tells the whole story..anyhow you should likely TIE your sensor to +5V  & put your resistor in the gnd lead and measure there, for generally improved accuracy.  It's easier to process 20mv around gnd , than around 5V.   This is more true if the ADC ref is not the exact same supply as the sensors.   A 100mv difference between sensor supply & ADC ref would give a 100mv reading difference near the top end, so a 20mv reading could read 20mv+/-100mv...down near gnd a 20mv reading would read 20mv(4.9/5)  or 20mv(5/4.9)...much better.

 

The majority of sensors will be 2-wire thermistors.

 

As per your second paragraph, this solution speaks to your earlier point of doing away with any switching, and just connecting all inputs to 5V? If I were to go with that approach your suggestion makes sense. I haven't yet gone through the power supply considerations, but I'd certainly endeavour to provide a common 5V reference for the sensors and ADCs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My point is that differing 5V supplies (or adc references) will be like treetops in the forest..the one over there is not the same height as the one over here.   However gnd can more easily be kept flat everywhere, since it doesn't depend on any part (regulator) tolerance.   Thus, measuring relative to gnd is inherently somewhat more stable.

 

Measuring from the top of three different 12 ft ladders to see how high up workers are is more complicated than simply measuring how far they are from the gnd.

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jars121 wrote:
pseudo-diagrams

Eh??

 

They are real diagrams!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

My point is that differing 5V supplies (or adc references) will be like treetops in the forest..the one over there is not the same height as the one over here.   However gnd can more easily be kept flat everywhere, since it doesn't depend on any part (regulator) tolerance.   Thus, measuring relative to gnd is inherently somewhat more stable.

 

Measuring from the top of three different 12 ft ladders to see how high up workers are is more complicated than simply measuring how far they are from the gnd.

 

That makes perfect sense. If I pay special attention to the voltage reference design, does this become a somewhat moot point?

 

awneil wrote:

jars121 wrote:
pseudo-diagrams

Eh??

 

They are real diagrams!

 

You're far too kind! haha

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The picture in post #4 is what I was thinking and your description is also accurate as well.

Can you provide part numbers of the two sensors you are using by chance?
Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?  - Lee "theusch"

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgmdesign wrote:
The picture in post #4 is what I was thinking and your description is also accurate as well. Can you provide part numbers of the two sensors you are using by chance? Jim

 

Thanks for confirming Jim. I don't have part numbers I'm afraid, as these are theoretical sensors at this stage. I'm testing with some generic two-wire thermistors at the moment, but will be interfacing with three-wire sensors as well (Sensor PWR, GND and SIGNAL).

 

avrcandies wrote:

My point is that differing 5V supplies (or adc references) will be like treetops in the forest..the one over there is not the same height as the one over here.   However gnd can more easily be kept flat everywhere, since it doesn't depend on any part (regulator) tolerance.   Thus, measuring relative to gnd is inherently somewhat more stable.

 

Measuring from the top of three different 12 ft ladders to see how high up workers are is more complicated than simply measuring how far they are from the gnd.

 

I've been giving this some further thought, and I really don't know how to apply this to my application. For two-wire sensors, it's relatively straight forward, as both the SIGNAL and GND leads interface with my device (the first diagram in my first post). However, for three-wire sensors, only the powered signal line interfaces with my device (sensor power and sensor ground are external, but the sensor ground will be connected to my device ground), so I don't have a choice but to measure the signal with respect to the sensor's external 5V?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Regardless, your thermistor forms some sort of voltage divider, simply measure with respect to gnd.  Depending on how you rig things up, the thermistor & adc may or may not share the exact same physical reference level.   Of course, it is better if they do, since any measurement will them be ratiometric.  This means if suddenly (or slow drift), the ref level fell 10%, you'd still get the exact same adc reading, since both the adc ref & the measured voltage would fall 10%.  Of course this only happens when the thermistor & adc share the same ref (supply).

 

===========

When measuring voltages in general, you can always measure relative to the high side or gnd, your choice.  In general, the high side is probably fluctuating around , so  not as good.   Say you have 5V power and  measure a 3.000V signal

with respect to gnd you read 2.98, 3.01, 3.03, etc...pretty good.    With respect to 5V you read 2.02, 1.99, 1.97 below 5v....Ok, just subtract and get 5-2.02=2.98, 5-1.99=3.01, 5-1.97=3.03, ok.   However, say the 5v has sagged a bit to 4.9V...now all of your subtractions will give a large error.  The program doesn't know the reading have sagged & makes wrong decisions.

 

   

 

 

 

 

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

Regardless, your thermistor forms some sort of voltage divider, simply measure with respect to gnd.  Depending on how you rig things up, the thermistor & adc may or may not share the exact same physical reference level.   Of course, it is better if they do, since any measurement will them be ratiometric.  This means if suddenly (or slow drift), the ref level fell 10%, you'd still get the exact same adc reading, since both the adc ref & the measured voltage would fall 10%.  Of course this only happens when the thermistor & adc share the same ref (supply).

 

===========

When measuring voltages in general, you can always measure relative to the high side or gnd, your choice.  In general, the high side is probably fluctuating around , so  not as good.   Say you have 5V power and  measure a 3.000V signal

with respect to gnd you read 2.98, 3.01, 3.03, etc...pretty good.    With respect to 5V you read 2.02, 1.99, 1.97 below 5v....Ok, just subtract and get 5-2.02=2.98, 5-1.99=3.01, 5-1.97=3.03, ok.   However, say the 5v has sagged a bit to 4.9V...now all of your subtractions will give a large error.  The program doesn't know the reading have sagged & makes wrong decisions.

 

I understand this on a theoretical level, but I'm struggling to put together the practical implementation in my head. Consider the following setup, which is essentially the worst case scenario:

 

 

In this situation, the sensor has its own microcontroller, which outputs a 0-5V analogue signal via a dedicated signal wire. The sensor has it's own 5V power source. As shown on the diagram, the sensor GND and GND of my device will be common. In this worst case scenario, the +5V source for the sensor and the +5V source used for my device's internals (MCP32x17 and ADS1158 ADC) are different. Given that the ground of the sensor unit and my device are common, how would I measure the SIGNAL input with respect to GND? I've only ever compared inputs to the ADC Vref, so I'm not sure how to go about a low-side measurement.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

so I'm not sure how to go about a low-side measurement.

The ADC value IS a low side measurement...it shows how many counts (volts) you are away from gnd!  The exact scaling is determined by the ADC reference voltage level & of course your signal level (which is scaled by your signal's supply)...when these 2 supplies mismatch or drift, then  a bit of chaos can obviously erupt.  If using the ADC internal bandgap (or an external high quality vref), THAT drift should be low.  As mentioned, if the sensor AND ADC can use the same physical reference, then those variations would ratiometrically cancel out.

 

Note that if your sensor is far away, you may want to use a differential voltage measuring mode, or a current transmitter arrangement.  These keep the signal exact, all to way to the micro, even in presence of common mode noise, gnd loops, etc

 

 

When in the dark remember-the future looks brighter than ever.

Last Edited: Sat. Jun 16, 2018 - 04:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the temperature range you want to measure?

 

Jim

 

Click Link: Get Free Stock: Retire early!

share.robinhood.com/jamesc3274

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

so I'm not sure how to go about a low-side measurement.

The ADC value IS a low side measurement...it shows how many counts (volts) you are away from gnd!  The exact scaling is determined by the ADC reference voltage level & of course your signal level (which is scaled by your signal's supply)...when these 2 supplies mismatch or drift, then  a bit of chaos can obviously erupt.  If using the ADC internal bandgap (or an external high quality vref), THAT drift should be low.  As mentioned, if the sensor AND ADC can use the same physical reference, then those variations would ratiometrically cancel out.

 

Note that if your sensor is far away, you may want to use a differential voltage measuring mode, or a current transmitter arrangement.  These keep the signal exact, all to way to the micro, even in presence of common mode noise, gnd loops, etc

 

 

 

Understood, thanks for your patience and continued clarifications. I will definitely be using a precision reference for the ADC, but won't have any control over the external sensor 5V. I think I'll just have to accept that there might be some minor variation between the 2 5Vs, and trust that the external 5V source will be relatively accurate with respect to the shared GND.

 

ki0bk wrote:

What is the temperature range you want to measure?

 

Jim

 

 

I'm interfacing with existing sensors, so I don't really have control over their configuration or range, but I'd expect temperatures between ~20 degrees (C) and 120 degrees (C).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Understood, thanks for your patience and continued clarifications. I will definitely be using a precision reference for the ADC, but won't have any control over the external sensor 5V. I think I'll just have to accept that there might be some minor variation between the 2 5Vs, and trust that the external 5V source will be relatively accurate with respect to the shared GND.

 

That's fine, just remember if the sensor supply changes 3%, your adc reading will also change 3%, if not using a ratiometric setup.   That could be an issue if you make your sensor so its signal only changes 2% over a 100 degree swing!!  Then the 3% change would look like a 150 degree variation/error.

When in the dark remember-the future looks brighter than ever.

Last Edited: Sun. Jun 17, 2018 - 03:55 PM