Complex Continuity Tester

Hi, I am currently working on a continuity tester project for a set of 10 different cables.

I have looked around on other threads and have based my code of: Continuity Tester (Pass or Fail outcome only)
so it works in a very similar manner.

I am having a slight Issue in that some of my cables have common connections at each end so it isn't a straightforward end to end harness. (please see below schematic)

For example, when I run my test to compare the 2 arrays of "PinsCableBegin" and "PinsCableEnd", it flags the (DAC19 shell to DAC20 shell) connection as shorting to pin 5 of DAC20 and flags the connection of (DAC19 shell to Dac20 pin 5) as shorting through DAC20 shell.

How can I write this into my array/ modify my code so it avoids flagging intended common connections?

#include <MCP23017.h>

MCP23017 mcp[] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27};
#define FISRT_MCP_PIN 100


// Cable Tester by "jurs" for Arduino forum
enum {PASS, FAIL_NOTCONNECTED, FAIL_WRONGCONNECTED, FAIL_SHORTENED };


const byte Cable715Begin[] = { 207, 208, 209, 210, 211, 176};   //DAC 19 (1=207) (2=208) (3=209) (4 =210) (DAC19shell=211) (176=DAC20pin5)

const byte Cable715End[]  =  { 174, 172, 173, 175, 176, 177}; //DAC 20 (1=172) (2=173) (3=174) (4 =175) (5=176) (DAC20shell=177)

const byte NUM715CABLES = sizeof(Cable715Begin);
...

Please post your full sketch

I should briefly mention that this test is using MCP23017-E/SP chips to measure signals hence why the pin numbers are in the range of 100-228 in my script.

#include <MCP23017.h>

MCP23017 mcp[] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27};
#define FISRT_MCP_PIN 100


// Cable Tester by "jurs" for Arduino forum
enum {PASS, FAIL_NOTCONNECTED, FAIL_WRONGCONNECTED, FAIL_SHORTENED };


const byte Cable715Begin[] = { 207, 208, 209, 210, 211, 176};   //DAC 19 (1=207) (2=208) (3=209) (4 =210) (DAC19shell=211) (176=DAC20pin5)

const byte Cable715End[]  =  { 174, 172, 173, 175, 176, 177}; //DAC 20 (1=172) (2=173) (3=174) (4 =175) (5=176) (DAC20shell=177)

const byte NUM715CABLES = sizeof(Cable715Begin);



void setup() {
  Serial.begin(9600);

  uint8_t MCP23017_count = sizeof(mcp) / sizeof(* mcp);
  // Serial.print(MCP23017_count);
  // Serial.println(" MCP23017 declared");
  for (size_t mcpIndex = 0; mcpIndex < MCP23017_count; mcpIndex++)
  {
    mcp[mcpIndex].init();
  }


}

void myPinMode(uint8_t pinNumber, uint8_t pinModeVal)
{
  if (pinNumber < FISRT_MCP_PIN)
  {
    pinMode(pinNumber, pinModeVal);
  }
  else
  {
    mcp[(pinNumber - FISRT_MCP_PIN) / 16].pinMode((pinNumber - FISRT_MCP_PIN) % 16, pinModeVal, false);
  }
}

void myDigitalWrite(uint8_t pinNumber, uint8_t pinState)
{
  if (pinNumber < FISRT_MCP_PIN)
  {
    digitalWrite(pinNumber, pinState);
  }
  else
  {
    mcp[(pinNumber - FISRT_MCP_PIN) / 16].digitalWrite((pinNumber - FISRT_MCP_PIN) % 16, pinState);
  }
}

int8_t myDigitalRead(uint8_t pinNumber)
{
  if (pinNumber < FISRT_MCP_PIN)
  {
    return digitalRead(pinNumber);
  }
  else
  {
    return mcp[(pinNumber - FISRT_MCP_PIN) / 16].digitalRead((pinNumber - FISRT_MCP_PIN) % 16);
  }
}

void allPinsInputHigh715()
{ // set all pins to INPUT_PULLUP in a for-loop
  for (byte i=0;i<NUM715CABLES;i++)
  {
    pinMode(Cable715Begin[i],INPUT_PULLUP);
    pinMode(Cable715End[i],INPUT_PULLUP);
  }
}

void Do715Test()
{
  byte result;

  Serial.println();
  Serial.println("### TEST ###");
  for (byte i=0;i<NUM715CABLES;i++) // test each pin 
  {
    result= PASS; // initially there is no error found, assume PASS
    allPinsInputHigh715();
    // first test is for logic high continuity so OUTPUT/HIGH
    pinMode(Cable715Begin[i], OUTPUT);
    if (digitalRead(Cable715End[i])!=HIGH)
    {
        bitSet(result,FAIL_NOTCONNECTED);
    }
    // then check for logic low continuity so OUTPUT/LOW
    digitalWrite(Cable715Begin[i], LOW);
    if (digitalRead(Cable715End[i])!=LOW)
    {
        bitSet(result,FAIL_NOTCONNECTED);
    }
    
    // next test: check for wrong connections to other pins
    for (byte j=0;j<NUM715CABLES;j++)
    {
      if (j!=i && digitalRead(Cable715End[j])==LOW)
      {
        bitSet(result, FAIL_WRONGCONNECTED);
      }  
    }
    // final test for short circuit against other pins
    for (byte j=0;j<NUM715CABLES;j++)
    {
      if (j!=i && digitalRead(Cable715Begin[j])==LOW)
      {
        bitSet(result, FAIL_SHORTENED);
      }  
    }
    Serial.print("Line ");
    Serial.print(i+1);


    if (result== PASS) Serial.print(" PASS");
    else Serial.print(" FAIL");

    
    if (bitRead(result,FAIL_NOTCONNECTED)) Serial.print(" BREAK");
    if (bitRead(result,FAIL_WRONGCONNECTED)) Serial.print(" WRONG");
    if  (bitRead(result,FAIL_SHORTENED)) Serial.print(" SHORT");
    Serial.println();
  }
  Serial.println("Test finished.");
  Serial.println();
}


void loop() {
  if (Serial.available())
  {
    Do715Test();
    delay(20);
    while (Serial.available()) Serial.read(); // clear Serial input buffer
  }
}

A generalized solution would be to have, as data, some kind of list of things you don't want it to care about.

When it finds something it might care about and report, it just checks that list to see if should bother.

You could at some point automate the creation of the list. Place a known good cable in the test circumstances and hit the training button, which will find all the "faults" and then never say anything about them when you swap in the cable to be tested.

a7

I worked for a cable assembly company once and they had "universal" cable testers (with custom connector/adapters for each different cable/harness).

I don't know exactly how they worked but they'd give a code or "signature". I assume that's something like a checksum where you "write" a series of patterns at one end and read them at the other end. It might have been simply counting in binary and summing the results at the other end to get a checksum but I'm not sure if that's a valid test... A criss-crossed wire might give the same-correct sum... I haven't thought it through...

Do you know what a "walking one's" (or "walking zero's" test) is? That's where you write one bit at a time (01, 02, 04, 08, etc.) and normally, you want to read-back what you wrote. If you don't have straight-through wiring you'd need to adjust the results but as long as you know what happens with a good cable it should be easy to know the pass/fail results.

If it fails, it takes some "diagnosis" to determine what the problem is. (When I used those commercial cable testers, I don't think it reported the exact open or short failure.)

Where I work now we use walking-one and walking-zero tests to check I/O ports. When it fails we can do a manual test, and check with a 'scope etc., to diagnose the problem. For example, if I write a 1 and I read-back a 3, then two lines are shorted or there might be a bit that's stuck high, etc. Or I can write a zero and that will tell me if a bit is stuck high, and I can write FF (hex) to tell if a bit is stuck low. (Our test actually works in hex because it's easier to convert to binary.)

...Of course, when there's a possibility of a short you can only have one output driving/writing at a time. The other pins need to be configured as inputs with pull-ups or pull-downs.

And if there is a possibility of a short to ground you need an inline current-limiting resistor.

1 Like