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()
{
}

