Issues with AMS AS5600 - Teensy 4.1

jayd99

Member
Hi, I’m currently working on a project where I need to control 2 steppers using a Teensy 4.1, two TMC2208 and two AMS AS5600 magnetic encoders. We’re currently having issues where, sometimes the encoders will return the same (wrong) value over and over, even after moving to different positions with the steppers. I wanted to write here to see if some people ran into the same issue as us. Unfortunately, I can’t give you the whole source code since it’s a confidential development project, but I’ll try to give you as many details as possible.

Example:
Let’s use 2 steppers named YStepper(linear axis) and CStepper(rotative axis).
-Move Ystepper to 120mm using steps, counter verifying with the encoder, encoder returns 120mm which is okay.
-Move Cstepper to 90degrees, counter verifying with the encoder, encoder returns 90deg which is okay.-
-Move Ystepper back to 0mm, counter verifying with the encoder and now Y is 20mm and C is 156 degrees (which is not true). And they will keep giving back theses values until we reboot or reupload.

Things to know:
-AMS AS5600 works on I2C with the address 0x36 which isn’t modifiable so we’re using Wire0 and Wire1 of the teensy 4.1 to avoid address conflicts.
-We’re using AccelStepper library to control our steppers with STP, DIR and EN signals.
-The whole point of the encoders is to validate that the axis are really at the position they claim to be after moving using STP signal.
-We need to poll the encoder value periodically while the stepper is turning because of our reduced gears ratios. We wouldn't wanna miss the encoder going from 4096 to 0 and not know if we've made a complete turn or just haven't moved.

The issue seems to happen always and only after using the 2 steppers. Moving only Ystepper will never cause the issue. Moving only Cstepper will never cause the issue.

After doing some research on different forums, I've seen many people talking about interrupts for I2C messages, the AS5600 using interrupts for every pulse and the AccelStepper Library using interrupts. Could all these interrupts mess our timing? Do Wire0 and Wire1 use the same interrupts?

I know it's a complex problem and I can't really give any schematic or code snippet. Don't hesitate to ask questions, I'll answer all of them and try to be as precise as possible. Also just give me a heads up if post about a confidential project isn't really permitted here due to the lack of documentation.

Best regards,
Jeremy
 
Have you ruled out hardware issues like crosstalk, ground loops, poor layout? I'd suspect that in the first instance, especially if external cabling is long.
 
Yes, electrical issues have been ruled out. It seems like the encoder stops returning the right value when it happens to go over 4096 and fall back to 0..
 
Yes, electrical issues have been ruled out. It seems like the encoder stops returning the right value when it happens to go over 4096 and fall back to 0..

Well, that's suspicious, and makes it sound more likely a software issue, but it's hard to guess what might be wrong if you can't share any details. It might be useful to create a test program that does nothing but configure and read the AS5600 encoders, and maybe you could get permission to share that code and its results. The link below is for a library that looks good, was just updated two days ago, and has an example for two encoders, one each on Wire and Wire1.

https://github.com/RobTillaart/AS5600
 
Hey guys,
quick update to tell you we've found the issue. Everything was related to our TMC2208s having a VREF set higher than 1V... It seems to cause the stepper to skip steps or stall make our code crash... The encoders are on and everything seems to work just fine now.
Thanks for your help
 
Back
Top