Multi-Wire Cable Tester with UNO R3 and Port Expander MCP23017

Hey everyone,

I'm completely new to Arduino/Interfacing and I'm working on a simple cable continuity tester project.

Ultimate Goal: Create a 12-Wire Cable Continuity Tester with RGB LEDs

So far the logic is correct, but it's only for 9 wires while displaying with the serial monitor. Currently I am trying to implement a port expander (Port Expander MCP23017) using I2C. I've been looking at multiple tutorials to read and write using the Wire library, but I am stumped on actually accessing each pin of the Port Expander.

** I don't have an MCP23017 at the moment to play around with which makes it extremely difficult to understand.

Before I dive into the LED portion, I would like to know how to implement the newly added GPIO of the expander to my code.

Below is a link to the code.

Thanks in advance!!!

Update

I was recently suggested using the Adafruit-MCP23017 Arduino Library (attached). Started playing with code, but messed up the logic. To understand it better I took away half of the wires. However, I am still trying to implement additional GPIO with the expander. Currently I reserved pins 2~7 as inputs and A0~A5 as outputs on my Arduino.

Does anyone know if I am possibly not addressing the pins of bank A? (excuse my lack of terminology)

Here is a new pastebin to the cleaned up code.

Adafruit-MCP23017-Arduino-Library-master.zip (12.9 KB)

I wonder why you are making a simple project so complicated. Several years ago we duplicated a set of perhaps 20+ different cables for a customer. Originals came from a chemical processing machine and were in pretty bad shape. there were three different type of connectors involved.

I built a continuity tester out of LEDs and series resistors. Some cables had 40 wires. Each cable had all the wires tested simultaneously. Powered by a regular 12V DC power supply. In the end, the customer also bought the tester.

Never had reason to include an Arduino for just continuity testing.

Paul

That would test for continuity pin-for-pin , but not for shorts between wires or cross-wires.

For that an arduino could be handy.

Allan

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

allanhurst:
That would test for continuity pin-for-pin , but not for shorts between wires or cross-wires.

For that an arduino could be handy.

Allan

Very true. Our cables were all flat ribbon cables.

The OP wants only continuity testing, as I read it.

Paul

Paul_KD7HB:
Very true. Our cables were all flat ribbon cables.

The OP wants only continuity testing, as I read it.

Paul

Apologies for the confusion. I am using this to test for cross connections and shorts as allanhurst had mentioned. I want to be able to display status of each wire in my cable in a Pass/Fail scenario with RGB LEDs (green for pass and red for fail).

If your arduino were connected to a pc you could use the serial monitor to give a detailed display of all faults found.

Better than led's - it tells you where to look to find the fault.

Of course, not all cables are wired 1:1 - eg old RS232 using 25-way 'D' connectors. (ghastly system).

An arduino could measure and remember the connections of a known 'good' cable, and compare subsequent cables to be tested against that template.

Allan

Hey everyone, sorry for the delay. Below is my current code. I've implemented an RGB LED to display my status. I had trouble implementing the green LED logically. And I still dont have the port expanders to do what I originally wanted to do.

#include "Wire.h"
#include "Adafruit_MCP23017.h"

enum {PASS, FAIL_NOTCONNECTED, FAIL_WRONGCONNECTED, FAIL_SHORTENED };

// pin numbers for use at begin and end of cable
const int redLED = 9;		//bad status
const int greenLED = 10;	//good status
const int blueLED = 11;		//standby status
const int m1a0 = A0;

const byte pinsCableBegin[]= { 2, 3, 4, 5, 6, 7};//, 8, 9, 10, 11, 12, 13
const byte pinsCableEnd[]  = {A0,A1,A2,A3,A4,A5};//,m1a0,A1, A2, A3, A4, A5, 21, 22, 23, 24,25,26};

const byte NUMCABLES=sizeof(pinsCableBegin);  //Stores quantity within array

Adafruit_MCP23017 mcp;
//Adafruit_MCP23017 mcp1;
//Adafruit_MCP23017 mcp2;

void setup() {
	
  Serial.begin(9600);
  
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(blueLED, OUTPUT);
  
  mcp.begin();
  Wire.begin();
  Wire.beginTransmission(0x20);
  Wire.write(0x00);	//GPIOA
  Wire.write(0x00); //Sets all of bank A as outputs
  
  
  if (sizeof(pinsCableBegin)!=sizeof(pinsCableEnd))
  {
    Serial.println("Pin configuration Error.");
    Serial.println("Fix declaration of pinsCableBegin[] and pinsCableEnd[] arrays!");
    while(1); // error stop with endless loop
  }
  //standbyStatus();
  Serial.println();
  Serial.println("################################################");
  Serial.println("#                CABLE TESTER                  #");
  Serial.println("################################################");
  Serial.println();
}

void allPinsInputHigh()
{ // set all pins to INPUT_PULLUP in a for-loop
  for (byte i=0;i<NUMCABLES;i++)
  {
    pinMode(pinsCableBegin[i],INPUT_PULLUP); //enables internal 20k pullup resistors
    pinMode(pinsCableEnd[i],INPUT_PULLUP);
    //mcp.pinMode(pinsCableEnd[i], INPUT); //
    //mcp.pullUp(pinsCableEnd[i], HIGH); //
  }
}


void DoOneTest()
{
  byte result;
  Serial.println();
  Serial.println("### TEST ###");
  for (byte i=0;i<NUMCABLES;i++) // test each pin 
  {
    result= PASS; // initially there is no error found, assume PASS
    allPinsInputHigh();

    // first test is for continuity and OUTPUT/HIGH
    pinMode(pinsCableBegin[i], OUTPUT);
    if (digitalRead(pinsCableEnd[i])!=HIGH)
    {
        bitSet(result,FAIL_NOTCONNECTED);
        badStatus();
    }  
    
    // then check for continuity and OUTPUT/LOW
    digitalWrite(pinsCableBegin[i], LOW);
    if (digitalRead(pinsCableEnd[i])!=LOW)
    {
        bitSet(result,FAIL_NOTCONNECTED);
        badStatus();
    }
    //goodStatus();
    // next test: check for wrong connections to other pins
    for (byte j=0;j<NUMCABLES;j++)
    {
      if (j!=i && digitalRead(pinsCableEnd[j])==LOW)
      {
        bitSet(result, FAIL_WRONGCONNECTED);
        badStatus();
      }  
    }
    
        // final test for short circuit against other pins
    for (byte j=0;j<NUMCABLES;j++)
    {
      if (j!=i && digitalRead(pinsCableBegin[j])==LOW)
      {
        bitSet(result, FAIL_SHORTENED);
        badStatus();
      }  
    }

    Serial.print("Line ");
    Serial.print(i+1);

    if (result== PASS) Serial.print(" PASS");
    else badStatus();//Serial.print(" FAIL");
    if (bitRead(result,FAIL_NOTCONNECTED)) //badStatus();
    if (bitRead(result,FAIL_NOTCONNECTED)) Serial.print(" FAIL BREAK");
    if (bitRead(result,FAIL_WRONGCONNECTED)) badStatus();
    if (bitRead(result,FAIL_WRONGCONNECTED)) Serial.print(" FAIL WRONG");
    

    //if  (bitRead(result,FAIL_SHORTENED)) Serial.print(" SHORT");
    Serial.println();
  }
  Serial.println("Test Complete.");
  Serial.println();
}

void standbyStatus()
{
	digitalWrite(redLED, LOW);
	digitalWrite(greenLED, LOW);
	digitalWrite(blueLED, HIGH);
	//delay(1000);
	//digitalWrite(redLED, LOW);
	//digitalWrite(greenLED, LOW);
	//digitalWrite(blueLED, LOW);
	//delay(100);
}

void badStatus()
{
	digitalWrite(redLED, HIGH);
	digitalWrite(greenLED, LOW);
	digitalWrite(blueLED, LOW);
}

void goodStatus()
{
	digitalWrite(redLED, LOW);
	digitalWrite(greenLED, HIGH);
	digitalWrite(blueLED, LOW);
}


void loop() 
{
	standbyStatus();
	//showSpectrum();
	if (Serial.available())
	{
		//standbyStatus();
		DoOneTest();
		//delay(3000);
    
    while (Serial.available()) Serial.read(); // clear Serial input buffer
    }
  
}

Hey, Were you able to finish your project?