PDA

View Full Version : program help



TONIGALEA
- 7th October 2004, 13:15
Hello everyone
i need some help from you again:) on a tester i am presently working on.
Basically the tester is a cable tester which tests the Continuity of a 16 core cable and also checks to see if the cable cores are shorted to each other.
I am using two 16 channel multiplexers which both have 4 control lines and an enable pin (DG406)
so i am using portc of the 16f877 for those where the first four bits RC0 - RC3 controls Mux1 and the last four bits RC4 - RC7 controls Mux2
Now here comes the problem.
i want to be able to leave the value of the first 4 bits constant and then change just the last 4 bits to check for shorts (ie if s1 on mux1 is shorted to s2,3,4---s16
but the only way i can do this is very long winded as you can see from below
Is there and easier way i can do this as i would need to do this for 16 times for each pin

PIN1_SHORT:
high PORTE.0: PORTC=%00011111
GOSUB SHORT_CHECK ' check if shorted to pin2
high PORTE.0: PORTC=%00101111
GOSUB SHORT_CHECK ' check if shorted to pin3
high PORTE.0: PORTC=%00111111
GOSUB SHORT_CHECK ' check if shorted to pin4
high PORTE.0: PORTC=%01001111
GOSUB SHORT_CHECK ' check if shorted to pin5
high PORTE.0: PORTC=%01101111
GOSUB SHORT_CHECK ' check if shorted to pin6
high PORTE.0: PORTC=%01111111
GOSUB SHORT_CHECK ' check if shorted to pin7
high PORTE.0: PORTC=%10001111
GOSUB SHORT_CHECK
RETURN


Best Regards
Toni

Melanie
- 7th October 2004, 14:16
Well, the obvious springs to mind...


For CounterA=16 to 240 step 16
TestByte=CounterA+$0F
High PortE.0
PortC=TestByte
Gosub ShortCheck
Next CounterA

Melanie

ero
- 7th October 2004, 14:59
Dear Tonigalea,

If I undertood very well your problem the solution can be as follows;
First of all you should use 2 pcs. 4067 (analog multiplexer)
'------------------------------------------------------------------------------
mux1 var byte
mux2 var byte
shft var byte
error var byte
InputA var PortE.0 'connected to the exit of Mux1
ExitB var PortE.1 'connected to the exit of Mux2
Input InputA:output ExitB

main: High InputA
for mux1=0 to 15:error=0
for mux2=0 to 15
shft=mux1<<4
PortC=mux2+Shft
if ExitB=1 then Error=Error+1
next mux1
next mux2
if error<15 then Broken_Line
if error>15 then Cross_Connection
'------------------------------------------------------------------------
'The ExitB should be Pulldown by a 10K resistor.
I did not try the program but I think it can work. You can check broken lines and also cross connected lines in same time.

ERO