Author Topic: Quadrature detector code  (Read 150 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Regular
  • Posts: 174
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 »