New approach to Rotary Encoder


Closed Thread
Results 1 to 40 of 91

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    Hi Ioannis,
    I haven't looked at the particular code in question but generally, you decode all 4 edges, hence the term quadrature. Look at the capture for one click, first Ch.0 goes low (1) then Ch.1 goes low (2), then Ch.0 goes high (3) and finally Ch.1 goes high (4). So, 4 counts per click.

    /Henrik.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    Hmm, thanks Henrik, it looks logic now... well...

    Ioannis

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    I need a rotary encoder for manual input in flight simulator; changing radio frequency, autopilot altitude, etc. I like the "slower" detection in post #1 for this particular application or else I'd issue 4 keyboard commands in a single detent. 100 feet would change to 500 feet with a single click with no way to set to the in-between values.

    But Podgy brings up a very important point; all rotary encoder datasheets I've seen mention debounce. I know most PIC inputs have Schmitt triggers, but just how effective are they in these cases? I can't test until my batch arrives.

    Robert
    Last edited by Demon; - 28th February 2012 at 00:01.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    a couple of 100nF were needed for mine. After placing the caps to ground from each encoder output pin, false readings were a past.

    Ioannis

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    Need help with one enconder ... a little different.
    How can I read the "up/+" and "down/-" action of this particular encoder ?
    Any help will be appreciated ! Thanks in advance !
    Attached Images Attached Images  

  6. #6
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    It's ok something like this ?!
    Code:
    TrisA = %00000000
    TrisB = %11110000
    PortB = 0
    
    Flag                var bit
    Q_New               var Byte
    Q_Old               var byte
    M_Count             var byte [4]
    P_Count             var byte [4]
    Q_Count             var word
    
    ' ---------------------- Set variable value @ startup ----------------------  
         
    For Q_Old = 0 to 3
    Read Q_Old,M_Count[Q_Old]
    Read Q_Old + 4,P_Count[Q_Old]
    Next Q_Old
         
      Q_Count = 0   
        Q_New = 0
        Q_Old = 0
         Flag = 0  
                            
    
    Goto Main_Loop
    
    Encoder:                                    '
    Q_New = PortB.7 + PortB.6 + PortB.5         ' get port status
     
    If M_Count[Q_Old] = Q_New then              ' if M_Count code satisfied then minus
              Q_Count = Q_Count - 1
                 Flag = 0                       ' set flag for DOWN
    goto Q_Skip
    endif
    
    If P_Count[Q_Old] = Q_New then              ' if M_Count code satisfied then plus
              Q_Count = Q_Count + 1
                 Flag = 1                       ' set flag for UP
    endif
    
    
    Q_Skip:
    Q_Old = Q_New                               ' update Q_Old Byte
     
    
    Main_Loop:   
    if Flag = 1 then do command1                             
    if Flag = 0 then do command2                                  
    goto Main_Loop

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: New approach to Rotary Encoder

    So far...no good ...
    Complete "hardware" it's like in picture . I intend to use an remote with some "rotary encoder" ...
    The remote controller has six wires . They are connected to three rows and three columns. This allows maximum of 3*3=9 functions. Roller takes three functions because it must be possible to know which way it is rotated (how doing this in PBP ?!?). Rest of the functions are assigned to six buttons.
    I use great pice of code (keypad matrix routine) of Mr. Mister-e and the "regular" buttons works verry fine...but I want to use the function of roller too.
    I can't figure out how doing this, so any "clue" will be appreciated !
    Attached Images Attached Images  

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