Switchable pullup resistor for analogue inputs

Go To Last Post
35 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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"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"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix 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.   I look forward to being able to predict the future!

  • 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.   I look forward to being able to predict the future!

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.   I look forward to being able to predict the future!

  • 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

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"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"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix 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.   I look forward to being able to predict the future!

  • 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.   I look forward to being able to predict the future!

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

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 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.   I look forward to being able to predict the future!

Last Edited: Sun. Jun 17, 2018 - 03:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry to resurrect this old thread, but I'm revisiting this switchable reference design, and have some additional considerations. From a previous post, this is on what my current approach is based:

 

 

An MCP23017 switches between 5V output (to enable the 5V reference) and High-Z (to disable the 5V reference). The resistor (R1) was initially going to be 1kOhm, but I'm revisiting this value (to be explored below).

 

As per my original post, I've planned for 2 signal input scenarios. The first whereby a 2-wire sensor would need the signal line pulled up to the 5V reference. The second whereby either a 3-wire sensor (as shown in the above image) or 2-wire sensor with external pullup to reference are to be measured, and do NOT require an internal pullup to 5V reference. The assumption at the time was that under scenario 2, the voltage (output voltage of the sensor, input voltage to the ADC) would be in the 0-5V range. However, I'm now using an ADC capable of bipolar inputs, so would like to be able to measure in the range +-20V.

 

Now that I've got both negative voltages at play as well as voltages much higher than the MCP23017 VDD (5V), I want to confirm whether this approach is still sound. From the MCP23017 datasheet, the maximum port current (whether source or sink) is 25mA and VDD has a maximum of 125mA. Assuming the 'worst' case whereby the 5V reference is enabled an a-20V input with a 1kOhm resistor:

  • Voltage = 5-(-20) = 25V
  • Resistance = 1000Ohm
  • MCP23017 port current = 25mA
  • Maximum number of concurrent inputs = 125mA/25mA = 5

 

If I instead use a 10kOhm resistor, the maximum port current is reduced to just 2.5mA, and would allow for all 16 inputs to be in this 'worst' case at the same time (total VDD current is 40mA). Does this logic work?

 

The other question I have is regarding the voltage seen by the MCP23017 pin. The datasheet specifies the following:

Voltage on all other pins with respect to VSS (except VDD): -0.6V to (VDD + 0.6V)

Is this purely to manage the port current? If not, is there a way I can adapt this approach to cater to the +-20V 'worst' case scenario? I've considered using the MCP23017 output to control the gate of a transistor, but I'd run into issues of leakage current, clamping to VDD, additional series resistance (Rds), etc.

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

No, it's not really good to overdrive the port pin & if you do clamp it to 5V or gnd , then how will you get an accurate reading when you have a 14.5V signal?  

Also what is preventing your ADC from blowing up with a 14.5V signal?  ADS1158 will not handle that range.

 

or 2-wire sensor with external pullup to reference are to be measured, and do NOT require an internal pullup to 5V reference.

So what, big deal, it has its own pullup...leave the internal one on and no circuit or pullup switching is needed.  There's just 2 pullups.  Do you have an issue with that?  If so, what? 

 

Rather than contort an old explanation from years, ago, freshly & completely state what you are doing, with the details.

so would like to be able to measure in the range +-20V

Doesn't that mean you need a 20V pullup?  

 

Provide a link to the sensor(s)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Jun 28, 2020 - 11:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Port current usually refers to the port sourcing or sinking current. You want to inject current as you are exceeding the voltage specs of the device. This is not advisable - strange things may happen.

The p-chan mosfet solution would be my suggestion.

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

avrcandies wrote:

No, it's not really good to overdrive the port pin & if you do clamp it to 5V or gnd , then how will you get an accurate reading when you have a 14.5V signal?  

Also what is preventing your ADC from blowing up with a 14.5V signal?  ADS1158 will not handle that range.

 

Rather than contort an old explanation from years, ago, freshly & completely state what you are doing with the details.

 

so would like to be able to measure in the range +-20V

Doesn't that mean you need a 20V pullup?  

 

Thanks for your input, much appreciated as always.

 

That all makes sense. The front-end circuitry also has a voltage divider network to bring down the +-20V to a level which is accepted by the ADC. The ADC itself also has protection circuitry built in.

 

The +-20V signals will only ever come from scenario 2 sensors. They don't need any pullup as they are externally powered/referenced before interfacing with the device.

 

Only the unreferenced 2-wire sensors, which interface directly with the device, need a pullup to the internal reference.

 

Kartman wrote:
Port current usually refers to the port sourcing or sinking current. You want to inject current as you are exceeding the voltage specs of the device. This is not advisable - strange things may happen. The p-chan mosfet solution would be my suggestion.

 

Thanks Kartman, that makes sense and was what I was expecting to hear.

 

As for the MOSFET solution, I'll have to do some more research, as I would have thought that as soon as the input voltage gets to a certain level, you'd have issues with the MOSFET's body diode?

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

They don't need any pullup

Why do you need to turn off the pullups?  Is there a problem if they are on?   It would be much simpler just to have them pulling up, possibly calibrate them out.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:

They don't need any pullup

Why do you need to turn off the pullups?  Is there a problem if they are on?   It would be much simpler just to have them pulling up, possibly calibrate them out.

 

That's definitely a consideration. If I can't reasonably implement the switchable approach, I'll look to just have static pullups on all the inputs, and just account for them in the conversion.

 

One thing I'd need to bear in mind I guess, is the affect that the inputs could have on the 5V rail. If I've got all 16 inputs at -15V (a use case that would never eventuate, but illustrates the point), I'd need to take into account the impact on the 5V rail. I guess that increasing the pullup resistor from 1k would help in this regard.

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

May be a constant current source might be an answer? Using a transistor and a handful of components would ensure the maximum current is limited by design. If the input exceeds 5V, then the transistor stops working.

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

Since your pullup is forming one leg of a precision divider to provide an ADC voltage, you don't want any switches or circuits involved (at least if you want rather high accuracy).  Note the "5V" raill may be 4.8V, 5.1V , etc....so that impacts things...you can use  a ratiometric ADC reading to negate some of that uncertainty (or you can measure the 5V rail & make that part of the calc).   If you need to display a value then you need to at some point convert from ratiometric to absolute.  If you are only using the ADC only for control purposes, then ratiometric is wonderful.

 

Remember: if your dividers are 1% values you won't get a 16-bit (or even 10 bit) answer without some significant cal.   Maybe you only want 8 bits?

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

also, the actual value of the pullup is not tightly defined.

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: 1

What sensors are being used? what accuracy is needed?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Darn,  I read the entire thread before I realized it was an old Thread.

But the good news it, it is actually a continuation of the original Thread.

 

It seems the inputs are growing in number and have a markedly different voltage range, power requirements, and output impedances...

 

What a mess!

 

A universal input analog front end design then becomes challenging, (as does ANY design that includes the words 16-Bit ADC!).

 

How many of these devices are there?

One in a research lab?

1000 in the field?

 

Who connects the sensors to the board?

An individual with no electronics knowledge?

An engineer?

 

Does the board have to figure out what type of input has been connected, or is there a config / user interface where this is told to the system?

 

What kind of accuracy on the signals is required?

 

Can the person setting up the system set (configure) a little PCB mounted DIP Switch, (like in the old days), when they connect an input to a given channel?

Can the processor configure the "dip switch" automatically, no dip switch required?

 

One option that hasn't been suggested yet is to have a high impedance buffer on the input to each channel that can tolerate any of the possible input signals.

Then route that signal to several analog front ends for signal conditioning, (Range, DC offset, etc), and feed them into multiple ADC inputs, for each sensor signal.

The correct analog front end will give a meaningful signal for the sensor attached to that channel.

The other processed signals and their ADC readings might well be saturated at a rail, or totally bogus, it doesn't matter.

If you have 3 analog front ends processing each input channel you configure the software to read the correct input based upon whatever sensor was applied.

This negates the need for an external signal MUX for selecting the correct analog front end signal, at the expense of using more ADC input channels.

 

At some point one might consider a system overhaul where instead of routing 32 analog signals, (an untold distance), to a micro / PC, one simply puts a small PCB with the correct analog front end and a small micro near the signal origins, and transmit the signals digitally back to the main data collection & processing board.

 

Thermistor gets a small blue interface board attached to the sensor, +/- 20 V sensor gets a red PCB, ...

All of which send digital signals to the main processor.

 

Each sensor has an optimized front end, not a somewhat kludged system with multiple trade-offs made to accommodate an unconnected sensor.

 

JC

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

avrcandies wrote:

Since your pullup is forming one leg of a precision divider to provide an ADC voltage, you don't want any switches or circuits involved (at least if you want rather high accuracy).  Note the "5V" raill may be 4.8V, 5.1V , etc....so that impacts things...you can use  a ratiometric ADC reading to negate some of that uncertainty (or you can measure the 5V rail & make that part of the calc).   If you need to display a value then you need to at some point convert from ratiometric to absolute.  If you are only using the ADC only for control purposes, then ratiometric is wonderful.

 

Remember: if your dividers are 1% values you won't get a 16-bit (or even 10 bit) answer without some significant cal.   Maybe you only want 8 bits?

 

I do indeed need absolute values, but I can also read the 5V rail as part of the calculation. As for the resistors, it would certainly make sense to use higher tolerance (e.g. 0.1%) for the points you've raised above. I'd like to resolve 10mV at the 'worst' case scenario (+-20V). As part of the front-end circuitry I have a voltage divider which reduces the input voltage by a factor of 2 (+-10V), which would give a 'worst case' range of 20V. This would then require 11 bits of resolution for 10mV across a 20V range. Given all the discussion in this thread, and the subsequent research I've been doing, I think it best to discount the switchable approach for this use case. As such, I'd be looking at one of two options:

  1. Pull all the inputs up and select resistors (both the pull up to 5V reference and the voltage divider) of suitable tolerance to deliver the ~11 bits.
  2. Split the inputs into externally referenced type (allowing for both 0-5V and +-20V inputs) and internally referenced type (allowing for 0-5V 2-wire inputs via the pullup resistor to 5V reference).

 

I'd like to exhaust option 1 methods before looking at option 2 if possible. In my mind, option 1 would like something like this:

 

 

The user can specify whether the input is externally or internally referenced, as well as the indicative voltage range. Given I can read the 5V rail and allow for any deviations caused by externally referenced signals, is this approach sound?

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

A few things:

 

Unless we see what is driving the input, the notion of pullup doesn't mean much of anything...for example if the input is coming from some opamp, the pullup will have essentially no effect whatsoever.

So, what circuit is driving the input, that must be shown!!

You prob need a cap at the adc, for anti-aliasing & general noise suppression.

Since this don't spec your sensor we don't know the expected range---from 0 to 20v, or something else?  That range, and the divider scaling, and basic ADC full-range resolution determines your usable resolution.

Generally, inputs should always be drawn on the left, unless it is not possible or highly inconvenient to do so---we read schematics from left to right!!

 

 

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Microchip have the pac1934 chip. 4 chans of 0-32V with 16 bit resolution. No messing around with dividers.

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

A pull-up on an analog input can help detect when a remote device is disconnected.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Thanks again for your input everyone.

 

avrcandies wrote:

A few things:

 

Unless we see what is driving the input, the notion of pullup doesn't mean much of anything...for example if the input is coming from some opamp, the pullup will have essentially no effect whatsoever.

So, what circuit is driving the input, that must be shown!!

You prob need a cap at the adc, for anti-aliasing & general noise suppression.

Since this don't spec your sensor we don't know the expected range---from 0 to 20v, or something else?  That range, and the divider scaling, and basic ADC full-range resolution determines your usable resolution.

Generally, inputs should always be drawn on the left, unless it is not possible or highly inconvenient to do so---we read schematics from left to right!!

 

Apologies for the missing information. There are 3 sensor types with which I envisage I need to interface.

  1. Variable resistance 2-wire temperature sensor. E.g. OEM automotive IAT sensor. When tied up to 5V (via a resistor), outputs a linear voltage between ~0.5V and ~4.5V.
  2. Ratiometric 3-wire sensors. E.g. OEM automotive pressure sensor. Utilises an external power supply, and outputs a (typically) ~0.5-~4.5V signal (which may not necessarily be linear).
  3. Variable reluctance and inductive sensors. E.g. OEM crankshaft position sensor. A passive sensor which produces a sinusoidal (in the example case of the crankshaft position sensor) signal around 0V; I'm allowing for measureable amplitudes up to +-20V.

 

As for the cap on the ADC input, totally agree. I didn't show it in the diagram above for simplicity. Thanks for the point regarding diagram inputs, I've learnt something today :)

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


 

When tied up to 5V (via a resistor), outputs a linear voltage between ~0.5V and ~4.5V.

Are you certain?  Maybe so, since the sensor has some strange curve. 

 

A resistor divider itself is nonlinear vs R---possibly negating the sensor's curve (I didn't look) & giving a linear output....I'd be somewhat surprised if it all worked out that way..

 

Here are 2 divider examples,,,,the bottom (grounded resistor  goes from 0 to 50K, the upper (pullup) is either 10k or 50k...in any case, the ADC will give a number that can be  magically coagulated into a temperature value.

 

In the old days there were actual books about the crazy "shapes" that could be created with ganged pots (linear & nonlinear too) and combinations of parallel/series values.   They'd sit around weeks, like it was a game.  I can generate that shape using only 2 pots and 1 resistor!!

 

This is a simplistic example of what I'm referring to:   http://www.geofex.com/article_folders/potsecrets/potscret.htm

 

Resistive sensors have come a long way.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Jun 30, 2020 - 07:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That all makes sense. The intent here would be that the user enters the specific sensor configuration when connecting the sensor. For a linear output, they would specify the 0V and 5V conversion values, for anything more exotic they could enter points of interest between 0V and 5V such that a conversion could be performed at any voltage along the curve. The conversion curves provided by the sensor manufacturers are typically based on a specific pullup resistor value (e.g. 1k, 2.2k, etc), so this would also need to be taken into account given the proposed fixed internal pull up resistor.