Using 4 input to control 10 output


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11

    Default Using 4 input to control 10 output

    Dear all.

    first off all i would like to apologise my bad english.
    Iam been working a robot project control via serial com PC using 4 channel RF( thanks to melaine that give source code on this forum). Transmitter section, iam using PIC 16F626 and to control 4 (led) output RA.0 to RA.3 that i connected to Transmitter module (4 ch).
    On Reciever section, Reciever module is connected to PIC16F877 RB.0 to RB.3.
    10 Output(led) is connected to RA.0 to RC.2
    The problem is how to control the 10 LED individually using only 4 input?
    i hope that this imformation can inderstand my project situation
    regards

    cibotsan

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    The result will be based on this table

    Code:
    state of inputs          state of outputs
    ==============          ================
    0000                       0000000001
    0001                       0000000010
    0010                       0000000100
    0011                       0000001000
    0100                       0000010000
    0101                       0000100000
    etc
    simple code here...
    Code:
    ADCON1=7 ;disable ADC
    
    
    TRISB=$FF
    TRISA=0
    TRISC=0
    
    
    InputBCD VAR PORTB
    Out1_8   VAR PORTA ;first 5 LEDs
    Out9_10  VAR PORTC ;last 5 LEDs
    GetInput VAR BYTE
    BCDToDEC VAR BYTE
    
    Out1_5=0
    Out6_10=0
    
    start:
    Getinput=InputBCD
    
    Select case Getinput
               Case is<=5
                       Out6_10=0
                       BCDToDEC=dcd Getinput                   
                       Out1_5= BCDToDEC
               Case is>=6
                        Out1_5=0
                        BCDToDEC=dcd (GetInput-6)
                        Out6_10= BCDToDEC
    End Select
    goto start
    it's suppose to work. Try and post reply on this. There's several different way to do this
    Last edited by mister_e; - 3rd November 2004 at 06:12.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thanks steve .
    any how i try it but ist wont work.for you imformation.when i run it all output is on all while input = 0.When i set any input = 1 , the only ouput Rc0 =0 below is my code .

    ADCON1=7 ;disable ADC


    TRISB=$FF
    TRISA=0
    TRISC=0


    InputBCD VAR PORTB
    Out1_5 VAR PORTA.0 ;first 5 LEDs
    Out2_5 VAR PORTA.1 ;first 5 LEDs
    Out3_5 VAR PORTA.2 ;first 5 LEDs
    Out4_5 VAR PORTA.3 ;first 5 LEDs
    Out5_5 VAR PORTA.4 ;first 5 LEDs
    Out6_10 VAR PORTC.0 ;last 5 LEDs
    Out7_10 VAR PORTC.1 ;last 5 LEDs
    Out8_10 VAR PORTC.2 ;last 5 LEDs
    Out9_10 VAR PORTC.3 ;last 5 LEDs
    Out10_10 VAR PORTC.4 ;last 5 LEDs

    GetInput VAR BYTE
    BCDToDEC VAR BYTE

    Out1_5=0
    Out6_10=0

    start:
    Getinput=InputBCD

    Select case Getinput
    Case is<=5
    Out6_10=0
    BCDToDEC=dcd Getinput
    Out1_5= BCDToDEC
    Case is>=6
    Out1_5=0
    BCDToDEC=dcd (GetInput-6)
    Out6_10= BCDToDEC
    End Select
    goto start

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    "Thanks steve .
    any how i try it but ist wont work.for you imformation.when i run it all output is on all while input = 0.When i set any input = 1 , the only ouput Rc0 =0 below is my code ."


    can you provide the output table from transmitter you have and receiver you want?

    maybe

    transmitter:
    1111 = receiver out1
    1110 = receiver out2
    1101 = receiver out3
    1100 = receiver out4
    1011 = receiver out5
    .....

    let us know
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    thanks again steve
    okey whats i need is like this

    state of inputs state of outputs
    ============== ================
    0000 all output =0
    0001 out1 =1 out3=1
    0010 out2 = 1 out 4 =1
    0100 out1=1 out4=1
    1000 out2=1 out3=1
    0011 out5=1
    0110 out6=1
    1100 out7=1
    0111 out8=1
    1110 out9=1
    1111 out10=1

    its is possible to change from out put to a label? because i will use to control a different output devices for example RC servo, DC motor ,relay etc?

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    "its is possible to change from out put to a label? because i will use to control a different output devices for example RC servo, DC motor ,relay etc?"

    sure....

    Code:
    ADCON1=7 ;disable ADC
    
    
    TRISB=$FF
    TRISA=0
    TRISC=0
    
    
    Out1     VAR PORTA.0
    Out2     VAR PORTA.1
    Out3     VAR PORTA.2
    Out4     VAR PORTA.3
    Out5     VAR PORTA.4
    Out6     VAR PORTC.0
    Out7     VAR PORTC.1
    Out8     VAR PORTC.2
    Out9     VAR PORTC.3
    Out10    VAR PORTC.4
    Rinput   VAR PORTB
    
    GetInput VAR BYTE
    Gosub ResetOutputPort
    start:
    
    GetInput=Rinput & $0F ;will mask the MSB bits of PORTB
    
    select case Getinput
         Case 0
            Gosub ResetOutputPort
         Case 1
            Out1=1
            Out3=1
         Case 2
            Out2=1
            Out4=1
         Case 3
            Out5=1
         Case 4
            Out1=1
            Out4=1
         Case 6
            Out6=1
         Case 7 
            Out8=1     
         Case 8 
            Out2=1
            Out3=1
         Case 12
            Out7=1
         Case 14
            Out9=1
         Case 15
            Out10=1
    End Select 
    goto start       
    
                  
    ResetOutputPort:
    PORTA=0
    PORTC=0
    return
    now it's really suppose to match with your specific need.

    NEXT!!!
    Last edited by mister_e; - 4th November 2004 at 17:02.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Yes!!! its working, thanks again steve you safe my robot life.can i buy you a drink?If i have further problem i will online again.

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    hi cibotsan,
    Great to know that everything work for you !!!

    >can i buy you a drink?

    hehe nothing exepensive.... 50 year age PORTO will do the job

    best regards
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. problem with input and output (18F452)
    By turkuaz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th March 2008, 23:21
  2. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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