Cable Tester (Again)

Hi,

I am creating a cable tester where one end can go to any combination at the other end. I have searched but not found a solution to this specific problem I encounter.

I am using the typical approach of a shift register

Shift in pattern - > look at each input - > Ensure I only get 1 signal on each input, assume pin to be fine. If all pins fine, assume cable to be fine.

If no signal - Broken Pin
if more than 1 signal - >shorted pin,

But I encounter this problem where say output 1 has become disconnected but also shorted to output 2.

So when i apply my pattern I see an input to 1, but this is actually coming from the short from output 2. Therefore the cable passes, but in reality it shouldn't

Here is my code


byte verify;
#define clr  0b00000000
#define pin1 0b00000001
#define pin2 0b00000010
#define pin3 0b00000100
#define pin4 0b00001000
#define pin5 0b00010000
#define pass 0b01000000
#define fail 0b10000000


//Pin connected to ST_CP of 74HC595
int latchPin = A2;
//Pin connected to SH_CP of 74HC595
int clockPin = A1;
////Pin connected to DS of 74HC595
int dataPin = A0;


void setup() {

  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);

  Serial.begin(19200);
  Serial.println("Test In Progress");

  pinMode (4, INPUT_PULLUP);
  pinMode (5, INPUT_PULLUP);
  pinMode (6, INPUT_PULLUP);
  pinMode (7, INPUT_PULLUP);
  pinMode (8, INPUT_PULLUP);
}

void loop() {
  verify = 0;

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, clr);
  digitalWrite(latchPin, HIGH);


  Serial.print("Pin1: ");
  pin1Test();

  Serial.print("Pin2: ");

  pin2Test();

  Serial.print("Pin3: ");

  pin3Test();

  Serial.print("Pin4: ");

  pin4Test();

  Serial.print("Pin5: ");

  pin5Test();

  shift(clr);


  if (verify == 5)
  {
    Serial.println("Cable passes test");
    shift(pass);
  }
  else
  {
    Serial.println ("Cable Failed");
    shift(fail);
  }


  while (1);
}

void pin1Test ()
{

  int result = 0;
  shift(pin1);

  for (int i = 4; i <= 8; i++)
  {

    if (digitalRead(i) == LOW)       //read the inputs one after the other
    {
      result++;                       //if the input is true, incrememnt the count
    }


  }

  if (result == 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Pass");
    verify ++;
  }


  if (result == 0)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Not connected/broken");
  }

  if (result > 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Shorted");
  }

  // Serial.println(verify);


}




void pin2Test ()
{

  int result = 0;
  shift(pin2);

  for (int i = 4; i <= 8; i++)
  {

    if (digitalRead(i) == LOW)       //read the inputs one after the other
    {
      result++;                       //if the input is true, incrememnt the count
    }

    // Serial.print("Result");
    //  Serial.println(result);
  }

  if (result == 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Pass");
    verify ++;
  }


  if (result == 0)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Not connected/broken");
  }

  if (result > 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Shorted");
  }


  // Serial.println(verify);

  //  while(1);
}



void pin3Test ()
{

  int result = 0;
  shift(pin3);

  for (int i = 4; i <= 8; i++)
  {

    if (digitalRead(i) == LOW)       //read the inputs one after the other
    {
      result++;                       //if the input is true, incrememnt the count
    }


  }

  if (result == 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Pass");
    verify ++;
  }


  if (result == 0)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Not connected/broken");
  }

  if (result > 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Shorted");
  }

  //  Serial.println(verify);

}


void pin4Test ()
{

  int result = 0;
  shift(pin4);

  for (int i = 4; i <= 8; i++)
  {

    if (digitalRead(i) == LOW)       //read the inputs one after the other
    {
      result++;                       //if the input is true, incrememnt the count
    }


  }

  if (result == 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Pass");
    verify ++;
  }


  if (result == 0)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Not connected/broken");
  }

  if (result > 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Shorted");
  }

  //  Serial.println(verify);

}

void pin5Test ()
{

  int result = 0;
  shift(pin5);

  for (int i = 4; i <= 8; i++)
  {

    if (digitalRead(i) == LOW)       //read the inputs one after the other
    {
      result++;                       //if the input is true, incrememnt the count
    }


  }

  if (result == 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Pass");
    verify ++;
  }


  if (result == 0)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Not connected/broken");
  }

  if (result > 1)                  //The count should = 1, less then broken circuit, if >1 then shorted
  {
    Serial.println("Fail - Shorted");
  }

  //  Serial.println(verify);

}




void shift (byte data)
{

  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, data);
  digitalWrite(latchPin, HIGH);
}


void testPins()

{





}

You seem to have a lot of code that looks very similar.

Noted thank you, this is early stages of the design. I have written the shift into a function but can see room for improvement

You can maintain a table (const array) of expected pattern at the receiver end for each sender pin. Then shift out the pattern for a pin and shift in the pattern from the other end, then compare to the table.

Thank you, this would be a solution but the cables under test are randomly wired (by design) or are you suggesting maintain a table of all possible correct patterns, and compare to them?

So, shift out 0001, check if result is 0001,0010,0100,1000 and such?

So are you saying that it does not matter which pin is connected to which, as long as every pin at one end connects to one and one only pin on the other?

That would also require that the cables always had the same number of pins, wouldn't it?

It may be impossible to detect such shorts, because then also the outputs are shorted, resulting in unknown signal level on the shorted pins and risk of damage to the output shift register.

Having built cable testers, I can see you have avoided the most troubling part. How many different CONNECTORS will you have on the cables? You need to be able to interface your tester to each and every different type of connector long before you try to examine how the cable connections have been made.

Always the same 5 pin connector with 5 wires, but always randomly wired (i.e. not pin to pin) so I cannot use a test a pattern is correct to verify.

I can test continuity i.e. consecutively shift in 00001,00010,00100,01000,10000) and verify each time that I only get 1 return line low. But I'm trying to detect the fault where the cable has detached from the pin but also shorted to another pin. So in effect i will still only get one line low per test but i'd pass the cable, despite one line not actually being connected. I hope that makes sense.

Thanks, I am using TPIC6B595 as per a suggestion an another post pulling low with input_pullup on the arduino pins, so I don't believe multiple shorts in an issue in this instance.

This is correct - the cables control lights and actually it is the random wiring of the cables that attributes to the random effects.

But at the moment my solution is
-signal on each output pin consecutively, 00001,00010 etc
-look at input pins - is only on line high
1 yes = ok
0 no = broken
2 more than 1 = short

However this cannot account for a situation where a cable has broken off of one pin but also shorted to to another pin, because we we still get that signal, albeit on a pin that has already been high in another case.


Then you are testing OLD cables, not freshly made cables.

Yes, they go to a job and we must test they are ok on return and have not been damaged

TPIC6B595 is a good choice because you can drive 100 mA or so into the cable rather than just a few mA. This will test poor connections. The input side consists of five 47 Ohm pull-up resistors connected to the cable connector, each with a 1k or so resistor (protective) to an Arduino input pin. The output side of course, is your TPIC6B595 controlled by three Arduino pins.

So the code is actually quite simple. You shift a "1" into (just) one bit of the TPIC6B595 (noting that a "1" pulls the corresponding output LOW). You read the five inputs. If more than one is LOW then you immediately have a fault. If none are low, that again is a fault.

You put the one bit that is low into a variable, for example an element in an array corresponding to the position of the bit, or you could just OR the bit into a single variable. Now you repeat the process for the other four wires.

Having tried all five, you now examine the storage variable - all five bits should be set; if not, then there is a break.

Note - your second diagram in #11 will show as a fault after having checked through all the wires at the shift register end; one input will have been missing and another would have been detected twice. If the cable fault was the other way round (left for right) it would have been detected when no input pulled low when one particular shift register output was pulled low during the individual tests.

Do not forget to clear the shift register after the test scan in order to stop drawing current, particularly if the last wire pulled low happened to be connected to many of the pull-ups. :grin:

Thanks for that. I think I see what you are saying so opposed to counting up when a low is detected, I look at each bit uniquely. That starts to make some sense so my array would show maybe [1,1,1,2,0] if I understand you correctly ? And to pass could only show [1,1,1,1,1]

That's about the size of it. Get coding! :+1:

Hey @Paul_B I tried with pull ups of 47 Ohm but consistent fails the read. Is this the value you meant to write? Works a treat with just the internal pull ups on.

That means more than 100mA at 5V! Try 470 or 1k instead.

You haven't been following the discussion, have you? :thinking:

47 Ohm is exactly what was suggested as a suitable load for a TPIC6B595 to give a suitable test current for a cable! This should pull down perfectly well to the millivolt range.

Not talking about an Arduino output pin.

It should work. You mean it still reads HIGH? What value do you read with a multimeter when you use a test sketch to write the TPIC output HIGH and connect the 47 Ohm resistor? What are the band colours on your 47 Ohm resistors? Have you measured them with the multimeter before using them?

What if multiple wires are connected and a multiple of 100mA is flowing?