Analog IN expand

hi fellows!

building LED table and control 90 TCRT5000 sensors so I need 90 analog inputs. I bought CD74HC4067 and only now find out that I can use only ONE at the time...

So what expander should I use for this solution?

How many analog channels do you have? You can put a 4067 on each analog input.

Or can you wire S0-S3 in parallel and use the enable input to choose which 4067?

How often do you need to read each input? 10 times per second? Once per second? Once per minute? What Arduino are you using? How many times per second can its A2D converter do a conversion?

groundFungus:
How many analog channels do you have? You can put a 4067 on each analog input.

Or can you wire S0-S3 in parallel and use the enable input to choose which 4067?

I'm using arduino UNO so I have only 6 analog inputs, but I need 90.
Ok 4067 have 16 output so I need 6pcs of 4067.

4067:
SIG -> A0...A5
S0...S4 -> parallel to arduino
EN -> use different input for each 4067???
VCC -> parallel to arduino
GND - > parallel to arduino

code:
MUX74HC4067 mux1(7, 8, 9, 10, 11);
MUX74HC4067 mux2(6, 8, 9, 10, 11);
MUX74HC4067 mux3(5, 8, 9, 10, 11);
MUX74HC4067 mux4(4, 8, 9, 10, 11);
MUX74HC4067 mux5(3, 8, 9, 10, 11);
MUX74HC4067 mux6(2, 8, 9, 10, 11);

mux1.signalPin(A0, INPUT, ANALOG);
mux2.signalPin(A1, INPUT, ANALOG);
mux3.signalPin(A2, INPUT, ANALOG);
mux4.signalPin(A3, INPUT, ANALOG);
mux5.signalPin(A4, INPUT, ANALOG);
mux6.signalPin(A5, INPUT, ANALOG);

data1 = mux1.read(i1);
data2 = mux2.read(i2);
data3 = mux3.read(i3);
data4 = mux4.read(i4);
data5 = mux5.read(i5);
data6 = mux6.read(i6);

Did I understand it correctly???

PerryBebbington:
How often do you need to read each input? 10 times per second? Once per second? Once per minute? What Arduino are you using? How many times per second can its A2D converter do a conversion?

As often as posible. I'm using arduino UNO

As often as possible.

That's not helpful. You need to know how often you need to read the sensors then design a solution to match. It makes a big difference whether you need to read them once per micro second or if once per second or even once per 10 seconds is OK. Once per microsecond would need an A2D per sensor, once per second can easily be done with a single A2D and analogue multiplexers.

Ok 4067 have 16 output so I need 6pcs of 4067.

Yes that would give you 96 analogue inputs.

PerryBebbington:
That’s not helpful. You need to know how often you need to read the sensors then design a solution to match. It makes a big difference whether you need to read them once per micro second or if once per second or even once per 10 seconds is OK. Once per microsecond would need an A2D per sensor, once per second can easily be done with a single A2D and analogue multiplexers.

ok, about 10 times per second I need to read all 90 analog inputs. Sorry dont know anythikg about A2D can you give me some information?

Grumpy_Mike:
Yes that would give you 96 analogue inputs.

what about wiring is EN is correct?
4067:
SIG -> A0...A5
S0...S4 -> parallel to arduino
EN -> use different input for each 4067???
VCC -> parallel to arduino
GND - > parallel to arduino

EN -> use different input for each 4067

If that is analogue input on the Arduino that is correct.
All the channel select lines are common to all chips. So set that and read all six Arduino analogue inputs.

It should take you about just under 10mS to get round reading them all.

Don’t forget to include a 0.1uF ceramic capacitor on each chip and ground any input pins you are not using.

OK, about 10 times per second I need to read all 90 analogue inputs. Sorry don't know anything about A2D can you give me some information?

Right, there is 1 A2D converter in an Uno, so that has to be shared across all 90 inputs, which is what the multiplexer is for. The A2D takes one analogue input and converts it to digital. It does this very fast and I don't think doing 900 (90 inputs 10 times a second) per second will be a problem. You need to arrange that the 6 * 4077s scan across the 90 inputs 1 at a time, the A2D is triggered, a measurement is taken then move on to the next one.

Do you need analog inputs or are you just using these to detect or not detect an object , in which case everything is much easier with digital inputs.
Have a thought too about your software , you will have a lot of analog valves with what you propose, which will need thought on how you use them .

ammygo:
EN -> use different input for each 4067???

No.
You can set all 4067 to position one, and read the six analogue inputs.
Then set all 4067s to position two, and read the six analogue inputs.
You would only use EN if you would connect the 4067s to a single analogue input.

The Uno process almost 10,000 readings per second, well a bit less with the switching/storing overhead.
Leo..

hammy:
Do you need analog inputs or are you just using these to detect or not detect an object , in which case everything is much easier with digital inputs.
Have a thought too about your software , you will have a lot of analog valves with what you propose, which will need thought on how you use them .

I need analog inputes. I building LED table and using TCRT5000 IR sensor. Closer my hand to IR sensor brighter LED light, so I need measure distance

Wawa:
No.
You can set all 4067 to position one, and read the six analogue inputs.
Then set all 4067s to position two, and read the six analogue inputs.
You would only use EN if you would connect the 4067s to a single analogue input.

The Uno process almost 10,000 readings per second, well a bit less with the switching/storing overhead.
Leo..

ok...
SIG -> A0 and A1
all S3 -> 11
all S2 -> 10
all S1 -> 9
all S0 -> 8
EN -> --- (nowhere)
all VCC -> 5V
all GND -> GND

is that correct???

code:

#include "MUX74HC4067.h"

int a1, b1, c1;
int a2, b2, c2;

MUX74HC4067 mux(8, 9, 10, 11);

void setup()
{
  Serial.begin(9600); 
  pinMode(6, OUTPUT);
}

void loop()
{
  digitalWrite(6, HIGH);  
  delayMicroseconds(500);
  
  mux.signalPin(A0, INPUT, ANALOG);  
  a1 = mux.read(0);
  mux.signalPin(A1, INPUT, ANALOG);  
  a2 = mux.read(1);
     
  digitalWrite(6, LOW);  
  delayMicroseconds(500);
  
  mux.signalPin(A0, INPUT, ANALOG);  
  b1 = mux.read(0);
  mux.signalPin(A1, INPUT, ANALOG);
  b2 = mux.read(1); 
       
  c1 = a1 - b1;                
  c2 = a2 - b2;

  Serial.println(c1);
  Serial.println(c2);

}

For testing I use only two 4067. Did I get it right???

c1 signal affects c2 signal, but c2 signal not affects c1 signal...somethig is not good

EN -> --- (nowhere)

no, EN -> ground

ok
EN -> GND

same problema...but if I change code:
from:

MUX74HC4067 mux(8, 9, 10, 11);

to:

MUX74HC4067 mux(5, 8, 9, 10, 11);

I define EN in code as input pin 5, but connect EN to GND
now problem solved...for now.
Why I have define EN even if you don't use it?

found this picture


in this picture show how to connect 3pcs 4067. Here EN connect to different pins...

There’s an analogue multiplexer built into the Uno, so you can connect each 4067 to a different analogue input on the Uno. In the schematic you have posted all the 4067s are connected to the same input. If they each have their own input then you don’t need EN, just connect to ground, then do what Wawa suggested, select address 0, read all six inputs, then select address 1 and repeat. No need for EN.

PerryBebbington:
do what Wawa suggested, select address 0, read all six inputs, then select address 1 and repeat. No need for EN.

can you explain this?
why read six inputs (4067 have 16 inputs)?
can you show me in code how does it looks like?

why read six inputs (4067 have 16 inputs)?

Because you eventually want to have 90 inputs. This is the best way to expand up to that.

I think your big big problem is that you are using a library that is not suited to how you want to configure your system. This is such a simple thing to do you don’t need a library at all.

can you show me in code how does it looks like?

You mean do it for you?