View previous topic :: View next topic |
Author |
Message |
Aurbo
Joined: 07 Apr 2008 Posts: 49
|
Continuity test between ports |
Posted: Sun Sep 07, 2014 2:23 pm |
|
|
How would I test a pair of wires connected to RB0-RD0 and RB2-RD2 for continuity and or shorting?
I'm trying to understand how a pair of ports on a single mcu can determine continuity and/or shorting between the two lines.
Basically a 2 wire cable tester.
I'm not getting the concept for some reason, any help would be appreciated. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Sun Sep 07, 2014 2:33 pm |
|
|
basic electrical continuity
set a 'one' on one wire, read the result which should be a 'one' on THAT one wire..if true, that wire is good
if false, it's busted
if the 'one' appears on any other wire, it's shorted to the other wire.
there is a 'cat5 cable' test program on the forum...you could cheat and just use that IF it works BUT you better KNOW how it works when the teacher asks you !!!
hth
jay |
|
|
Aurbo
Joined: 07 Apr 2008 Posts: 49
|
|
Posted: Sun Sep 07, 2014 2:39 pm |
|
|
Thanks for the quick response, and the tip
As for the teacher.. not had to deal with one in nearly 35 years. |
|
|
Aurbo
Joined: 07 Apr 2008 Posts: 49
|
|
Posted: Tue Sep 09, 2014 5:48 pm |
|
|
I cannot find the cable tester thread you mentioned.
If I understand the theory correctly
1.set both ports as input (tris registers to 0xFF)
2.set a single pin as output and set high
3.set remaining pins as input
4.scan input port for the signal from the output pin, if more than one input pin received the signal then a short exists. (more than one input pin goes high)
5.save the results
6.repeat steps 2-5 until all pins have been checked.
7.display results. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Sep 09, 2014 6:34 pm |
|
|
CCS has a few functions you can use to make things go easy..
bit_set() , and bit_test().. See the help files( F11 when project is open) for proper use.
Since you only have 2 wires it is easy
bit clear (turn off) RB2 ( the second wire connection)
bit set( turn on) RB0. (the first wire connection)
Now test RD0 using bit_test().
If it is a one( true) then the wire is connected
If it is a zero(false) then the wire is busted
Now test RD2 using bit_test().
If it is a one(true) then RB0 is connected(shorted) to RD2
If it's a zero(false) then no connection(good)
The 'trick' is to think in small,easy to test steps, and proceed in a logical pattern.Once you get it to work for 1 wire, simply copy but recode for the I/O pins in use.
Be sure to read the manual to get the proper syntax for the tests though !!
hth
jay |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
|
|