Okay. I've run the timing tests for stepped splines.
I originally tested using int64_t computations for position and velocity; It added ~2K in code, and the overhead, compared to a 48 bit hand coded addition algorithm, was ~10x slower; I suspect gcc uses function calls rather than inlining the instructions (8 adc instructions seems more than adequate, but I did not take a look at the assembly to see what GCC was doing.)
My next steps on firmware front:
1. add protocol to allow transmitting splines to firmware.
- I've talked about making this a 'forth' like syntax. I think I'm going to back off of this for the time being; KISS, and all that.
2. Add protocol to reset and home all motors.
3. Hook stepper drive to step spline output.
Main loop on firmware will be extremely simple; I'm guestimating an overall loop rate of 2000-5000 per second, which should be adequate to drive all steppers at at 100-150 RPM or higher. Hopefully, this translates into a fast enough print speed for the majority of area on my RepolaRap...
For those interested, here's the data structure for the stepped spline:
struct CubicStepSpline
{
uint32_t positionFrac;
uint32_t velocityFrac;
int32_t accelerationFrac;
int32_t jerkFrac;
int16_t velocityUnit;
int16_t positionUnit;
CubicStepSpline( int64_t position, int64_t velocity, int32_t acceleration, int32_t jerk );
int16_t get_Position() const { return positionUnit; }
void Step();
};
The Step function simply does:
position += velocity;
velocity += acceleration;
acceleration += jerk;
The numbers use 32 bit fixed point representation; which means, to return the position value, you return the top 16 bits of the 48 bit number.
To translate this to stepper motion, I'll just record the current position of each stepper, the target position in the stepped spline, and incrementally step until the two numbers match. Once all steppers match, I'll advance all splines to the next position.
I find this appealing because computing the next spline takes time. That time translates to delay between motor steps. The splines may need to step several times to translate to a single step on a motor. The host can compute a specific position/velocity/acceleration/jerk profile. Knowing the average 'main loop' time, hardware capabilities, etc. should allow the profiles to approach hardware limitations without crossing them, I.E, accelerating thru corners (acute angles would slow down more than obtuse angles, for example). I'll look forward to see if this actually becomes a reality.