Quadrature Encoder Object

Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on print
Table of Contents

These three source code examples interface a quadrature encoder clock, data and button signals to the Propeller 2. The first two versions are useful for seeing the internals of the encoder signals, but the third version is a demo with its own encoder object. 

  • Rotary_Encoder_Demo1_Archive.zip – read a quadrature encoder with Spin2 and PASM
  • Rotary_Encoder_Demo2_Archive.zip – read a quadrature encoder with Spin2 and a more advanced PASM that keeps track of prior positions
  • Rotary_Encoder_Demo3_Archive.zip – puts the encoder into its own object

The encoder object and terminal (which may be Parallax Serial Terminal or ANSI-Compliant) are started in this method:

pub setup()

  enc.start(ENC_A, ENC_B, ENC_BTN, enc.DETENT, 0, LO, HI)       ' start encoder

  term.tstart(BR_TERM)                                          ' start terminal serial

The object used in the third example has a complete encoder configuration for the low and high range and button states. The output from Parallax Serial Terminal looks like this:

Programming Language
Tools and Operating System
Document Author
Source Code Author
Table of Contents
0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Copyright © 2021 Parallax Inc. All Rights Reserved
Designed and Made in California, USA