Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Encoder feedback inaccurate, how to change encoder direction

  1. #1

    Encoder feedback inaccurate, how to change encoder direction

    Hi

    Working on a paddle shifter for a manual transmission.

    Using a linear actuator with encoder and an Arduino Due board.

    The code is doing what I want, the linear actuator will move in the desired direction, but is not stopping consistently in the same "spot"

    For some unknown reason, the position feedback from the encoder is not accurate and is inconsistent, in order to solve that issue, I decided to include on the code a "compare" with current position Vs. Previous position, if they are different write previous position to current position, but it gets lost the original motion direction (CCW vs CW) of the encoder. Is there a way that direction can be changed when the write() command is used? Please check ReadHorizontalPos() routine in the attached code.



    Another thing....can't figure out why my set up() routine needs to be loaded at least three times to work properly.


    Regards,
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,578
    What is the intent of using ABS on the encoder result? That will eat the direction information.

    Also with needing to load setup do mean the download process fails 66% of the time, setup() specifically you are having to call additional times, or is it that setup stalls at some unknown point?

    If it's outright failure thats tricky given not that many people here have Dues being a teensy forum, but would suggest confirming you can load blink, and possibly serial and EEPROM examples (plus anything else you think might be hanging the startup process). You can also use spare pins and LEDs to observe the setup stepping through looking for which command causes trouble.

Posting Permissions

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