After a bit of digging, I found an old thread between a user named BlueGene00 and Luni:
https://github.com/luni64/TeensyStep/issues/139
BlueGene00 was doing the exact same project that I am doing, but I wasn't able to successfully contact him. From what it seems, I first need to implement no acceleration in the code. Whereas the original TeensyStep library implemented templates for different accelerators, the approach seems differently in TeensyStep4. I tried simply setting setAcceleration() to zero for all steppers but that didn't seem to work. I then went digging into the code to see if there was a culprit for setting the acceleration to 0 but couldn't find anything obviously suspicious (I probably missed it somewhere).
Is there any intent to implement accelerator templates into teensystep4? I'd be more than happy to be a guinea pig.
The hope is that if I get no acceleration working, I'd like to invoke a callback to the main function that runs the steppers with a step target matrix as per the discussion I linked above:
Code:
constexpr pos path[] = {
{3200, 3200},
{ 0, 0},
{5000, -1000},
{ 200, -3200},
{ 0, 0},
};
(This is an example from the discussion)
This is the function I was hoping to invoke in the callback:
Code:
void runMoco(){
for(int i = 1; i < NUM_KEYFRAMES; i++){ //change back to i=1 if testing with delta
//Serial.println("Keyframe");
for(int j = 0; j < NUM_STEPPERS; j++) {
int delta = kuper[i][j] - kuper[i-1][j]; //takes difference between current and next in STEPS
//Serial.println(delta);
prepareMovement(j, delta); //input: currStepper, steps
}
runAndWait(); //wait for all axes to finish keyframe(n) to keyframe(n+1) movement
}
}
The NUM_KEYFRAMES represents the rows in the first example, and NUM_STEPPERS refers to the specific stepper motor address as represented in the columns in the first example as well.
Now I recognize that to invoke the callback, I'll have to replace the nested for loop in place of an if() statement as per example 1:
Code:
if (p < pathLength)
{
sx.setTargetAbs(path[p].x);
sy.setTargetAbs(path[p].y);
ctrl.moveAsync(sx, sy);
p++;
}
This is Example 1's function that would be the parameter for the subsequent callback declaration:
Code:
ctrl.setCallback(onPositionReached);
I would love to get some advice on implementing the no-accelerator templates and callbacks for TeensyStep4.
Thank you for your time!