HEDS5540 optical encoder


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: HEDS5540 optical encoder

    easiest way


    Code:
    Flag var byte
    wsave VAR BYTE    $70     SYSTEM  ; alternate save location for W 
    enc_new VAR BYTE
    enc_old VAR BYTE
    enc_counter VAR WORD


    Code:
    asm    
    
        ;Read latest input from PORTB & put the value in _enc_new.
             MOVE?CB    1 ,_Flag
             movf    PORTB,W
             movwf  _enc_new
    
             ;Strip off all but the 2 MSBs in _enc_new.
    
             movlw    B'11000000'    ;Create bit mask (bits 7 & 6).
             andwf   _enc_new,F         ;Zero bits 5 thru 0.
    
             ;Determine the direction of the
    Last edited by richard; - 2nd October 2016 at 22:58. Reason: CASE SENSITIVE
    Warning I'm not a teacher

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: HEDS5540 optical encoder

    Richard's way is the best. Just for referece it could also be done without asm since its not time sensitive.

    Code:
    old_enc_counter var word
    Main_Loop:   
      
    if enc_counter<> old_enc_counter then 'If change update LCD
    Lcdout $fe, 1                    
    Lcdout Dec enc_counter     ; display counter value on LCD
    old_enc_counter = enc_counter
    endif
    goto Main_Loop
    end

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: HEDS5540 optical encoder

    hmm, I try it and no change, still only the "encoder test" message on the LCD.
    This line is ok MOVE?CB 1 ,_Flag what means the question mark.

Similar Threads

  1. 2 Beam Optical Pulse Generator
    By WOZZY-2010 in forum Schematics
    Replies: 8
    Last Post: - 6th April 2010, 04:03
  2. USB Optical mouse as motor encoder
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th August 2008, 15:09
  3. optical voice link
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th May 2008, 21:11
  4. Using a optical coder
    By debutpic in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 16th October 2007, 04:57
  5. Using the optical sensor from a ball mouse
    By lsteele in forum General
    Replies: 5
    Last Post: - 5th September 2007, 16:45

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