Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Checking 3 pin wire connections automatically?

Status
Not open for further replies.

bigal_scorpio

Active Member
Hi to all,

I will be making a lot of cables up for a friend soon. They are nothing special, just a thin screened cable with a 3 pin connector on each end.

What I thought I would do is make the painful process of testing each one after assembly easier by building a tester with a couple of the connectors on it so I could just plug them in tell immediately if they are ok. No need for the contortions of trying to get the meter probes on each end one at a time.

What I am proposing is using a 16F630 pic, the 6 "C" pins each connected to one pin of each of the connectors and a couple of LEDs connected to some of the "A" pins.

Then when turned on the pic would check firstly for shorts between the connectors one one end - if ok then both ends should be ok.

Next I wanted to test the continuity of each core from the matching pin on each end of the cable.

I use PicBasic Pro to program and am by no means an expert but this time it is not the actual syntax I am stuck with, its the way of checking that baffles me.

How do I turn one pin to output and then check all the others to confirm only the correct one is connected and then do the same for the other combinations?

There is probably a simple way of doing this but I can't think of it!

Can anyone help?

Thanks Al
 
A lot of effort for a 3core cable.

Why not use (for each core of the cable) a push button which connects a supply to a pin at one end of the cable, at the other end connect the corresponding pin to an LED, the LED connects back to the power supply.

When a button is pushed, the corresponding LED should illuminate.
If it does not there is an open circuit.
If the wrong LED illuminates, there is a wiring cross over.
If two or more LEDs illuminate, there is a short between cable cores.

Three button pushes and the cable is tested.
And the tester can be built in an hour or so.

JimB
 
Last edited:
Hi Jim,

Yes I see your point mate, but where's the fun in that? ;)

Tinkering is half the fun for me and it often teaches me something that I could not grasp by just book learning.

Al
 
The simplest way to do this is two pic's 12F any one you have handy. Take one of them and put 3 leds on it with resistors. Set to input fire each pin one at a time which will blink that led and then hold it
 
Last edited:
As far as I can tell, you need 3 outputs and 3 inputs.

Make outputs 2 and 3 inputs, turn on output 1 - check the other end of the cable and make sure that only the correct input is on and no more.
(You can also check outputs 2 and 3 to make sure they are not high however if there's a short it will show up at the other end so no need).
Make outputs 1 and 3 inputs, turn on output 2 - check the other end.
Make outputs 1 and 2 inputs, turn on output 3 - check the other end.

I think that should be it.
 
Last edited:
The way I was thinking you'll no which wire is which at each end and You'll get a common gound with the unused pins

It's like this set pin 1 to input set 2 and 3 low wait till for pin to go high save that to variable go next pin

The sending chip can output for set time.

After you think about this there a lot you could do.
 
Hi Burt,

I can think of a couple of problems with your approach. For example if the common ground is open circuit, no LED's will work which is also the same symptoms as the other 2 wires being open circuit.

Also, if ground is shorted to one of the other lines, it will give the same symptoms (on the tester) as the other line being open circuit (no LED on).
 
Last edited:
Both chips have to share a ground if two out three wires is broke there something bad wrong and you'll no if there a open wire. And it a short. And last I no it works made one for a bunch of wires and it worked fine. I'm taking the line high with picA and setting picB to input one pin at a time and two of the 3 will at ground while testing one line .

Say line one is shorted led don't light cables bad end of show.

Line one led came on show goes on to next line can't pull high end of show but lets test the last one any way

Line three set to input on B we can pull high led on. We know we have one bad line and we know which I really don't think it would make much deference if it's a short or broke wire it's still bad period.

But the short shows to because you can't bring the line to vdd on input
 
Yes but multiple different conditions cause the same symptoms. And it uses twice as many parts as other ideas. Hardly optimal.

Also, the tester should tell you exactly what is wrong on which line. Otherwise you will have to pull out your multimeter if the tester gives an error.
 
Last edited:
Looks good to me Your just not with me it test all three for each. Good wire and which one, Broke wire and a short whats left???

View attachment 63444

Ps with the right chip you probably could tell how far from chipA the short is.

twice as many parts as other ideas

Where all I have is 3 leds 6 resistors to show state.

How is your idea outputting what wire is what you list no output device.
Now Jimb is the easiest way but Big said micr and learning about how to do this with one.
 
Last edited:
I understand you a bit better now Burt, but still, you need 2 PIC's to do the job one PIC could do.

Actually I really don't understand why you need 2 PIC's?

Couldn't you just use 3 inputs (and 3 outputs) on the same PIC?
 
You could but what if the wires are run in a car and one end is in the trunk and your at the hood.
 
I would use a micro with 4 outputs and 3 inputs. Connect one end of each wire to output of micro, the other to input, and the last output will light an LED.

The micro will simply toggle each wire one at a time and read on the other end if the right pin is high and if no other is high. After it tests all three wires it will light the Ok LED.
It can be done with a simple continous loop, so as soon as it gets to check all three after connecting the led will be on.
 
Last edited:
Hi guys,

I am still trying to puzzle out how to best do this, though I do want to use a PIC.

I have tried various programs using loops but got bogged down in the for next and if thens.

I have even resorted to actually checking the connections one by one in 3 separate chunks.

The code below has issues in that even with the connections made correctly I am still getting all 3 of the error lights that I set up on port A, when there should be none, unless I am missing something?

My connections are as follows:-

RC3 to RC0
RC4 to RC1
RC5 to RC2 all made with jumper cables on my dev board.

I am programming the PIC with INT OSC, Master clear disabled and WDT disabled but alas all 3 error lights come on immediately, even though the pauses I added should have slowed it down.

Also I have tried pull downs on all port C pins to no avail.

Al

Code:
'PROG TO TEST 3 PIN CONNECTORS FOR CONTINUITY AND SHORTS
'USING 16F630 ON EASYPIC5 DEV BOARD


CMCON = 7            'set to all digital

TRISC = %11111111       ' Set PORTC to all input
TRISA = %00000000      ' Set PORTA to all OUTput
PAUSE 1000

mainloop:
TRISC = %11110111 
    PORTC.3 = 1
  IF PORTC.5 = 1 THEN shorterror
  IF PORTC.4 = 1 THEN shorterror
  IF PORTC.0 = 0 THEN conterror
  IF PORTC.2 = 1 THEN wrongerror
  IF PORTC.1 = 1 THEN wrongerror
    PORTC.3 = 0
TRISC = %11111111

PAUSE 1000
 
TRISC = %11101111    
    PORTC.4 = 1
  IF PORTC.5 = 1 THEN shorterror
  IF PORTC.3 = 1 THEN shorterror
  IF PORTC.1 = 0 THEN conterror
  IF PORTC.2 = 1 THEN wrongerror
  IF PORTC.0 = 1 THEN wrongerror
    PORTC.4 = 0
TRISC = %11111111

PAUSE 1000
 
TRISC = %11011111   
    PORTC.5 = 1
  IF PORTC.3 = 1 THEN shorterror
  IF PORTC.4 = 1 THEN shorterror
  IF PORTC.2 = 0 THEN conterror
  IF PORTC.0 = 1 THEN wrongerror
  IF PORTC.1 = 1 THEN wrongerror
    PORTC.5 = 0
TRISC = %11111111

PAUSE 1000 
        Goto mainloop   

shorterror:
PORTA.0 = 1
pause 1000
RETURN

conterror:
PORTA.1 = 1
pause 1000
RETURN

wrongerror:
PORTA.2 = 1
pause 1000
RETURN
        End
 
what language is that? some kind of basic?
I would do it along the lines of:
Code:
while(1){
  good=0;
  short=0;
  nc=0;
  set_wire1();
  if(input==wire1)good=good+1;
  else if(input==0)nc=nc+1;
  else short=short+1;
  unset_wire1();

  set_wire2();
  if(input==wire2)good=good+1;
  else if(input==0)nc=nc+1;
  else short=short+1;
  unset_wire2();

  set_wire3();
  if(input==wire3)good=good+1;
  else if(input==0)nc=nc+1;
  else short=short+1;
  unset_wire3();

  if(good==3)set_led_good();
  else unset_led_good();

  if(nc>0)set_led_no_connection();
  else unset_led_no_connection();

  if(short>)set_led_short();
  else unset_led_short():
}
pardon my pseudocode please
I hope you can test for example if PORTC==0x04 or you will have to test all three bits separately for each wire.
 
Last edited:
i would use MCU (any) and have three outputs (one for each wire) that are turned on one at a time (001, 010, 100, and then repeat continuously)
this would connect to one end of the cable. the other end would connect to same device but to three inputs (read all three inputs at the same time).
all inputs and outputs would have LED (6 LEDs in total, no dedicated I/O for LEDs). one more input for push button to force next scan if fault is detected.

idea: you connect both ends of the cable to same testing device.
outputs are scanned continuously (and fast, maybe 100-200 Hz per second for example).
if everything is ok, you will read same thing on inputs as what you put to outputs. this is easy to compare.
if the input(feedback) matches output, go to next scan pattern.
otherwise stop and wait. allow press on button to force index to next pattern (one press, one increment).

so if everything is good, cycle all patterns, and all LEDS light up. if there is a problem cycle stops and LEDs tell you current (problematic) connection::
- no input LEDs means none of them are connected to currently active output (loose or no connection)
- if wrong input lights up, you know that that wire is swapped
- if multiple inputs light up, you can see which ones are shorted

this is simple to implement using TTL or CMOS chips too, but MCU can give additional flexibility, and this is trivial to program. also using more I/O, this can be quite flexible universal cable tester. ideally this would also have several common connectors (DB9, RJ45 etc.) for both input and output. it could be used to quickly reverse-eingineer any cable (along with jumpers as used in RS232 for handshaking). ideally it could have local 'library' of various cables and recognize them instantly. also connectivity to PC (RS232 or USB) would allow to get the detected connections into a computer (with database and cad) or to download from computer to cable tester as new or current test pattern.
 
Last edited:
Hi guys,

Kubeek, sorry mate but as I am only used to PicBasic Pro I cannot figure out your C code though I can see some of the ideas.

Panic Mode, I think what you are saying is basically what I am trying to do. I just don't see why my code above doesn't work.

Anyone out there who can have a quick look at my code to see what I have missed?

Al
 
Kubeek, sorry mate but as I am only used to PicBasic Pro I cannot figure out your C code though I can see some of the ideas.
You should be able to easily rewrite my code into Basic. Mind you that what I wrote is not any particular language, it is just pseudo-code that looks a little like C, but it is more of an example how the program should function.

About your code, I suppose the problem lies somewhere in the spaghettiness of it. I am not familiar with picbasic, but I guess that for example "IF PORTC.5 = 1 THEN shorterror" calls function shorterror, right?
Are you sure that TRISC = %11110111 sets the output, instead of setting the output direction?
Also shouldnt it be "IF PORTC.5 == 1 THEN shorterror"?

Sorry I have no idea how this picbasic works, but it seems like pretty lousy language.. I dont know how to do if-else statemets or define a variable, and I didn't find any syntax or documentation.

Why did you choose this language anyway?
 
i don't know what your code was written in, but it is much too long.
here is what i expect to see (please adjust syntax as needed)

Code:
'PROG TO TEST 3 PIN CONNECTORS FOR CONTINUITY AND SHORTS
'USING 16F630 ON EASYPIC5 DEV BOARD
  
CMCON = 7            'set to all digital
 
TRISC = %11111111       ' Set PORTC to all input
TRISA = %00000000      ' Set PORTA to all OUTput
PORTA = %00000001      ' initialize one of test patterns
mask = %0000111         ' create mask (costant) to only test lower three bits

mainloop:

   PAUSE = 1000
   IF (PORTC AND mask) = (PORTA AND mask) THEN ' only move to next pattern if feedback on PORTC matches sent pattern on PORTA
		PORTA = (PORTA+PORTA) AND mask ' test patterns only use lower three bits
		IF PORTA = 0 THEN PORTA = %00000001   ' if nothing set, start with first test pattern   
   ENDIF
   
End
 
to test 5-wire cable, just modify mask to %00011111 and we are DONE.
of course this assumes that LEDs are attached to all test inputs and outputs.
all LEDs are driven by PORTA - even those that are wired to PORTC (through cable connections).
in this code sample (whatever it is, psudocode...) i didn't add condition
to force advancing to next pattern using push button.
this can be done by modifying condition of IF statement.
instead of adding PORTA with itself, you can use shift left, we just need to double the pattern value so the
next output bit is set...

if LEDs are not efficient, PORTA may need buffering (with transistors or just use ULN2003 or ULN2803).
if using buffering, feedback bits may need to be inverted, that's all...
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top