Cable tester, unsure of pinmode setting

Hello, I am making a cable tester using the arduino mega. the cable is only around 1m but it has 58 pins. this meant that regular testing possibilities like attaching beginning pin and end pin of the cable to separate pins on the arduino board was not feasible as i would need 116 pins that way. the cable tester will test continuity of each pin and if there are any shorts between pins.

after some research i found a way. If i create a dummy plug with diodes for one of the cable then i could connect only one end of the cable to the arduino and use only 58 pins. The dummy plug is connected in the following way:

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
etc...

I have an uncertainty when trying to program this cable tester. If for example I set pin 3 as pinMode(ouput) then pin 2 and 4 should be set as pinMode(input) or as pinMode(input_pullup)?

The reason i have this issue is that in a previous post (Continuity Tester (Pass or Fail outcome only) - Project Guidance - Arduino Forum #7) someone wrote some code for a cable tester and the pins were set as pinMode(input_pullup) but if i understand correctly the way input_pullup mode works that wouldn't test that pin 2 and 4 at all.

Below i attached my code so far. I am aware that pin 1 will have a different code as it is asymmetrical compared to the other odd pins but i just wanted to keep it simple for now i can just add some if statements later.

enum {PASS, FAIL_NOTCONNECTED, FAIL_WRONGCONNECTED, FAIL_SHORTENED };

//setting all pin numbers to cable pins
const byte pins[]= {1, 2, 3, 4, 5, 6, 7, 8,9 ,10};
const byte NUMCABLES=sizeof(pins);

void setup() {
  Serial.begin(9600);  
  Serial.println("################################################");
  Serial.println("#                CABLE TESTER                  #");
  Serial.println("################################################");
}

void allPinsInputHigh()
{ // set all pins to INPUT_PULLUP in a for-loop
  for (byte i=1;i<NUMCABLES;i++)
  {
    pinMode(pins[i],INPUT_PULLUP);
  }
}


void DoOneTest()
{
  byte result;
  Serial.println();
  Serial.println("### TEST ###");
  for (byte i=1;i<NUMCABLES;i++) // test each pin
  {
    result= PASS; // initially there is no error found, assume PASS
    allPinsInputHigh();
    
    
    if(i&0x01)
    {
      // first test is for continuity and OUTPUT/HIGH for odd pins
      pinMode(pins[i], OUTPUT);
      if (digitalRead(pins[i-1])!=HIGH)
      {
          bitSet(result,FAIL_NOTCONNECTED);
      }
      if (digitalRead(pins[i+1])!=HIGH)
      {
          bitSet(result,FAIL_NOTCONNECTED);
      }
       
         
      // then check for continuity and OUTPUT/LOW
      digitalWrite(pins[i], LOW);
      if (digitalRead(pins[i-1])!=LOW)
      {
          bitSet(result,FAIL_NOTCONNECTED);
      }
      if (digitalRead(pins[i+1])!=LOW)
      {
          bitSet(result,FAIL_NOTCONNECTED);
      }
    }
    
   
    // final test for short circuit against other pins. different tests for odd or even
    for (byte j=1;j<NUMCABLES;j++)
    {
      allPinsInputHigh();
      pinMode(pins[i], OUTPUT);
      
      //even pins
      if ((i&0x00) && (j!=i) && (digitalRead(pins[j])==HIGH))
      {
        bitSet(result, FAIL_SHORTENED);
      }
      //odd pins
      if ((i&0x01) && (j!=i) && (digitalRead(pins[j])==HIGH) && (j-i!=1) && (j-i!=-1))
      {
        bitSet(result, FAIL_SHORTENED);
      }
   
    }
    Serial.print("Line ");
    Serial.print(i);
    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
  }
}

As I understand your setup you are testing 3 wires in each step. The output must come back at least on one of its neighbours. The first wire is no special problem with an even number of wires, then connect a diode to the last wire.

Normally one pin is set to output, all others remain inputs. Then wanted and unwanted connections are tested, then the next pin becomes the output. In your setup a short is detected when the output signal arrives at any other pin, except for those connected by diodes in forward direction. This means that one wire must be tested for a short with a HIGH signal, for connection with a LOW signal, the next wire with opposite polarity.

This works only if each wire has a defined "idle" signal, with a pullup or pulldown resistor at the diode side, so that this level can not come from any diode. Common anodes deserve a pullup, common cathodes a pulldown. Unortunately now the resistors are shorted by the diodes, all pins have an undefined (middle) state :frowning:

I have no tested solution for this problem, perhaps it helps to turn power to the resistors on and off. If the test signal is HIGH, all pulldown resistors are connected to Gnd, and the pullups are connected to Vcc only when the output state is LOW. The resistors can e.g. be 10k to 50k.

What if there is a short? If you are doing this on a production basis they make commercial testers good to 1000 points. To properly test it you will need to connect all pins at each end. You can use octal bidirectional buffers to interface to the cable, that way you can send or receive a signal.

DrDiettrich:
This works only if each wire has a defined "idle" signal, with a pullup or pulldown resistor at the diode side, so that this level can not come from any diode. Common anodes deserve a pullup, common cathodes a pulldown. Unortunately now the resistors are shorted by the diodes, all pins have an undefined (middle) state :frowning:

You understood my circuit well and I understand the issue you are pointing out.
So the issue with pins declared only as input as opposed to input pullup is due to noise oscillations which might interfere with reading. Would it be possible to connect something to limit this noise and allow me to just use the pinmode(input) on its own? this would solve this issue wouldn't it?

gilshultz:
What if there is a short? If you are doing this on a production basis they make commercial testers good to 1000 points. To properly test it you will need to connect all pins at each end. You can use octal bidirectional buffers to interface to the cable, that way you can send or receive a signal.

Unfortunately I am not so experienced in this field to start using octal bidirectional buffers. I think the next thing left for me to do is simply find an extender for the arduino mega and use extra pins and connected each end and beginning to the board.

Primary question: do you want to follow your idea further or revert to the common solution with I/O pins on each end of the cable?

You're right that INPUT_PULLUP will assure a defined HIGH signal by default. Unfortunately this solution will only apply to half of the tests, with a LOW output level.

#5 DrDiettrich:

Primary question: If there is a solution for my current idea I would like to explore it. I am not sure which path is most convenient, one has lots of diodes that need connecting and one has a whole other device (or more) connecting to the board. I will need to buy components for either idea so I am not bound to either right now.

DrDiettrich:
You're right that INPUT_PULLUP will assure a defined HIGH signal by default. Unfortunately this solution will only apply to half of the tests, with a LOW output level.

So what you are saying is that output High test will not work but output Low test would? could this give me the result I am looking for anyway, which is a continuity test? I figured output Low would only have the digital pin be inactive as opposed to being a voltage/current sink.
to clarify, if I have Input_pullup pin connected to output LOW pin, would the pinRead() on the input_pullup pin read 5V (high) or 0V(low)?

nikola-med:
to clarify, if I have Input_pullup pin connected to output LOW pin, would the pinRead() on the input_pullup pin read 5V (high) or 0V(low)?

The output pin overrides the pullup, so you'll always read the state of the connected output pin.
Your idea with the diodes does not establish direct connection between output and input pins. An output connected to diode cathodes can pull down the related input pins, but connected to anodes it only can pull the input pins high - what they already are with INPUT_PULLUP. That's why I'd attach pulldown resistors to those inputs, which can be overridden by a HIGH output at the anodes.

DrDiettrich:
An output connected to diode cathodes can pull down the related input pins, but connected to anodes it only can pull the input pins high - what they already are with INPUT_PULLUP.

I see. The issue is that I am testing the wrong way round. If my output will be Low but inputs are High then I should be testing all the even pins which are pins connected to cathodes.

example: I test pin 2 which has cathode connection to pin 1 and pin 3. I set pin 2 as output(LOW) and pins 1 and 3 to input_pullup. I read from pins 1 and 3 the status of the pins. if both are low then continuity is achieved if either is still high then that pin has an issue and if both are high then pin 2 has an issue. like this I will only be setting the pins with diodes cathode sides as outputs. This should work yes?

when testing for shortcircuit I will set both anode side and cathode side to output(high or low) (not sure about this yet) one by one and read all pins if there are any unexpected pin readings. I would have to keep in mind that the anode connected pins will have different expected status of nearby pins than the cathode connected pins.

Would it be dangerous if I connected input_pullup pin to an output(high) pin?

1 Like

One output pin can drive many INPUT_PULLUP pins.

For the logic: force various faults, one or more at the same time, and check for correct error messages.

DrDiettrich:
One output pin can drive many INPUT_PULLUP pins.

For the logic: force various faults, one or more at the same time, and check for correct error messages.

Thank you, You have been great help. I will have to wait on this project for some time until i get all the components and start soldering. This is a side project for work so getting the components will take some time due to paperwork. Will post results when I manage

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.