Continuity Tester (Pass or Fail outcome only)

Hi, I'm looking to produce a Continuity Tester using an Arduino Uno. I have searched within the forum but a lot of the projects and the questions are never finished off by the OP. It is to test 9 pin to 9 pin cable I produce, I only need a pass or fail, I do not need to know the reason for fail. I am new to Arduino's and code and any help would be greatly appreciated. From my reading I know it will be setting some pins to high and some to low but that's about it. Thanks

All you probably need to do is connect both ends of each wire (in turn) between Arduino GND and an Arduino I/O pin with s pullup resistor. Then digitalRead() will give LOW if the connection is good and HIGH if it is not.

...R

You can look at any of the pushbutton examples. Testing a cable for continuity is just the same as checking if a pushbutton is pressed. If you want to test all 9 of your wires, you can just use 9 digital inputs.

--Doug

G40PY: I'm looking to produce a Continuity Tester using an Arduino Uno. I have searched within the forum but a lot of the projects and the questions are never finished off by the OP. It is to test 9 pin to 9 pin cable I produce, I only need a pass or fail, I do not need to know the reason for fail.

For a full test suite of - 9 cable continuity test - 9 cable discontinuity test - 9 cable short circuit test you will need 18 pins of your Arduino board.

The Arduino UNO has 20 pins, and if you don't need Serial you could use Pin-0 and Pin-1 for a red or green LED to signal "good" or "bad". But there is no extra pin available then, so you will have no "start test" button and the test will have to run all the time, signalling "bad" (red LED) all the time while no cable is connected. But that's possibly no big advantage, as the test is fast and probably running at a rate of "more than 100 full cable tests within 1 second" (full test in less than 0.01s).

1

That is what I want to do but ideally just plug the cable's into a cable that links to the Uno, I press run on a code, I get pass or fail, I then unplug the cable.

2

Ah OK, I didn't realise push button was the same thing, I'll have a read of some searches as well.

3

This sounds like what I'm looking for, instead of an LED could the code not just produce a pass or fail answer? then I would have enough pins. I am also happy to press start within the software if needed?

G40PY:
#3
This sounds like what I’m looking for, instead of an LED could the code not just produce a pass or fail answer? then I would have enough pins. I am also happy to press start within the software if needed?

You mean that the software prints “Pass” or “Fail” on the Serial monitor? That’s no problem if the board is “UNO R3”:
pin-0/1 ==> Serial connection to the PC
18 pins left for your cable tester: 9 pins for beginning and 9 pins for end of cable
==> all 20 pins on the UNO are in use.

I think you could implement one of two possible modes for a cable tester:

Automatic mode:
Software does one, ten or hundred tests per second and prints one, ten or hundred times per second a “Pass” or “Fail” line on the serial monitor.

Manual Mode:
Software does nothing until you “send” something on the serial monitor, then one test is done and one reply line is printed on the serial monitor.

BTW: Your UNO has to be of “R3” design, or you might have a problem with pin-13 (onboard LED).
Is your UNO a “UNO R3” (original or clone) or is it a different type of Atmega328 board design?

The board is a Sintron Uno R3

Jurs, the Manual Mode seems to be good to me.
I can press send, the software runs the test, ends, give me a result pas or fail in the software.
I can then disconnect the cable that is being tested, connect a new one and start again.
Is this what you mean with;

“You mean that the software prints “Pass” or “Fail” on the Serial monitor? That’s no problem if the board is “UNO R3”:
pin-0/1 ==> Serial connection to the PC
18 pins left for your cable tester: 9 pins for beginning and 9 pins for end of cable
==> all 20 pins on the UNO are in use.”

G40PY:
The board is a Sintron Uno R3

Yes, R3 design is what you need for this application (or you could not use pin-13).

Here is the code for a cable tester with nine single lines to test:

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

// pin numbers for use at begin and end of cable
const byte pinsCableBegin[]= { 2, 3, 4, 5, 6, 7, 8, 9,10 };
const byte pinsCableEnd[]  = {11,12,13,A0,A1,A2,A3,A4,A5 };
const byte NUMCABLES=sizeof(pinsCableBegin);

void setup() {
  Serial.begin(9600);
  if (sizeof(pinsCableBegin)!=sizeof(pinsCableEnd))
  {
    Serial.println("Wrong cable pin configuration!");
    Serial.println("Fix declaration of pinsCableBegin[] and pinsCableEnd[] arrays!");
    while(1); // error stop with endless loop
  }  
  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);
    pinMode(pinsCableEnd[i],INPUT_PULLUP);
  }
}


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);
    }
    // then check for continuity and OUTPUT/LOW
    digitalWrite(pinsCableBegin[i], LOW);
    if (digitalRead(pinsCableEnd[i])!=LOW)
    {
        bitSet(result,FAIL_NOTCONNECTED);
    }
    
    // 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);
      }  
    }
    // 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);
      }  
    }
    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())
  {
    DoOneTest();
    delay(20);
    while (Serial.available()) Serial.read(); // clear Serial input buffer
  }
}

Usage:

  • compile and upload sketch to UNO R3 (or compatible R3) board
  • connect all 9 pins at the begin of the cable to the pins declared in pinsCableBegin
  • connect all 9 pins at the end of the cable to the pins declared in pinsCableEnd
  • open the serial monitor and send something (at least one character)
    (CR/LF would be enough, so you can send empty line if sending line ending is enabled)

Printed result shows PASS or FAIL with each line of the cable.
If it is FAIL, an additional hint (BREAK, WRONG, SHORT) is given which might be helpfui for repair

When using non-R3 boards, the board LED pin-13 cannot be used.
But with R3 design boards you can also use pin-13 without any problem.

How long are the cables you test? If the cables are very long (dozens or hundreds of meters), the sketch may show wrong results. For cables up to a couple of meters that code should work flawlessly.

What do you think?

jurs: When using non-R3 boards, the board LED pin-13 cannot be used.

With 5 seconds of work with a soldering iron (removing the LED) or a razor blade (cutting the trace to the LED) or a screwdriver (mangling the led), you can get rid of this issue on non R3 boards...

The issue is just that on some boards (pre R3, and some clones) don't buffer the led on pin 13, so it puts a load on the pin no matter what. The newer boards buffer it with an opamp, so the load from the LED isn't seen by the chip.

DrAzzy: The newer boards buffer it with an op-amp, so the load from the LED isn't seen by the chip.

And if nothing else is connected to that pin, and the current sketch does not set it as an OUTPUT (as the blink sketch of course does) or INPUT_PULLUP, then the LED will randomly go on or off or perhaps flicker.

I think that you could reduce that to only nine pins on the Arduino. For the 'far' end of the cable construct a dummy plug or socket with leads connected to each other with diodes as below. lead lead diode 1 2 A to K 2 3 K to A 3 4 A to K 4 5 K to A 5 6 A to K 6 7 K to A 7 8 A to K 8 9 K to A

Test leads 1 and 2 for continuity (remembering the direction of the diode). Repeat for leads 2 and 3 and all the other adjacent pairs of leads, swapping the pins statuses from OUTPUT to INPUT and vice versa. Logic will usually indicate which of the tested pair is open circuit. Test all adjacent leads for shorts (again remembering the direction of the diode). Then test between all non-adjacent pairs of leads for shorts (direction not important as there will be at least 2 diodes between them). More complicated programming, but only using nine pins. The only difficulty could be in identifying the exact position of the fault(s) where two close leads are both open circuits.

7 Jurs

Thanks for that, I will try this when I am back from the office to see how it runs and come back to you to see if I have any issues. I presume this is a manual input start stop in the software? The length's are 300-500mm, so hopefully this should be OK. (thumbsup)

G40PY: I presume this is a manual input start stop in the software?

No, just a manual start. You "send" from the serial monitor, one test is done, one result displayed. No stop needed.

Every test just takes a few milliseconds. It would be easily possible to change the programming logic.

G40PY: The length's are 300-500mm, so hopefully this should be OK. (thumbsup)

Lengths up to a few meters should be fine using the internal pull-up resistors of the Atmega controller to activate testing voltage, and no external resistors are needed. Just connect the cable to the Atmega board and make sure that no AC mains power cable is crossing your test cable in a short distance during the test (which might lead to wrong FAIL results) caused by electromagnetic induction.

Jurs,

Opened sketch, put in code, verified, uploaded and then nothing happens? what am I missing?
No pass or fail is displayed in the sketch screen?

G40PY: Jurs,

Opened sketch, put in code, verified, uploaded and then nothing happens? what am I missing?

Opening the serial monitor? Setting the serial monitor to 9600 baud baudrate? Configure "line ending" as "Newline", "Carriage Return" or "both" in the serial monitor? Pressing "Send" in the serial monitor?

I don't know.

After uploading the sketch and opening the serial monitor you should see at least the greeting message which should look like:

################################################
#                CABLE TESTER                  #
################################################

Do you see that?

If not, something went wrong with your hardware.

Awesome , it works much appreciated, I can now work faster!

Beer tokens to you sir!

Hi,

I am new with Arduino and I am building also cable tester. That code in here is really interesting and I am trying to learn how it works, especially how to get that testing routine to start automatically when cable is connected? If someone could help with that it would be very nice. Thanks!

This is a very old Thread.

Post the code you are using and explain what it actually does and what you want it to do that is different.

...R

If it were me, I think I'd start a new thread and reference this one.

fin3630:
Hi,

especially how to get that testing routine to start automatically when cable is connected? If someone could help with that it would be very nice. Thanks!

Without knowing the details, you could possibly do that

Run a test routine which checks all the pairs of wires for NOTCONNECTED errors ALL THE TIME.
In csse the cable is not connected at all, then all pairs should be NOTCONNECTED.

And if at least one pair of wires does not produce the NOTCONNECTED result, then start the full test.
But even then you cannot distinguish the following cases:

  1. No cable connected at all
  2. Cable connected, gut all wire connections are broken