Encoder feedback inaccurate, how to change encoder direction

Status
Not open for further replies.

Ardillolambo

New member
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,
 

Attachments

  • E_Gear6.0.ino
    23.9 KB · Views: 52
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.
 
Status
Not open for further replies.
Back
Top