How to make working one HCTL2016 and a PIC16F876


Results 1 to 4 of 4

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    mmm, can you tell more about what you want to do with the rotary encoder???

    i'd never use this IC and i believe we can remove it and connect the encoder directly to the PIC.

    I often use rotary encoder in my apps to navigate between menu and/or get user entry. So an extra IC should be motivated by something that i don't see/understand.

    Bellow is one example to use rotary encode to increment/decrement a variable
    Code:
        ' Procedure to get value change from rotary encoder
        '
        OldPos = (PORTB & %11000000)>>6 ' get only PORTB<7:6> bits
        NewPos = OldPos 
        
        ' see if encoder has move
        ' 
        while ((NewPos==0) or (NewPos==3)) 
           NewPos = (PORTB & %11000000)>>6 ' get only PORTB<7:6> bits
           wend
        
        pause 20 ' debounce delay
     
        ' Get encoder movement
        ' --------------------
        '
        '      Rotary encoder output table (clockWise rotation):
        '      -------------------------------------------------
        '             00
        '             01 between move (half detent)
        '             11
        '             10 between move (half detent)
        '
        '     Using XOR
        '
        '               OldPOS   : 0     0     3     3
        '               NewPos   : 1     2     1     2
        '               movement : CW   CCW   CCW    CW
        '           XOR -------------------------------
        '                          1     2     2     1
        '
        ' So, if NewPos XOR OldPos = 1 => increment
        '        Newpos XOR OldPos = 2 => Decrement    
        '
        Newpos=newpos ^ oldpos 
        select case newpos
    
               case 1
                   menuchoice=menuchoice+1
    
               case 2
                   menuchoice=menuchoice-1
    
         end select
    Last edited by mister_e; - 9th July 2005 at 13:21.
    Steve

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

Members who have read this thread : 0

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