Expanding inputs

Started by psyclopedia February 1, 2006
I've been struggling with this one for a few days, to no avail.

I have a bunch of analog sensors that I read with GetADC().  Each
sensor going to a seperate pin.  Some of the sensors have voltage
dividers in the circuit, some do not.  Some are counting pulses, some
are reading resistance.  

Now though, I've used all of the available pins for analog input.  So
what I'd like to do is use some method of switching to combine all of
the sensors into 1 ADC pin (or a couple) and use the other digital
pins so selet which sensor I am reading.  

My transistor skills seem to be lacking, now that I actually have to
do something besides turn on an LED.  Could someone point me toward
the proper methodilogy to do some simple switching?

My primary concern is that the transistor will taint the analog values
at the pin.  

-Don
	
Don,

When using transistors, you will always have to drop some voltage to 
close the output side PN junction. This may taint your application? 
Although I have not tried what you are attempting to do, I would 
probably opt to try small 5V relays first as the outside of a relay 
will yield less resistance than a transistor.

If you want to try the transistor method (NPN) -- hook up the emitter 
(-) and base (+) pins to the digital I/O and the Collector (+) and 
Emitter (-) to the Analog. This is the common emitter arrangement - 
be sure to spec the proper resistor sizes according to the transistor 
and load requirements.

With the relay method, however, -- just hook up the two control pins 
to the digital I/O and 5V and wire your Normally Open (NO) output 
(common pin and NO pin) so that it is in line with one of your sensor 
I/O wires. Without the 5V from your digital I/O, the sensor wired 
through the relay would be inactive.

Good luck,

John
	--- In basicx@basi..., "psyclopedia" <psyclopedia@...> wrote:
[]
	
 > ... Some are counting pulses, some are reading resistance.

Counting pulses is not normally an analog function so, unless the pulses 
you are counting peak below about two volts, you will free analog pins 
by moving the counted pins to digital inputs (BX-24 pins 5 through 12).

If you must multiplex an analog input, you can do it with a 4066 quad 
CMOS bilateral switch, which takes a logical input to control each of 
four SPST switches.  Each switch can pass essentially any signal in the 
0-5v range, analog or digital.  You can parallel and cascade them, too.
http://www.fairchildsemi.com/ds/CD/CD4066BC.pdf
	Tom

The chip that Tom sugessted would surely be more compact than 
individual relays. Very good suggestion would be simple to implement.

John
	  Each switch can pass essentially any signal in the 
> 0-5v range, analog or digital.  You can parallel
and cascade them, 
too.
> http://www.fairchildsemi.com/ds/CD/CD4066BC.pdf
> 
> 
> Tom
>
	
Thanks very much Tom.  That's much easier to work with than relays. 
I'm looking through the spec sheet right now.  

I usually use the upper and lower ADC values (0 and 1023) to indicate
a bad sensor (shorted or not connected).  The only problem with the
bilateral switch is the on resistance.  

One of the sensors I'm using is a simple thermistor, implimented as
shown below.  With resistance between the ADC pin and the voltage
divider junction, the pin will always see some resistance to ground,
even when the sensor is a dead short.  The thermistor has a resistance
range of 0 to 90 Ohms.

              +5V
               |
               |
               <
               > R1
               <
               >
               |
               |
               |
               O----BX ADC Pin
               |
               |
             Sensor (R2)
               |
               |
               =Gnd
                
I'll have to get one of them and try it in the circuit to see how much
of an impact it has.

So it's back to ExpressPCB I go...

Thanks again for the insight.

Don
	--- In basicx@basi..., "Dr. John R. Wright, Jr."
<john.wright@...> wrote:
>
> The chip that Tom sugessted would surely be more compact than 
> individual relays. Very good suggestion would be simple to implement.
> 
> John
> 
> 
>   Each switch can pass essentially any signal in the 
> > 0-5v range, analog or digital.  You can parallel and cascade them, 
> too.
> > http://www.fairchildsemi.com/ds/CD/CD4066BC.pdf
> > 
> > 
> > Tom
> >
>
	
Here are some chips used in data acquisition expansion boards

ADG506A 16-Channel Multiplexer
ADG508A 8 Channel Analog Multiplexers

These chips require aprox. 11 to 16 volt VDD supply though and are 
available in a pdip package.

Requires also 4 i/o pins to select input.

http://www.analog.com/en/prod/0,,768_836_ADG506A%2C00.html
	RR

--- In basicx@basi..., "psyclopedia" <psyclopedia@...> wrote:
>
> I've been struggling with this one for a few days, to no avail.
> 
> I have a bunch of analog sensors that I read with GetADC().  Each
> sensor going to a seperate pin.  Some of the sensors have voltage
> dividers in the circuit, some do not.  Some are counting pulses, 
some
> are reading resistance.  
> 
> Now though, I've used all of the available pins for analog input.  
So
> what I'd like to do is use some method of
switching to combine all 
of
> the sensors into 1 ADC pin (or a couple) and use
the other digital
> pins so selet which sensor I am reading.  
> 
> My transistor skills seem to be lacking, now that I actually have to
> do something besides turn on an LED.  Could someone point me toward
> the proper methodilogy to do some simple switching?
> 
> My primary concern is that the transistor will taint the analog 
values
> at the pin.  
> 
> -Don
>
	
 > ... With resistance between the ADC pin and the voltage divider 
junction, the pin will always see some resistance to ground, even when 
the sensor is a dead short.

You don't show that resistance in your drawing, if I understand you.  A 
resistance in series with an analog input will have little effect unless 
it is quite large since the analog input impedance is very large.

And your description of the function sounds odd to me.  An analog input 
does not measure resistance; it measures voltage.  The circuit you drew 
is a voltage divider.  The voltage at the junction of R1 and the sensor, 
R2, seen by the analog input pin, will be zero if the sensor is shorted 
- shows zero ohms.  A zero-ohm thermistor is also unusual in my 
experience.  Typical thermistors indicate 10k at 25C, and the resistance 
decreases non-linearly with increasing temperature, an NTC.  It will 
never be zero, even if it is 100 ohms at 25C.  And doesn't the current 
drawn by a low-value thermistor produce an unnecessarily large 
self-heating error?

In any event, a typical load impedance (resistance) for the 4066 is 10k; 
if your sensor is excessively loaded by that you can make it larger but, 
if your source impedance is very low, like your example, the switch and 
load will not appreciably affect your measurements - and your series 
resistor will serve no value, I'll bet.
	Tom

--- In basicx@basi..., Tom Becker <gtbecker@...> wrote:
>

> You don't show that resistance in your drawing

You're right.  The resistance (i.e. bilateral switch) would be right
at the BX pin, as this is where I would want to switch between sensors.
 
> resistance in series with an analog input will
have little effect
unless 
> it is quite large since the analog input impedance
is very large.

This is what I don't know.  I'm sure you're right on this one, I'm
just being picky about the cleanest path to the ADC pin I suppose.

> 
> And your description of the function sounds odd to me.  An analog input 
> does not measure resistance; it measures voltage.  The circuit you drew 
> is a voltage divider.  The voltage at the junction of R1 and the
sensor, 
> R2, seen by the analog input pin, will be zero if
the sensor is shorted 
> - shows zero ohms.  

I order to measure resistance, I'm using the sensor as part of the
voltage divider.  Some of the other sensors output a simple votage, so
no voltage divider is required.  As long as the ADC pin will see no
voltage with the sensor shorted, then I'm good.  

A zero-ohm thermistor is also unusual in my 
> experience.  Typical thermistors indicate 10k at
25C, and the
resistance 
> decreases non-linearly with increasing
temperature, an NTC.  It will 
> never be zero, even if it is 100 ohms at 25C.  And doesn't the current 
> drawn by a low-value thermistor produce an unnecessarily large 
> self-heating error?

Again, you're right.  These are not standard thermistors.

> 
> In any event, a typical load impedance (resistance) for the 4066 is
10k; 
> if your sensor is excessively loaded by that you
can make it larger
but, 
> if your source impedance is very low, like your
example, the switch and 
> load will not appreciably affect your measurements - and your series 
> resistor will serve no value, I'll bet.
> 
I'll bet you're correct.  I've order a few of these switches to
experiment with.  From what you're saying.  I'm guessing that they'll
work just fine.

Thanks for your input Tom, much appreciated. 

-Don
	
RR, very nice chips, thanks for posting up. I also like the ADG526A 
and ADG527A.

Don, since all these AD chips have EN lines you could really go 
crazy and use a 74xx595 to one or several 74xx138 chips and cascade 
100s of the ADGs together (power permitting!!).

I am currently using the 74xx595/74xx138 combo to make 2 pins of the 
BX-24 into 16 serial I/O ports. Total BX-24 pins required for this 
is 5.

More on the 74x595 => http://www.phanderson.com/bx24/sh_out.html

The 74xx138 is pretty straight forward, google for more info.

Good luck,

Kmac

--- In basicx@basi..., "raunig2003" <raunig2003@...> wrote:
>
> Here are some chips used in data acquisition expansion boards
> 
> ADG506A 16-Channel Multiplexer
> ADG508A 8 Channel Analog Multiplexers
> 
> These chips require aprox. 11 to 16 volt VDD supply though and are 
> available in a pdip package.
> 
> Requires also 4 i/o pins to select input.
> 
> http://www.analog.com/en/prod/0,,768_836_ADG506A%2C00.html
> 
> 
> RR
> 
> --- In basicx@basi..., "psyclopedia" <psyclopedia@> wrote:
> >
> > I've been struggling with this one for a few days, to no avail.
> > 
> > I have a bunch of analog sensors that I read with GetADC().  Each
> > sensor going to a seperate pin.  Some of the sensors have voltage
> > dividers in the circuit, some do not.  Some are counting pulses, 
> some
> > are reading resistance.  
> > 
> > Now though, I've used all of the available pins for analog 
input.  
> So
> > what I'd like to do is use some method of switching to combine 
all 
> of
> > the sensors into 1 ADC pin (or a couple) and use the other 
digital
> > pins so selet which sensor I am reading.  
> > 
> > My transistor skills seem to be lacking, now that I actually 
have to
> > do something besides turn on an LED.  Could
someone point me 
toward
> > the proper methodilogy to do some simple
switching?
> > 
> > My primary concern is that the transistor will taint the analog 
> values
> > at the pin.  
> > 
> > -Don
> >
>