Shop OBEX P1 Docs P2 Docs Learn Events
Anyone want me to leave the dual quadrature encoder driver in the OBEX? — Parallax Forums

Anyone want me to leave the dual quadrature encoder driver in the OBEX?

KyeKye Posts: 2,200
edited 2010-12-28 19:13 in Propeller 1
I made this object some time ago:

http://obex.parallax.com/objects/544/

However, I made a much better version of the driver which can do PID control also:

http://obex.parallax.com/objects/673/

While the dual version can do two encoders at once, I and other people have said that they have problems with it. I don't feel like maintaining it anymore as I no longer need it for anything so I'm thinking about taking it down from the OBEX. I am trying not to add clutter to the website.

Any replies on this would/ be great. Thanks,

Comments

  • lardomlardom Posts: 1,659
    edited 2010-12-27 09:10
    Kye, Thanks for your contributions to the OBEX. I've downloaded http://obex.parallax.com/objects/673/. I'm going to try to modify it to use the Parallax Serial Terminal since I don't know much about RS232.
  • KyeKye Posts: 2,200
    edited 2010-12-27 09:25
    It already works for the parallax serial terminal.
  • lardomlardom Posts: 1,659
    edited 2010-12-27 09:48
    Great. Now that I know it already works with the PST I found the baud rate, 250_000. :cool: Thanks again.
  • TappermanTapperman Posts: 319
    edited 2010-12-27 12:08
    Kye wrote: »
    I made this object some time ago:
    http://obex.parallax.com/objects/673/

    Any replies on this would/ be great. Thanks,

    I'm reading through your assembly in the encoder PWM1C_PIDEngine
                            cmp     encoderPrevious,  encoderCurrent wz        ' Update current state.
    if_nz                   rev     encoderPrevious,  #30                      '
    if_nz                   xor     encoderPrevious,  encoderCurrent           '
    if_nz                   cmpsub  encoderPrevious,  #2 wc, nr                '
    if_nz                   sumc    encoderPosition,  #1                       '
                            wrlong  encoderPosition,  positionAddress          '
                            mov     encoderPrevious,  encoderCurrent           ' Update previous state.
    

    And I'm having a little trouble with the manuals explination of the REV opcode. My question is "the way you use the REV opcode above is to reverse all the bits, except the carry ... is that correct?"

    ... Tim

    PS - I'm the one who had the question about 'JonnyMac's object, that you replied to ... BTW, thankyou for the input!
  • KyeKye Posts: 2,200
    edited 2010-12-27 19:50
    (Rev) reverses 32 - 30 = 2 bits in my code.

    So, it reverses the bottom 2 bits and zeros the rest.

    The tricky peice of code you see there does the work of all the code in the Parallax Quadrature Encoder Object in like ~8 lines versus arround 30+. (The grey code stuff)
  • kuronekokuroneko Posts: 3,623
    edited 2010-12-28 19:13
    @Kye: As this is one of your fully optimised OBEX contributions I challenge you to replace the three red instructions with a single one.
                    cmp     encoderPrevious,  encoderCurrent wz
    [COLOR="red"]if_nz           rev     encoderPrevious,  #30[/COLOR]
    [COLOR="red"]if_nz           xor     encoderPrevious,  encoderCurrent[/COLOR]
    [COLOR="red"]if_nz           cmpsub  encoderPrevious,  #2 wc, nr[/COLOR]
    if_nz           sumc    encoderPosition,  #1
    
                    wrlong  encoderPosition,  positionAddress
                    mov     encoderPrevious,  encoderCurrent
    
Sign In or Register to comment.