Mixing 3.3v and 5v analog sensors

I want to use a mix of 3.3V and 5V analog sensors on the same 5V ATMEGA1280 CPU. I see a few ways of doing this, can anyone comment on the best method?

  1. Run 3.3V to AREF through a 5K resistor. Use analogReference to switch between DEFAULT(5V) and EXTERNAL(3.3V) AREF settings. It's unclear if I can call analogReference anytime during my code. In some places it talks about damaging things.

  2. Run 3.3V to AREF through a 5K resistor. Route the 5V sensors through a voltage divider (3.4k and 6.6k) to drop the range to 0 -3.3V.

  3. Use some type of voltage shifting IC like a PCA9306D.

  4. Some better method?

Please help! :)

  1. Some better method?

Or you could just leave the A/D reference as is and accept that analog input values from the 3.3 volt sensors will occupy a 0-675 count range. A lot depends on the resolution and accuract specs of the 3.3v sensors.

Lefty

Good point, but I really would like the full resolution the ADC.

I guess another option would be to use a separate ADC chip for the 3.3V sensors.

I guess another option would be to use a separate ADC chip for the
3.3V sensors.

Very true. There are many A/D conversion chips available that use I2C, SPI or even simple serial data to communicate with. Many offer multiple channels, greater resolution, programmable gain factors, differential input modes, etc.

Lefty

Just did some searching and dedicated ADC's are all pretty pricey. I need at least 4 channels and decent conversion speed. TI has some around $30 bucks and I'd rather not add that type of cost unless I have too.

I'm hoping someone will come along here and clarify the analogReference and maybe I can switch on the fly between 3.3V and 5V.

If you use the external reference, AREF, you can not use the other reference options (bandgap and AVCC). AREF is connected directly to the ADC and would short the external reference to the other references.

You could put an external reference that is programmable or an analog switch that switches between two fixed references.

(* jcl *)


www: http://www.wiblocks.com twitter: http://twitter.com/wiblocks blog: http://luciani.org

How about a cheap DAC with an I2C interface?

The TI DAC5571 is about $2 and I could output 3.3V or 5V to the AREF pin. I wonder how noisy the output of the DAC is? Anyone see a problem with using a DAC?

I want to use a mix of 3.3V and 5V analog sensors on the same 5V ATMEGA1280 CPU

Why not reconsider the above.

With two Atmega328 mcu's, you get 2 sets of digital I/O, 2 sets of 6 ADC channels, 2 independent AREF's, 2 times serial, 2 cpu's and 2 of everything else the AtMega offers.

Power them at 3V3/5V respectively and connect them with I2C.

The DAC will work but you need to go through the accuracy numbers to verify that it meets your requirements. A big advantage to the DAC is it has a very low output impedance.

(* jcl *)

With two Atmega328 mcu’s, you get 2 sets of digital I/O, 2 sets of 6 ADC channels, 2 independent AREF’s, 2 times serial, 2 cpu’s and 2 of everything else the AtMega offers.

Power them at 3V3/5V respectively and connect them with I2C.

That might be alright but 2xATMEGA328 != 1xATMEGA1280, I’d lose
quite a few digital lines and 4 analogs. I could use a 328 and a 1280
as you suggest. Cost would be around $5 to add a 328. The big
downside is that it would also have to be programmed, not a huge
problem but another step.

The DAC will work but you need to go through the accuracy numbers to
verify that it meets your requirements. A big advantage to the DAC is it
has a very low output impedance.

The DAC is an 8bit giving 5V/255 = .0196V per step. Seems to be accurate enough. Is there something I’m overlooking?

I don’t understand why a low output impedance would be important?

[The DAC is an 8bit giving 5V/255 = .0196V per step. Seems to be accurate enough. Is there something I'm overlooking?

Yes. You are mixing accuracy and resolution. 0.0196V is the resolution not the accuracy. The gain error is +-1.25% of FSR (max). The zero error is 20mV (max). There is also a temperature drift but I don't know the operating conditions of your system.

If you can live with a apx +-1% error on the reference pin you should be OK. Those are maximum specs so you will probably be quite a bit lower.

I don't understand why a low output impedance would be important?

A low output impedance is less susceptible to noise. Any loading affects (which I do not believe the ATmega reference input has) are low.

(* jcl *)

Ah... got it. Thanks! I think I can live with less than 1% error.

I think that is how I'm going to proceed for now. It seems to be the best option in my mind. Still open to suggestions from anyone.

There may be programmable references from Linear Tech or ADI that
might be a little easier to use. Not sure. The DAC will work.

I make two boards with SPI DACs on them

http://wiblocks.luciani.org/NB1/NB1A-index.html
http://wiblocks.luciani.org/NB2/NB2AS-index.html

unfortunately they don’t wire to AREF :frowning:
Maybe I should add a jumper :wink:

(* jcl *)

Those look like nice boards, you should add a line to the AREF, seems like it would increase the versatility.

Those look like nice boards,

Thanks.

you should add a line to the AREF, seems like it would increase the versatility.

I have only seen one request ;) Probably not difficult to do.

(* jcl *)

Something simple to do might be to use a small trim pot as a voltage divider for a 3.3v reference from the board 5v. Not sure about the arduino output pins, but if when they are off they have a high impedance and not sink current, then one of these pins could be connected in parallel with the 3.3v. With the output pin "off" and at high impedance, 3.3v would be proviced to the aref pin. With the output pin "on", 5v would be provided to Aref.

You can use an op-amp circuit to amplify the 3.3V sensors. I just started learning electronics a few months ago - the op-amp is not as difficult as I first guessed.

The gain of the op-amp circuit is designed much like a voltage divider. You would need an op-amp that is "rail to rail" to make it easier. I used an MCP602

You need to supply 2.5V constant to the (-) input of the op-amp. Then connect a voltage divider across VOut and your signal in. The middle of the voltage divider goes to the (+) input of the op-amp. Check out wikipedia for the circuits.

For a related problem 0.5- 4.5V sensor into 3.3V max ADC.

I used a circuit like this to invert a .5 to 4.5 signal so it would be 4.5 to .5. Then I chopped off the top of it using a 3.6V Zener (close enough). I did this because I cared about only part of the range of the sensor but it just happened to be the wrong end.