connecting 5v output to analog input to "test cables"

Proposed idea: XLR audio cable tester. i want to wire 4 digital outputs to an xlr connector. then use another connector wired directly to 4 analog inputs. i want my code to send 5 volts down a single conductor, and read all 4 analog pins to detect shorted cables and continuity.

when i energize the positive pin, or digitalWrite(52, HIGH) and read, analogRead(a0), using breadboard to simulate xlr cable, i see 1023 which is good. when i look at analogRead(a1) - (a3) i see ~900 - ~1000. how can i bring the other pins down?

the code is not the finished product, I am trying to learn how to program and am very green.. please forgive my ignorance and ugly programming. eventually i want to run a test on each conductor seperately, then have a pass or fail, so i can check the cable for internal shorts and continuity. right now, i have it working, but testing all conductors simultaneously, not able to check for shorted conductors due to high readings on analog pins.

i am using an Arduino Mega 2560 recovered from an old 3d printer.

void loop() {
digitalWrite(xlrPs, HIGH); // pin 52 configured as OUTPUT
pos = analogRead(xlrPr); // pin A0
if (pos >= 1020){
delay(100);
digitalWrite(Ppass, HIGH); //turns on green led
digitalWrite(Pfail, LOW); //red led
P = 1; //used later in code, p+n+g+c should = 4, if not bad cable
}
else if (pos < 1020){
delay(100);
digitalWrite(Pfail, HIGH);
digitalWrite(Ppass, LOW);
P = 0;

sketch_apr20a.ino (2.66 KB)

As long as your pins ate not connected, they are «floating» which gives you random readings.

You should connect all your analog pins to ground to get a 0 reading while you don’t send 5v to the input.

when i look at analogRead(a1) - (a3) i see ~900 - ~1000. how can i bring the other pins down?

I am going to assume that there is nothing connected to those analog inputs and you want them to read near 0 for open. Is that right? If so, a high value resistor (100K - 1M ish) from the analog input to ground will pull that input down when unconnected (open) but not significantly affect the reading when connected HIGH.

Hi,
You need to discriminate between open and shorted cable conductors (And BTW wether the cables were wired correctly, which affects microphone phasing.)

You would like to know if the insulation is good.

One approach, which I used in testing Arduino inputs and outputs, is to connect two high value (say 100,000 ohms) resistors in series from +5V to Ground, with the center to each cable conductor. Start by reading the voltage at each conductor. It should be very close to 2.5V if the insulation is good.

(See the Arduino testing application HERE )

Then drive each conductor from the "send" end (in series with 220 ohms to protect the Arduino output pins), to both 5V and Ground and read those voltages. They should be close to 5V and Ground. The 100K resistors have little effect on that.

You could make a short XLR-Male to Female cable with the conductors connected to the test setup, maybe on a piece of protoboard.

Then you can test the tester by mating the two connectors, and then unplug and add cables in series to test.

It might be good to have the test run constantly, alarming any faults, so you can twist and abuse the cables and connectors to see if there are intermittent shorts/opens.

And as my Dad taught me in 1950, if you find a bad cable, immediately tie a figure-8 in both ends, so no one will mistake it for a good one... And when you get back to the radio station, you'll pull it right out of the cable bag and put it on the bench.

thanks all for the information! I am learning a ton. i wish i had discovered arduino a long time ago!

OP's CODE

 int xlrPs = 52;  // XLR Positive Pin test send 
int xlrNs = 50;  // XLR Negative Pin test send
int xlrGs = 48;  // XLR Ground Pin test send
int xlrCs = 46;  // XLR Case test send
int xlrPr = A0;  // XLR Positive pin test receive
int xlrNr = A1;  // XLR Negative pin test receive
int xlrGr = A2;  // XLR Ground pin test receive
int xlrCr = A3;  // XLR Case test receive
int Pfail = 31;  // Positive pin test fail
int Nfail = 33;  // Negative pin test fail
int Gfail = 35;  // Ground pin test fail
int Cfail = 37;  // case test fail
int Ppass = 53;  // positive pin pass
int Npass = 51;  // negative pin test pass
int Gpass = 49;  // ground pin test pass
int Cpass = 47;  // case test pass
int Good = 41; // good cable led
int Bad = 43; // bad cable led
int pos = 0;  // variable for positive test
int neg = 0;  // variable for negative test
int gnd = 0;  // variable for ground test
int cas = 0;  // variable for case test (shielded cable)
int P = 0;
int N = 0;
int G = 0;
int C = 0;

void setup() {
  pinMode(xlrPs, OUTPUT);
  pinMode(xlrNs, OUTPUT);
  pinMode(xlrGs, OUTPUT);
  pinMode(xlrCs, OUTPUT);
  pinMode(Pfail, OUTPUT);
  pinMode(Nfail, OUTPUT);
  pinMode(Gfail, OUTPUT);
  pinMode(Cfail, OUTPUT);
  pinMode(Ppass, OUTPUT);
  pinMode(Npass, OUTPUT);
  pinMode(Gpass, OUTPUT);
  pinMode(Cpass, OUTPUT);
  pinMode(Good, OUTPUT);
  pinMode(Bad, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(xlrPs, HIGH);
  pos = analogRead(xlrPr);
  if (pos >= 1020){
    delay(100);
    digitalWrite(Ppass, HIGH);
    digitalWrite(Pfail, LOW);
    P = 1;
  }
  else if (pos < 1020){
    delay(100);
    digitalWrite(Pfail, HIGH);
    digitalWrite(Ppass, LOW);
    P = 0;
  }
  digitalWrite(xlrNs, HIGH);
  neg = analogRead(xlrNr);
  if (neg >= 1020){
    delay(100);
    digitalWrite(Npass, HIGH);
    digitalWrite(Nfail, LOW);
    N = 1;
  }
  else if (neg < 1020){
    delay(100);
    digitalWrite(Npass, LOW);
    digitalWrite(Nfail, HIGH);
    N = 0;
  }
  digitalWrite(xlrGs, HIGH);
  gnd = analogRead(xlrGr);
  if (gnd >= 1020){
    delay(100);
    digitalWrite(Gpass, HIGH);
    digitalWrite(Gfail, LOW);
    G = 1;
  }
  else if (gnd < 1020){
    delay(100);
    digitalWrite(Gpass, LOW);
    digitalWrite(Gfail, HIGH);
    G = 0;
  }
  digitalWrite(xlrCs, HIGH);
  cas = analogRead(xlrCr);
  if (cas >= 1020){
    delay(100);
    digitalWrite(Cpass, HIGH);
    digitalWrite(Cfail, LOW);
    C = 1;
  }
  else if (cas < 1020){
    delay(100);
    digitalWrite(Cpass, LOW);
    digitalWrite(Cfail, HIGH);
    C = 0;
  }
  if (P + N + G + C == 4){
    digitalWrite(Good, HIGH);
    digitalWrite(Bad, LOW);
  }
  else if (P + N + G + C != 4){
    digitalWrite(Good, LOW);
    digitalWrite(Bad, HIGH);
  }
}

A neat idea to use the analog inputs - then you can see leakage or voltage drop over the wires.

Hi,

OP's CODE

Where did this code come from??

This seems to assume a MEGA, is that true??

terryking228:
Where did this code come from??

In the OP #1

Where did this code come from??
In the OP #1

SORRY! Now I Get It... Thanks for making it easier to see. Compiles OK for me on 1.8.5