BIG NEWS: the stepgen of Litex-CNC is finally stable!
I took nearly a full re-write of the stepgen code to find the errors:
- the stepgen supports S-curve acceleration, although the current implementation does not use it. By creating this modification it turned out that in some corner cases the apply-time in the FPGA can be overwritten by the next packet. This mainly affected systems with high amount of jitter. This has been solved in the FPGA firmware, which copies the apply-time to a local register, i.e. a kind of queue with space to buffer one full cycle.
- the apply time is designed to be 0.9 x period after the start of the current cycle. The motmod should be fed with the predicted position at the next apply time. Problem here was jitter: the position could not be determined with high enough precision. This resulted in the stepper not running as smooth as I wanted (my benchmark is the LPT port, should be equal or better). Also I discovered there is a clock drift between LinuxCNC and the FPGA. To solve this, the amount of clock-cycles is averaged over 10 cycles. This average is used to calculate the amount of clock-cycles per cycle and prevents overshooting the commanded position. It is safe-guarded that the apply time is always within safe limits.
- the algorithm is now basically the same as the stepgen of LinuxCNC, with some modifications to improve accuracy (I could recommend those changes also to the regular stepgen).
My sincere apologies that this took too long. This was more difficult then I anticipated, due to the errors being in multiple layers.
That said: this never more (but in a positive way). Before I merge the branch
stepgen_improvement I'm going to split the current stepgen into two parts:
- the actual stepgen, part of LitexCNC which is responsible to translate a commanded speed to a command to the FPGA to produce steps.
- the translation from motmod's position command to a velocity that can be used by the stepgen. This will be a separate component (pos2vel).
This approach has as a benefit that I can still work on developing S-curve acceleration on a separate component in the future, whilst for regular applications Litex-CNC can be still used. The other benefit is that the component
pos2vel can also be used for the other implementations of the colorlight cards.
@
Xu: If Google translate works well, the answer is 是的 (yes).