program help


Closed Thread
Results 1 to 3 of 3

Thread: program help

  1. #1
    TONIGALEA's Avatar
    TONIGALEA Guest

    Default program help

    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

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Well, the obvious springs to mind...
    Code:
    For CounterA=16 to 240 step 16
    	TestByte=CounterA+$0F
    	High PortE.0
    	PortC=TestByte
    	Gosub ShortCheck
    	Next CounterA
    Melanie

  3. #3
    Join Date
    Aug 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    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 InputAutput 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

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 10:54
  2. Replies: 1
    Last Post: - 23rd May 2009, 10:22
  3. Compile and Program help using PICKit2
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th March 2009, 15:51
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  5. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 15:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts