Shop OBEX P1 Docs P2 Docs Learn Events
Digital Encoders — Parallax Forums

Digital Encoders

Greg LaPollaGreg LaPolla Posts: 324
edited 2010-06-17 14:54 in General Discussion
I have been working on a project using a digital encoder. I am using the Quadrature Encoder from OBEX. The spec sheet for the encoder is attached. I have the 288V232R161B2.


CON
   
  _clkmode = xtal1 + pll16x                             ' Crystal and PLL settings.
  _xinfreq = 5_000_000                                  ' 5 MHz crystal (5 MHz x 16 = 80 MHz).

OBJ
  Encoder : "Quadrature Encoder"
   pst    : "Parallax Serial Terminal"                   ' Serial communication object         

VAR
  long Pos[noparse][[/noparse] 3 ]


PUB Main | value, prev 

  Encoder.Start(0, 1, 1, @Pos)                          'Start continuous two-encoder reader (encoders connected to pins 8 - 11)
  pst.Start(115200)
  pst.Str(String("Encoder Reading"))                 ' Heading
  pst.Chars(pst#NL, 2)                                    ' Carriage returns
  prev := 99                                                   'Set it to something it wont be for the first loop through so it will be displayed   
  repeat
    value := Pos[noparse][[/noparse]0]                                          'Read each encoder's absolute position 
    if value <> prev                                          
      pst.Dec(value)                     
      pst.Chars(pst#NL, 2)                               ' Carriage returns
    prev := value




It always reads 0. I have pins a & b pulled up to 3.3 volts using 10K resistors. pins a & b are also attached to pins 0 and 1 on the prop. Pin C goes to ground. I don't think I am understanding the quadrature encoder documents fully. Any help or insight is much appreciated!


Thanks

Greg

Post Edited (Greg LaPolla) : 6/17/2010 1:35:50 AM GMT
288.pdf 213.6K

Comments

Sign In or Register to comment.