Differential encoder ASM input routine

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Differential encoder ASM input routine

8,307 Views
Encoder
Contributor I
I have seen some samples of keyboard and LCD drivers in ASM on application notes, and I have been using those components for years. Now we are planning to substitue keybord with a differential encoder.
 
Do anybody knows of some example of polled or interrupt driven ASM routine for input from a low-cost differential encoder? That one with 3 lines and a separate pushbutton. Slow response is required: I think some 20-40 pps is enough.
 
Thanks
Encoder
Labels (1)
0 Kudos
Reply
5 Replies

911 Views
BobMac
Contributor I

Good Day Encoder! I have just the solution for you.

 Go to www.amqrp.org/kits/micro908/index.html

There you will find a product description for the "Micro908". Download the software labeled "aav5.1a and af1.2d" in the "drivers.asm" routines you will find all the peripheral i/o routines you can think of!

Best regards Bob

0 Kudos
Reply

911 Views
bigmac
Specialist III

Hello Encoder,

I assume that by "differential encoder" you actually mean a rotary encoder or quadrature encoder.  If so there has been considerable recent discussion on the following thread in the 16-bit forum.

http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=398

Regards,
Mac

 

0 Kudos
Reply

911 Views
Encoder
Contributor I
Thanks Mac.
It was exactly what I was searching for and the discussion, whilst in the 16-bit forum, was very general.
 
Everything said was very reasonable, unfortunately the code lines were few, even if the only code was for HC08! Thanks, Rocco.
 
If someone has other examples, welcome...
 
Encoder
0 Kudos
Reply

911 Views
sungam
Contributor I

Hello, Encoder

Here is some code i have used once for the JL3.

Sungam

; Theese bits are in ram-variable flags:
new          equ  0     ;indicates that rotationalencoder has changed
direction    equ  1     ;moving direction for the encoder
oldstate     equ  3     ;stores the oldstate for the encoderinput
                       ;so the ISR can determine if it has changed state

       org     flash
main       
       ....
       jsr   init_timer
       cli
       
       ....
**************************************************************       
;       example that changes var when encoder has changed
       
       brclr   new,flags,done
       bclr    new,flags   ; indicate that we have picked up the change
       brclr   direction,flags,decvar
       inc     var
       bra     done
decvar       
       dec     var
done

**************************************************************
Init_Timer:
      mov   #%00110110,TSC     ; Timer 1 - Cleared + Stopped.
                         ;    Clicks once every 64 BUS Cycle
                         
      clr   tmodh
      mov   #93,tmodl    ; tof after 94*64 cykles = 1.0027ms


      mov   #%01000110,TSC     ; Start the timer, tof aktiv
      rts
**************************************************************  
; TOF interrupt happens every 1ms

T_ISR:
      pshh
      lda   tsc
      and   #%01111111
      sta   tsc       ;clear tof
      lda      ddra
      psha
      bclr     0,ddra          ;encoder connected to PTA0, PTA1
      bclr     1,ddra
      nop
      nop
      brclr    0,porta,enc_low
      brset    oldstate,flags,done_encoder ;no change since last time?
                                           ;if so we're done
      bset     oldstate,flags              ;position has changed
      bset     new,flags                   ;new indicates new position,
                                           ;main program must clear this flag
      brset    1,porta,setdir              ;after it has read it
      bclr     direction,flags
      bra      done_encoder
setdir
      bset     direction,flags
      bra      done_encoder
enc_low
      bclr     oldstate,flags
done_encoder
      pula
      sta      ddra
done_tisr:
      pulh
      rti

0 Kudos
Reply

911 Views
Encoder
Contributor I

Thanks a lot Sungam and Mac. :smileyhappy:

Encoder

0 Kudos
Reply