cable test program help

hello guys i need advice. i am trying to make a cable tester with a arduino due to test custom cables so i need to test each wire individually and see where it pins out too. and if the pin out is wrong to print to lcd that test failed and what pins are wrong on the cable so the cable can be repaired.

but i dont know where to start. can i just blink each wire one at a time? is there a better way? how can i set what pins i need to be connected?

i'm new to programming arduino's

tyler_k:
hello guys i need advice.
i am trying to make a cable tester with a arduino due to test custom cables
so i need to test each wire individually and see where it pins out too. and if the pin out is wrong to print to lcd that test failed and what pins are wrong on the cable so the cable can be repaired.

but i dont know where to start. can i just blink each wire one at a time? is there a better way? how can i set what pins i need to be connected?

i’m new to programming arduino’s

You will need two digital pins per wire to do the test.

Simply connect one end of the cable to “outputs” and the other end to “inputs”, then sequentially turn on each output and check that:

(a) You read the proper wire on the input
(b) You DO NOT read anything on any other input

There are other ways to do this which would involve a smaller number of digital pins, but above is the simplest way… especially if your cables don’t have too many wires.

well down side is i have to make a few different tests ranging from 9 pin to 25 pin cables and im not vary well versed in programming these so i can see what the examples do and how they work but idk what functions to use for this loop statement.

tyler_k: hello guys i need advice. i am trying to make a cable tester with a arduino due to test custom cables so i need to test each wire individually and see where it pins out too. and if the pin out is wrong to print to lcd that test failed and what pins are wrong on the cable so the cable can be repaired.

Looking at this, do you you want to simply check that each wire has continuity or (as I read it) you are concerned that instead of pin "A" connecting to the corresponding pin "A" it may in fact have been connected to pin "B"? If this is the case then it is an interesting piece of code to play with.

Why are you double posting? This waists our time and is quite rude.

.

Kiwi_Bloke:
Looking at this, do you you want to simply check that each wire has continuity or (as I read it) you are concerned that instead of pin “A” connecting to the corresponding pin “A” it may in fact have been connected to pin “B”? If this is the case then it is an interesting piece of code to play with.

well i need it to do both check for continuity and make sure the wires in the right spot but idk how to write that iv been messing with a array set up but i seem to be failing at that but this is what i have and i have something messed up becouse it will not print back to the computer

 int j = 2;  // ENTER NUMBER OF CONNECTIONS
  int CABLE_A[] = {4,3};  //  ENTER CABLE VALUES FOR CONNECTION A
  int CABLE_B[] = {6,5};  //  ENTER CABLE VALUES FOR CONNECTION B

  int i;  // input counting variable
  int k;  // output counting variable
  
  int out_pin;  // holding variable
  int pin_status;  // holding variable
  

void setup() 
{

  Serial.begin(9600);
  Serial.print("starting")
  ;for(i = 0; i < j; i = i++)
  { 
    pinMode(CABLE_A[i], INPUT);
    }
  
  ;for(k = 0; k < j; k = k++)
  {
    out_pin = k + 25;
    pinMode(CABLE_B[out_pin], OUTPUT);
  }
  
}

void loop() 
{
  //k = 0;
  
  for(i = 0; i < j; i = i++)
    {
      digitalWrite(CABLE_A[i],HIGH);
      delay(50);
      
      out_pin = i + 25;
      pin_status = digitalRead(CABLE_B[out_pin]);
      
        if (pin_status == HIGH)
        {
          Serial.print("PASS");
          Serial.print("/t");
          Serial.print("CABLE_A pin ");
          Serial.print(CABLE_A[i]);
          Serial.print(", to CABLE_B pin ");
          Serial.print(CABLE_B[i]);
          Serial.print("/b");
        }
        
        else
        {
          Serial.print("FAIL");
          Serial.print("/t");
          Serial.print("CABLE_A pin ");
          Serial.print(CABLE_A[i]);
          Serial.print(", to CABLE_B pin ");
          Serial.print(CABLE_B[i]);
          Serial.print("/b");
        }
      
      digitalWrite(CABLE_A[i],LOW);
      delay(50);
      
    }}

LarryD:
Why are you double posting?
This waists our time and is quite rude.

i came here for help not to be ignored and pushed off just becouse i dont know anything. iv spent the last 2 days on google with unyielding results thats why im here the closest thing to this i found was to check for a short in the cable as some one posted on my other post that i already read threw and dose not help[/code]

to larryD i came here for help not to be ignored and pushed off just becouse i dont know anything. iv spent the last 2 days on google with unyielding results thats why im here the closest thing to this i found was to check for a short in the cable as some one posted on my other post that i already read threw and dose not help

You should read: “How to use this forum”.
http://forum.arduino.cc/index.php?topic=149014.0

Here is a simple 1 to 1 tester that might be of interest:

2016-02-04_21-35-38.jpg
.

As I mentioned in your other post:

Maybe use the search feature on this site. There are other people who have done this and asked for help. here for example Here .

tyler_k: well down side is i have to make a few different tests ranging from 9 pin to 25 pin cables and im not vary well versed in programming these so i can see what the examples do and how they work but idk what functions to use for this loop statement.

Are the cables wired as a 1 to 1 connection so pin 1 to pin 1, pin 2 to pin 2 etc or do some wires cross?

The Due has 54 digital pins so you can just about wire all the pins (both ends) on a 25 cable. But you will maybe need extra pins for switches to select the cable type and maybe drive a display of some sort. If it's going to be connected to a PC all the time then the settings for cable selection and displaying the results can be done over the USB. Code wise you could use 2 nested for/next loops. The outer loop setting each output pin 1-25 to output and the inner loop reading the 1-25 input pins to see where it gets a signal and printing the matches. To overcome the problem of floating inputs you could maybe turn on all the input pins pullup resistors and then the output pins would try pulling to ground. Or just use external pull downs on the input pins.

they are all cross over cables and i know basically nothing on how to program these things so what would the nested for/next loop look like? sorry to ask but most of the examples i can find don't really match what i'm trying to do so i feel i'm getting more lost than i am coming closer to a answer

Something like this…

uint8_t outPins[] = {2, 3, 4, 5, 6};              // Output pins
uint8_t inpPins[] = {7, 8, 9,10,11};              // Input pins

void setup(){
  Serial.begin(115200);
  for (uint8_t i = 0; i < sizeof(outPins); i++){  // Setup output pins
    pinMode(outPins[i],OUTPUT);
    digitalWrite(i,LOW);
  }
  for (uint8_t i = 0; i < sizeof(inpPins); i++){  // Setup input pins
    pinMode(inpPins[i],INPUT);
  }
  Serial.println("Begin...");
  
  for (uint8_t o = 0;  o < sizeof(outPins); o++){ // Loop though output pins
    Serial.print("Output Pin \t");
    Serial.print(o);
    Serial.print("\t");
    digitalWrite(o,HIGH);                         // Set pin high
    for (uint8_t i = 0; i < sizeof(inpPins); i++){// Scan input pins
      if (digitalRead(inpPins[i]) == HIGH){       // If pin is high must be connected to output
        Serial.print(i);
        Serial.print(",");
      }
    }
    digitalWrite(o,LOW);                          // Set output back to low
    Serial.println();                             // New line ready for next pin
  }
  Serial.println("End.");
}

void loop(){
}

As you have crossover cables then you would need to add a bit more code to check the correct input is going to the correct output. At it’s simplest this would be ordering the inpPin/outPin arrays so pins correspond 1:1 and if any other pins connect the it’s a fail.

ok so with what you have written above this would report back what pins are going where? im kinda figuring some of this out. and this might be out side the bounds but for the circuit i would want to use a resistor right and not just wire right to the connectors?

tyler_k:
ok so with what you have written above this would report back what pins are going where? im kinda figuring some of this out. and this might be out side the bounds but for the circuit i would want to use a resistor right and not just wire right to the connectors?

No real need for resistors as the input pins will only draw what current is needed to trigger there logic but for safety you could put something like 1K resistors on the output pins to limit current just in case a cable is wired really badly causing excess current draw.
Code is untested but I have added the pass/fail code.

sketch_jan12a_CableTest.ino (1.49 KB)

thank you riva! you have been a big help! I got a book on c programming today. iv starting to get a better under standing of your loop and array functions but one thing i noticed is that when the program runs it has a big bug it will pass a cable if its one wire even if no wires are plugged in and if there are 2 wires that i have been using to trying debug no matter if wires are connected or not i get this back

Begin... Output Pin 0 1 Output Pin 1 0 Failed End.

yet both wires are wear there supposed to be. then i tried switching the wires around and got the same response back and it responds the same with no wires attached. been looking in the code and cant figure it out

Sorry for that, have not been near hardware to test the code but will hopefully have something Friday.
Attached is another version that should hopefully overcome this glaring error.

If you can use consecutive incrementing pin numbers for the output and input pins range of the Due then the arrays could then be used to hold the pins numbers of the cable being tested or for the use of more memory you could have a second array for the outPins/inpPins that hold the true cable pin numbers.

[5,6,7,8,9,10] = Due input pin numbers and another array [1,3,2,5,4,6] = cable pin numbers.

EDIT: I also think you will need to put pulldown resistors on all the input pins to prevent false positives.

sketch_jan13a_CableTest.ino (2.57 KB)

well now im really stuck starting to think this due might be fried but idk. both your program and one i wrote both are geting the same error and failing cables no matter what.

  int j = 2; 
  int CABLE_A[] = {2, 4}; 
  int CABLE_B[] = {8, 9}; 

  int i;
  int k=0;
  
  int out_pin; 
  int pin_status;  
  

void setup() 
{

  Serial.begin(115200);
  Serial.println("starting.....");
  for(i = 0; i < j; i++)
  { 
    pinMode(CABLE_A[i], OUTPUT);
    }
  
  for(i = 0; i < j; i++)
  {
    out_pin = i;
    pinMode(CABLE_B[out_pin], INPUT);
  }

  Serial.println("running test loop... ");
  delay(500);

  for(i = 0; i < j; i++)
    {
     
      digitalWrite(CABLE_A[i],HIGH);
      
      out_pin = i + 25;
      pin_status = digitalRead(CABLE_B[out_pin]);
      
        if (pin_status == HIGH)
        {
          Serial.println(" PASS");
          Serial.print("\t");
          Serial.print("CABLE_A pin ");
          Serial.print(CABLE_A[i]);
          Serial.print(", to CABLE_B pin ");
          Serial.println(CABLE_B[i]);
        }
        
        else
        {
          Serial.println (" FAIL");
          Serial.print("\t");
          Serial.print("CABLE_A pin ");
          Serial.print(CABLE_A[i]);
          Serial.print(", to CABLE_B pin ");
          Serial.println(CABLE_B[i]);
         
        }
      
      digitalWrite(CABLE_A[i],LOW);
     
 
      }
      
      if(i=j)
      {
        i=0;        
      }
}


void loop(){
  
}

tyler_k:
well now im really stuck starting to think this due might be fried but idk. both your program and one i wrote both are geting the same error and failing cables no matter what.

you sure go through a lot of machinations to iterate through those two tests… Plus, you will rarely need a global variable to iterate through a for loop.

you are testing two cables for continuity. So, try like this (compiles but untested, and way more simple) version:

int cableA[] = {2, 4};
int cableB[] = {8, 9};


void setup()
{

  Serial.begin(115200);
  Serial.println("starting.....");
  for (int i = 0; i < sizeof(cableA)/sizeof(cableA[0]); i++)
  {
    pinMode(cableA[i], OUTPUT);
    pinMode(cableB[i], INPUT);
  }

  Serial.println("running test loop... ");
  delay(500);

  for (int i = 0; i < sizeof(cableA)/sizeof(cableA[0]); i++)
  {
    digitalWrite(cableA[i], HIGH);
    delay(5);
    int pin_status = digitalRead(cableB[i]);
    if (pin_status == HIGH)
    {
      Serial.println(" PASS");
      Serial.print("\t");
      Serial.print("CABLE_A pin ");
      Serial.print(cableA[i]);
      Serial.print(", to cableB pin ");
      Serial.println(cableB[i]);
    }
    else
    {
      Serial.println (" FAIL");
      Serial.print("\t");
      Serial.print("cableA pin ");
      Serial.print(cableA[i]);
      Serial.print(", to cableB pin ");
      Serial.println(cableB[i]);
    }
    digitalWrite(cableA[i], LOW);
    delay(5);
  }
}

void loop() 
{

}
     out_pin = i + 25;

Now think carefully about which pin

pin_status = digitalRead(CABLE_B[out_pin]);

will read.

How many pin numbers are in the array ?

ok i commented out the out_pin and just used i and it will now just pass all wires even when nothing is connected and sorry bulldog that program isn't vary good at explaining cableA and cableB are 2 sides of one cable im trying to test custom cross over cables to see if there wired correctly. with a quick test on the code you showed now its pass/failing correct connections

tyler_k: ok i commented out the out_pin and just used i and it will now just pass all wires even when nothing is connected and sorry bulldog that program isn't vary good at explaining cableA and cableB are 2 sides of one cable im trying to test custom cross over cables to see if there wired correctly. with a quick test on the code you showed now its pass/failing correct connections

Done same task long time ago and not just simple A to B connection, but few "crossovers" in-between.

If you know the concept of arrays why not back "down" and just test pin x connected to pin y? To test your code concept just reduce the for loops to just one iteration.

Than take a look at modes INPUT and INPUT_PULLUP, you will find out that "open wire " = undefined INPUT. And in general - sending HIGH (DC) to very very long cable is also not very good idea. You are looking just for continuity, not testing cable as a transmission media, right?

And one more suggestion - Serial is nice, but LED 13 can be a useful indicator as pass / fail.

KISS