QEI Hardware Quadrature Encoder Inputs PIC 18F4431


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818

    Question QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    I am trying to get my head around this Data Sheet, and I don't get it.
    The DS refers to A POSCNT / MAXCNT registers. Am I correct that the counts of the QE are stored in those registers MAXCNTL , MAXCNTH . . . just the same as they would be in a software variable and then I can change or clear their value with software commands ?
    And if not, where is the advantage of the QEI hardware?
    Thank You
    JS
    Last edited by Archangel; - 5th July 2011 at 03:04.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    Hi,
    No, POSCNT contains the actual count. MAXCNT controls how "far" POSCNT counts before rolling over. That way you can have it wrap around at 1000 or 2000 or 34567 instead of 65535 if you want.

    The interrupt flag gets set whenever it rolls over, going in both directions.

    /Henrik.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    No, POSCNT contains the actual count. MAXCNT controls how "far" POSCNT counts before rolling over. That way you can have it wrap around at 1000 or 2000 or 34567 instead of 65535 if you want.

    The interrupt flag gets set whenever it rolls over, going in both directions.

    /Henrik.
    Ok, I have been looking at your answer for about 3 weeks, and it has taken most of that time to understand what you said, mostly because it addresses my problem, not my question.

    I was having "difficulty" getting MCS and PBP tp accept any input into those registers. To summarize what you posted so you know I understand, POSCNT tracks the number of changes and distance from zero counts and MAXCNT "SETS" the number of counts before rollover, almost like preloading a timer, except opposite.

    I resolved my difficulties by reinstalling MCS Pro, Oh and using POSCNTH & POSCNTL as there is no actual POSCNT listed in the P18F4431.inc . When I assemble a good working encoder example I will post the code.

    And Henrik, Thanks for the nudge !
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    Hi guys,
    I'm running into some of the same questions. From what I can tell, you can't preload POSCNTH or POSCNTL. Another item that puzzled me is that the datasheet mentions that MAXCNT value is 1527h. I can't figure out how they arrived at that figure.

    I'm trying to do as simple encoder for menu sleection and would like to set POSCNT in the middle so that I don't have to mess with rollover in either direction. I realize that it would be easy enough to deal with, but this gives me a chance to try and figure out how to use this darn feature. I'm trying to prove to myself that there is a good use for it. So far, it has been more of a pain than it is worth.

    Mark

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    Hi,
    From what I can tell, you can't preload POSCNTH or POSCNTL
    Sure you can, I find no problems doing that.

    Another item that puzzled me is that the datasheet mentions that MAXCNT value is 1527h
    Not sure where you got that number from but MAXCNT is setable to anything between 0 and 65535.

    I'm trying to do as simple encoder for menu sleection and would like to set POSCNT in the middle so that I don't have to mess with rollover in either direction
    MAXCNTH = 128 works just fine here.

    Code:
    Test:
      HSEROUT["Program start",13]
      HSEROUT[DEC PosCntH*256+PosCntL,13]
      Pause 10
      PosCntH = 128
      HSEROUT[DEC PosCntH*256+PosCntL,13]
      PosCntL = 1
      Pause 100
      HSEROUT[DEC PosCntH*256+PosCntL,13]
    Program start
    0
    32768
    32769
    /Henrik.

  6. #6
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: QEI Hardware Quadrature Encoder Inputs PIC 18F4431

    Thanks Henrik,
    I'll explain a bit further: I can load POSCNTH and POSCNTL, and they show up as correctly loaded, but as soon as the encoder moves, it jumps back to 5535 and rolls to 0 from there.
    I can change MAXCNT, but that doesn't put it in the middle of the count range and avoid the rollover.

    The reason I asked about MAXCNT value of 1527h is that it is mentioned in the datasheet, on page 173, note 5, and I thought it is a strange number.

    Like I said, there are obviously ways around this, I'm just trying to understand it better.

    Thanks
    Mark

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts