I originally tried moving them using the accelstepper library but they moved far slower than simply stepping myself.
I would to add another axis of movement by adding another stepper motor that is controlled by a tmc5160. Is it possible to move all 3 of these motors at the same time? The new motor would be moving a slower rate than the other 2 motors and would stop earlier also.
I have a general idea based on timing it, but the rest of my code would be too large and across a too many files to post on here. This is the code that's relevant to my question though.
sterisk:
I have a general idea based on timing it, but the rest of my code would be too large and across a too many files to post on here. This is the code that's relevant to my question though.
I am certainly too lazy to study a long program. Perhaps you can incorporate the code in Reply #2 into a short complete program just for learning purposes. Long programs are not good for learning.
So right now I'm using a Nema 23 and I have 10 microseconds between pulses based on my original code, with a cl57t as my motor driver. Is there a way to calculate my step rate with these variables?
EDIT: So I'm running my motor driver at 800pulses/rev, and my nema 23 is 200steps/rev. And so I have 10 microseconds between steps.
Do you know about an upper limit for using multistepper? I recalculated my desired steps/sec to be ~40000 to match the 3000rpm I get from my original code, but it doesn't seem any faster than the 13333 from my earlier post.
The problem is that the library uses floating point maths which is slow on a 16Mhz Arduino
If you need higher step rates then you will have to write your own code. Have a look at the second example in my Simple Stepper Code as a starting point.
Using the digitalWriteFast library will allow considerably faster code and it is as easy to use as the standard digitalWrite() and digitalRead(). I have used a Hardware Timer and the digitalWriteFast library to get step rates of about 25,000 per sec from a Mega. The very carefully optimised GRBL program can go a bit faster - up to 35,000 IIRC.
Your example looks like you're only running a single motor, but with my code I'm trying to run 3 stepper motors simultaneously. So would that be a major bottleneck for writing my own code?
sterisk:
Your example looks like you're only running a single motor, but with my code I'm trying to run 3 stepper motors simultaneously. So would that be a major bottleneck for writing my own code?
Running 3 motors should add relatively little to the code. My own personal project can drive 4 motors for a small CNC machine.
You have not told us what project you are trying to create or how the movements of the motors relate to each other or anything that would help us better to understand your problem. Give us the big picture.
My motor driver is set to 800steps/rev, so when multiplied with 1000rpm, and divided by 60, I get 13,333.33 steps/sec.
I see your driver doesn't let you go below 800 steps/rev. To get your higher terminal RPM, you would possibly look at different drivers, like TB6600 with a min 200 steps/rpm => 3,333 steps/sec.