Mux Shield II & I2c communication, Noob

Hello,

I have one Master (UNO) and two Slaves (UNO) with two Mux Shield II mounted on them, one is a Digital Out and the other Digital In, I want to send the Digital In data array to the master to be displayed no Idea How. I have found a few videos on YouTube and have ran them successfully, but not for what I need can anyone Help??

Quick questions before I attempt to answer your question:

Why do you need muxing? Does your project demand too much digital I/O? Exactly how are the muxes wired? Can you link to the demos you described? What exactly is your project.

We don't know your project like you do. We are not mind readers; more info = better answer, faster.

I am trying to make a wire harness tester using the Mux Shields II with 155 wires.

The code that I am using to read the IO is the example code from the Mux Shield II example library.

I attached a diagram of my project, master receives the date from the slave and eventually will be displayed to a i2c lcd.

//This example shows how to use the Mux Shield for digital inputs
#include <MuxShield.h>

//Initialize the Mux Shield
MuxShield muxShield;

void setup()
{
    //Set IO1, IO2, and IO3 as digital inputs
    muxShield.setMode(1,DIGITAL_IN_PULLUP);
    //use DIGITAL_IN in place of DIGITAL_IN_PULLUP if internal pullups are not needed
    muxShield.setMode(2,DIGITAL_IN_PULLUP);
    muxShield.setMode(3,DIGITAL_IN_PULLUP);
    
    Serial.begin(28800);
}

//Arrays to store digital values
int IO1DigitalVals[16];
int IO2DigitalVals[16];
int IO3DigitalVals[16];

void loop()
{
  for (int i=0; i<16; i++)
  {
    //Digital read on all 16 inputs on IO1, IO2, and IO3
    IO1DigitalVals[i] = muxShield.digitalReadMS(1,i);
    IO2DigitalVals[i] = muxShield.digitalReadMS(2,i);
    IO3DigitalVals[i] = muxShield.digitalReadMS(3,i);
  }
  
  //Print IO 1 values for inspection
  Serial.print("IO1 analog values: ");
  for (int i=0; i<16; i++)
  {
    Serial.print(IO1DigitalVals[i]);
    Serial.print('\t');
  }
  Serial.println();
}

canuseebg:
I am trying to make a wire harness tester using the Mux Shields II with 155 wires.

Wire harness with 155 wires? Just curious, is this for drone avionics or a car or something?

canuseebg:
I attached a diagram of my project, master receives the date from the slave and eventually will be displayed to a i2c lcd.

I can't find the diagram.

Harness test Diagram

Still no diagram.
Better approach is to use shift registers.
Send a pattern to TPIC6C595 to one end of the cable, read the pattern back on 74HC165 with input pullup resistors.
TPIC6C595 can only pull low. Open drain outputs, so no problem electrically if two are shorted.
Take one output low, read the '165s to see that only one low is received on the correct input. If on the wrong input, then some wires are crossed. If two lows are received, there is a short. If on the correct pin, then the outgoing data will agree with the incoming data.
Can do it with just one Uno using SPI interface, need just 4 IO pins. Plenty left for LCD interfacing and a start button.

here it is

No diagram. Please use Reply, then scroll below the message box and use "Attachments and other Options" to browse to your local file and Attach it.

I have tried attaching the diagram for some reason it not successful?

Here’s my suggestion.

cable_tester.jpg

What error message do you get when Attaching? Wrong file type, file too big?

I think I will go with your recommendation for the tester.

is there code already for this set up?

// write data out
outByte = 0b00000001; // 1 output low
digitalWrite(ssPin, LOW);
SPI.transfer(outByte); // output 0 goes Low
digitalWrite(ssPin, HIGH); // outputs are updated on this rising edge

// read the data in
digitalWrite (latchPin, LOW);
digitalWrite (latchPin, HIGH);
inByte = SPI.transfer(0); // clock in the sampled data
// find the 1's coming in
inByte = 0b11111111 - inByte; // in this example, 11111111 - 11111110 = 1. if 11101110 came back >00010001
if ( inByte == outByte){
Serial.println ("bytes match");
}
else {
Serial.print ('byte mismatch ");
Serial.print (outByte, BIN);
Serial,print (" vs ");
Serial.println (inByte, BIN);
}

So with 155 pins, 20 devices, do the writes and reads from an array, compare the array data byte by byte to check for errors.
Develop a smart way to walk a 1 thru the out bound data for a 155 loop.
Maybe a loop within a loop, the outer loop goes thru the 20 bytes, the inner loop goes thru the 8 bits of a register.
Or just make a large array that’s 20 bytes long by 155 rows:

byte testArray[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, // first wire
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, // 2nd wire
:
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, // 9th wire
:
 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, //
159th wire
 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, //
160th wire
};

20 bytes x 155 rows = 3100 bytes, so you probably want to store that in PROGMEM.

for (x=0; x<156; x=x+1){ // loop thr 155 rows
digitalWrite (ssPin, LOW);
for (y=0; y<20; y=y+1){ // loop thru a row
SPI.transfer (testArray((x*155)+y); // send a byte out
}
digitalWrite (ssPin, HIGH); // 20 registers get updated
// now read them back
digitalWrite (latchPin, LOW);
digitalWrite (latchPin, HIGH);
for (z=0; z<20; z=z+1){
readArray[x] = SPI.transfer(0);

}
// and compare them
for (z=0; z<20; z=+1){
if (0x11111111 - readArray[z] == testArray((x*155)+z) ){
Serial.print (z);
Serial.print ("ok");
}

}

Losing track of where I am in this little box, but I think you can get the idea. I think having a big array with a bit to check per row is a little easier to manipulate vs finding a way to walk a 1 across the row.

So the Array and the code beneath go together? and the first one is different?

Going to order the parts.