0

I need the Arduino to read about 100 analog inputs. Is this even doable? If not what is the maximum analog inputs I can read into the Arduino (The maximum non trivially would be to use the analog pins that the board already provides).

But can I expand those out? Thanks!!

  • You know that to scan 100 inputs you will take a quite long time, don't you? Time means something around 10-20 ms for all the acquisition, but anyway you'll get a low sample rate – frarugi87 Mar 7 '16 at 21:24
  • Could you tell use what you need it for? 100 analog inputs seems excessive. Having e.g. 100 sensors would probably also lead to other issues like power. There might be an easier way of accomplishing what you want without 100 analog input. – Gerben Mar 8 '16 at 14:30
  • Reviving an old thread and violating etiquette, but I am looking for solutions as well and would be interested in seeing Frank Mcculling's code (if he's still around). – Monty Nov 13 at 15:48
  • Use a bank of 8-channel ADCs with SPI interface. Sample times can be much faster than the internal ADC. ww1.microchip.com/downloads/en/DeviceDoc/21298e.pdf with 2 MHz clock, and 24 clocks to read and reply, a conversion can be done in 12 uS. 100 inputs can be done in just a few ms total then if you have good loop code to cycle thru 8 inputs on 13 chips. – CrossRoads Nov 13 at 18:58
6

There are two methods of doing what you want:

  1. Add more ADC channels
  2. Multiplex the existing ADC channels

SPI or I2C ADC chips are readily available in a range of resolutions, sampling speeds and number of channels. They are fairly simple to add to any Arduino.

For instance the MCP3208 will give 8 channels of 12-bit resolution on SPI, which means 3 pins (MOSI/MISO/SCK) + 1 per chip (SS). So 1 chip would be 4 pins, 2 chips 5 pins, 3 chips 6 pins, etc.

Adding lots of chips to the SPI bus though can itself be troublesome with the increased capacitance of all those inputs meaning you have to reduce your communication speed somewhat or add extra buffering to drive the bus with more current.

I2C chips can be harder to have lots of them since there are only a limited number of addresses on an I2C bus - plus on many Arduinos the I2C is also two of the analog pins, which you may not want to sacrifice.

The second option involves using analog multiplexers (eg the 4051) to switch different sources in to the existing analog inputs.

A third option which you probably haven't considered is to have multiple arduinos (or other low-cost microcontrollers) each doing some of the sampling and then implementing some kind of communication method between them (or to a single master). This has the added advantage that it's then possible to sample multiple channels at once (one per microcontroller) speeding up your operation somewhat.

6

Expanding on part of Majenko's answer, you can use an analog multiplexer like the 74HC4051 to turn one analog port into 8.

Analog multiplexer

Its cousin, the 74HC4067, will multiplex 16 ports. Now with 6 analog inputs on the Arduino Uno, you could have 6 x 16 inputs = 96. The A/B/C controls signals could be paralleled up.

This would let you handle 96 inputs with only 6 extra chips, and pretty simple code. I have code examples on my page about 74HC4051 multiplexer / demultiplexer.

For 8 inputs the code is:

// Example of using the 74HC4051 multiplexer/demultiplexer

// Author: Nick Gammon
// Date:   14 March 2013

const byte sensor = A0;  // where the multiplexer in/out port is connected

// the multiplexer address select lines (A/B/C)
const byte addressA = 6; // low-order bit
const byte addressB = 5;
const byte addressC = 4; // high-order bit

void setup ()
  {
  Serial.begin (115200);
  Serial.println ("Starting multiplexer test ...");
  pinMode (addressA, OUTPUT); 
  pinMode (addressB, OUTPUT); 
  pinMode (addressC, OUTPUT); 
  }  // end of setup

int readSensor (const byte which)
  {
  // select correct MUX channel
  digitalWrite (addressA, (which & 1) ? HIGH : LOW);  // low-order bit
  digitalWrite (addressB, (which & 2) ? HIGH : LOW);
  digitalWrite (addressC, (which & 4) ? HIGH : LOW);  // high-order bit
  // now read the sensor
  return analogRead (sensor);
  }  // end of readSensor

void loop ()
  {
  // show all 8 sensor readings
  for (byte i = 0; i < 7; i++)
    {
    Serial.print ("Sensor ");
    Serial.print (i);
    Serial.print (" reads: ");
    Serial.println (readSensor (i));
    }
  delay (1000);
  }  // end of loop
0

I have been exactly working with the same Issue. I need a program that reads 100 Thermistors...Why? well, some times you need it.

I kinda finished that already.

I tried the 74HC4051 multiplexer / demultiplexer. But, for some reason I didn't get the desired result.

First thing you will find...POWER, you will need an external power supply, in my case I just made a voltage divider and connected the thermistor to that power, then just use the Analog port for reading...

I use I2C protocol, 8 arduino Mega 7 slaves and One master. and since send send Integer, float, and blah, blah was kinda not helping I just made it for It can send the Analog reading over I2C and the master makes all the desired conversion.

If you still are interested, I can send you the source code for master and slaves. With this template you can connect up to 50 arduinos and the master will look for every arduino connected in the network and ask for data.

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.