New approach to Rotary Encoder


Results 1 to 40 of 91

Threaded View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807

    Default New approach to Rotary Encoder

    Here is an experiment on Rotary Encoders and a different approach than the standard XOR way.

    Code:
    loop1:
    if portb.1=0 then                 'here is switch 1 of the rotary encoder
        counter=counter+1
        goto lcd
    endif
    
    if portb.0=0 then                 'here is switch 2 of the rotary encoder
        counter=counter-1
        goto lcd
    endif
    
    goto loop1
    
    lcd:
    lcdout $fe,$c0,dec5 counter
    while (portb.0=0 or portb.1=0):pause 10:wend
    goto loop1
    The key is the last While/Wend command where it checks for the next pulse comming after the first edge of either switch of the encoder.

    Common of the encoder is Low and Pull Up is supposed to be active.

    Ioannis
    Last edited by Ioannis; - 8th December 2010 at 09:44. Reason: loop is reserved in 2.60 and later

Members who have read this thread : 2

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