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
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