Shop OBEX P1 Docs P2 Docs Learn Events
Quadrature Encoder Object question... — Parallax Forums

Quadrature Encoder Object question...

Chris_DChris_D Posts: 305
edited 2009-03-21 12:45 in Propeller 1
Hi guys,

I have a question about the quadrature encoder object I am hoping someone can answer.· I would like to know if there is a way to reset the counters to zero?· I thought I could just set the variable to zero but that didn't seem to work out very well.· Apparently the object somehow prevents this from happening.

Chris
·

Comments

  • telluriantellurian Posts: 52
    edited 2009-03-15 23:11
    I remember doing something like that a while back. I had to add a method tho the encoder object. Try this method:

    PUB Clear
    'clears all of the encoder values (i.e. a reset)
      longfill(Pos, 0, TotEnc+TotDelta)
    
    



    -tellurian
  • T ChapT Chap Posts: 4,223
    edited 2009-03-16 01:32
    Just stop and start the cog, that's what I ended up with.
  • Chris_DChris_D Posts: 305
    edited 2009-03-16 10:36
    Yeah, I know I can start and stop it, but I was hoping for a way to clear just a specific variable.· Tellurian, I will give your method a shot and see if I can manipulate that into doing exactly what I want.



    Thanks guys!

    Chris
  • Richard S.Richard S. Posts: 70
    edited 2009-03-19 16:07
    See· http://forums.parallax.com/showthread.php?p=720621I have done what you are asking about, resetting an individual axis while preserving the other values.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard in Michigan
  • Chris_DChris_D Posts: 305
    edited 2009-03-19 22:21
    Richard,



    Thanks very much for the link - I have downloaded your code and will certainly incorporate this feature!!!



    Chris
  • Jeff MartinJeff Martin Posts: 760
    edited 2009-03-21 12:45
    Gentleman,

    You should not need to reset the counter, and in fact if one were to achive resetting it outside the·cog that is reading the encoder(s), you'd be possibly creating a slight error (if the counter changed at a critical time in the read/write sequence of the encoder cog).

    For this reason, the Quadrature Encoder cog does not allow resetting the counter and, instead, provides a much more useful feature... Delta tracking.

    Simply call ReadDelta() every time you want to know how much the encoder has moved since the last time you "looked"... it provides a signed value, so if it moved backwards, you'd get a negative number.· If it hasn't moved since the last time you called ReadDelta(), then it returns 0.

    Read item 4 of "To use this object:" at the bottom of the code.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Jeff Martin

    · Sr. Software Engineer
    · Parallax, Inc.
Sign In or Register to comment.