Get current position in real-time
-
In Marlin firmware, I could get the current position of an extruder with this function:
y = float(st_get_position(Y_AXIS)/axis_steps_per_unit[Y_AXIS]) ;Is there the same thing in Duet firmware? I would like it to get the current position even if it is in the middle of a straight move. For example, If it is as X0, and it is traveling to X100, then when it triggers a sensor, I would like to know the current position of each time it is triggered during that move.
-
@jml I guess you could poll the stepper counts from the object model, but the response time would vary, so there is a big uncertanty.
All you'd know then is "the axis is at least at position nnnnn"
If there was a timestamp telling when exactly the current move started, you could calculate the position from knowing the (static) jerk, accel and requested speed numbers.
But some moves are so short, IDK if that would be a good solution. -
@jml I believe it's been added to the object model in one of the 3.5 betas
-
@jml
You could read move.axes[].machinePosition inside your trigger.
I'm not sure if there would be any lag between when the trigger event occurred and the object model reading was taken. -
@jml the previous two replies have got it right between them. IN RRF 3.5 the machine position in the object model is updated every 200ms during moves.