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.
Hi Panic Mode,

I haven't had chance to try your code yet but how does it discriminate between a short and a swapped wire?

I am not well versed in masks but I get the general idea of how you are checking but as I said, I don't get how I can get a result that tells me which problem if any is present?

Thanks Al
 
hello bigal,

you are right, this only handles the simplest case in which it expects 1:1 cable, anything other connection(or lack off) is considered wrong.
therefore no decoding is done on PIC, decision is left to user from displayed LED pattern (pic stops scan when any mismatch is found).
as with any oversimplified system, there is a hidden pitfall,
if all wires are short, all LEDs would be on and there would be no distinction with "OK" case where the MCU just scans perfect cable.

to do a full tester, it would take more effort, including constant manipulation of TRIS registers, case by case comparison and separate indication.
and that comes back to what you started...
 
Last edited:
Bigal, I would suggest refining the algorithm first, ie specify the exact test sequence and draw it out as a flowchart (or just a text flowchart sequence).

Once the algorithm is designed (possibly with some input from others) it should be easier to just write some code to execute it.

When programming I often write the entire sequence out in comments, then debug it in comments until the procedure is exactly what I want, then just write some code in to match the comments last and it all works.

Trying to design the algorithm and what it will do at the same time you write the code is a very difficult way of working. :)
 
Last edited:
Hi Roman,

Yes mate, I am finding that out and agree completely!

At the moment I have the program working in a fashion, but trying to catch the shorts, swaps and breaks is more puzzling that I would have believed!

This started out as a simple project just to make checking lots of cables easier, but wow is this a complicated logic problem.

I'm thinking of breaking the problem into smaller parts to try and make sense of it.

Al
 
I think the logic is quite simple:
set voltage on wire x
Read all inputs
if you read input only on wire x, the wire is ok
if you read input anywhere else the wire is shorted or connected to wrong pin
if you read nothing the wire is open

repeat for all wires
 
Last edited:
for simple cables (few wires and only 1:1 connection) the logic is simple.
but some cables (by design) can have multiple connections to any of the pins.
this is moer general case and logic is a bit more complex.
 
I think the logic is quite simple:
set voltage on wire x
Read all inputs
if you read input only on wire x, the wire is ok
if you read input anywhere else the wire is shorted or connected to wrong pin
if you read nothing the wire is open

repeat for all wires

Yep that looks pretty good, I would extrapolate a bit;
// PIC pins to the two 3pin cables (all pins have a 10k pullup resistor);
// A D
// B E
// C F

// test A
// all pins as inputs, but pin A as LOW output
// if D is high; record error A-D is open
// if any of BECF are low; record error A-x is shorted

// test B (repeat etc)

// final;
// if no errors; signal cable ie good
// if errors; signal which error as needed

As a display you could have one green LED for "all good" and 3 red LEDs for open cables, and 3 red LEDs for shorted cables.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top