Author Topic: Quadrature detector code  (Read 2214 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Quadrature detector code
« on: November 29, 2020, 01:38:04 am »
Coding for a quadrature detector. Scroll wheel stuff etc.
The two inputs are PinA and PinB

START:
DO
IF PinA% = 0 then EXIT DO
LOOP
   
DO

IF PinA% = 1 and  PinB% = 0 then scroll% =   1 : GOTO START
IF PinA% = 1 and  PinB% = 1 then scroll% =  - 1 :GOTO START

LOOP

****
scroll% is updated  on the  transition of PinA = 0 to PinA = 1
The code also detects transition of PinA = 1 to PinA = 0

« Last Edit: November 29, 2020, 03:32:39 am by NOVARSEG »