Farnell's Rotary Encoder 733-726


Results 1 to 7 of 7

Threaded View

  1. #4
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Lightbulb

    Hello mister_e

    Thanks for the nice code.... and comments also

    I think I found my way of how to use these evil rotary encoders...

    Now, I don't know how to explain this very well, but I think the code will do..

    Code:
    @ DEVICE PIC16F84A, XT_OSC, PWRT_ON, PROTECT_OFF, WDT_ON

    TRISA = 3
    TRISB = 0

    PORTA = 0
    PORTB = 0

    NEW VAR BYTE
    OLD VAR BYTE
    TEMP VAR BYTE
    DIRECTION VAR BIT

    INIT:
    TEMP = PORTA
    NEW = TEMP & 3 ' PortA<1,0> only required as inputs<B,A>
    START:
    OLD = NEW
    BEGIN:
    TEMP = PORTA ' Read the new value to see if changed
    NEW = TEMP & 3
    IF NEW == OLD THEN BEGIN ' If not changed, keep reading
    DIRECTION = NEW.1 ^ OLD.0 ' XOR left bit of new and right bit of old
    IF DIRECTION = 1 THEN CLOCKWISE

    COUNTERCLOCKWISE:
    '
    '
    GOTO START


    CLOCKWISE:
    '
    '
    GOTO START

    I tested this code with a mouse wheel, and it worked perfectly without any problems, I used 7 segment display to monitor the results. Tomorrow I will order the rotary encoder, and see if it also works as I intended...

    This method prevents double stepping each time the nob is rotated, try it guys, and tell me what is your experience like...
    Last edited by crematory; - 9th September 2005 at 21:50.

Similar Threads

  1. Quadrature encoder and ASM Interrupts. questions..
    By godfodder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th March 2013, 15:45
  2. Calculate Distance Using Rotary Encoder
    By guanerrr in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 4th May 2012, 17:40
  3. Rotary encoder help (not 'counting steps)
    By Elnino in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th October 2009, 23:03
  4. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 22:56
  5. Automotive quality rotary encoder
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th October 2004, 16:46

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