-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] 120Hz pulse at the beginning of each move/Classic Jerk not functional (?) #20150
Comments
So... no hope of getting into it any time soon? I'm willing to do whatever tests and measurements are needed for proper debugging. |
While I don't fully understand it, but I still think this should kept open. |
Keeping this open. |
Lets keep this open. |
From my point of view due to lack of interest this thread can be closed, I switched to Klipper firmware some time ago and I will not be able to test/reproduce anything. |
@descipher if you have ideas to investigate further don’t let me get on your way! I have a bit more time this weekend then will be back to work. I am wondering if this is possibly even correct behavior… it looks odd but maybe that is how jerk/acceleration constraints are met? |
The fact that it is present on various hardware/emulation targets means we should be looking in the stepper common code. The probe outputs are from default configs in branch bugfix-2.0.x. |
Well, I found where it is coming from. Understanding whether it is proper behavior or not is a harder question. void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor) {
uint32_t initial_rate = CEIL(block->nominal_rate * entry_factor),
final_rate = CEIL(block->nominal_rate * exit_factor); // (steps per second)
// Limit minimal step rate (Otherwise the timer will overflow.)
NOLESS(initial_rate, uint32_t(MINIMAL_STEP_RATE));
NOLESS(final_rate, uint32_t(MINIMAL_STEP_RATE)); In the stepper interrupt code, the timing between the first two steps is controlled by I'm not familiar with the planning code or what influences the |
I need to figure out whether these calculated acceleration/plateau numbers correctly correspond with this pulse train, or if there is an "off-by-one" error and we should be using our acceleration parameters between the first two pulses: Right now I'm thinking that |
I did correct a step calculation issue in my laser PR that still not merged. It related to this in some ways. Marlin/Marlin/src/module/planner.cpp Line 825 in 1874787
I had to change the deceleration calc or the planned step counts would be be 1 off. Marlin/Marlin/src/module/planner.cpp Line 830 in b867181
Here the decel point is not block->decelerate_after = acceleration_steps + plateau_steps it should be block->decelerate_after = decelerate_steps + plateau_steps;. e.g. with actuals of accel = 10, plateau = 20, decel = 9 we would get a total step count of 39 but when you do the calc based on the existing code its a total step count of 40 |
@descipher I just looked at your changes and left a comment on that PR. The new change doesn't seem right to me, but probably work in some cases. We could very well have several "off by one" errors in this code... |
OK, the current behavior is definitely incorrect. The step generation code assumes that we are actually accelerating during that entire 8.3ms between the first two steps, which causes a huge acceleration spike on the third step, followed by an early arrival at our coasting speed. With the current code, we don't accelerate or decelerate at all between the first two steps, we only maintain the entry speed. I've modified the code to actually calculate the step timing according to the desired acceleration. Using that I was able to generate plots comparing the current code to my "hopefully more mathematically correct" modifications. I think the charts speak for themselves. NOTE 1: This is currently only a prototype. I am probably doing too much math in the stepper ISR, and more work will be needed to solve this properly. NOTE 2: I'm comparing trapezoid acceleration here, but the same problem exists for S-Curve. NOTE 3: The timing of velocity reaching zero is an estimate. The Pulses stop at the last non-zero velocity, and I've estimated an extra timestamp to allow me to estimate the acceleration as we come to a stop. This is just a guess, and it looks like we still might be stopping a little too abruptly. We may need to start decelerating one step sooner than even my new changes. |
The charts above are from a |
I just wanted to say that I'm happy that this is being worked on and it's good to hear that my initial observations were correct! |
Definitely concur with your findings, the issue I see is the first step has already occurred in pulse_phase_isr e.g.
I still see more issues in the output. The deceleration in this capture is not right, checking further. |
Just a quick update for anyone watching this. @descipher and I have been working together on this and sharing ideas. We have a few ongoing experiments which show promise. There is a lot of intricacy in these bits of code so progress is slow. So far we have only explored fixing trapezoidal acceleration. Additional work will be needed to apply similar changes to S-Curve. |
That initial 120 now labeled as |
Based on my tests if the step rate value is too small issues will surface, such as the timer continuously overflows or the accel formulas fail with 0. |
Is this issue still relevant to the latest code? |
Unfortunately I think it is, will verify this weekend and update. |
This might have been fixed with some linear advance rework last year? Was that @tombrazier? |
Thanks for double-checking @descipher. I’ll close it out! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Description
I've been trying to write a small piece of software, which in part reads the STEP/DIR signals generated by Marlin.
To properly test that, I bought myself a logic analyzer and I have found something weird.
No matter that are the acceleration, jerk or speed settings, if I have
S_CURVE_ACCELERATION
orADAPTIVE_STEP_SMOOTHING
enabled or whatever - one, single pulse is always generated 8.33ms (=120Hz) before the rest, "normal" pulses are generated.Below you can find some pictures:
Series of 10mm moves
Closeup of one of those moves
I have tested Jerk set to 0, 4 and 10mm/s with accelerations 300 and 1000 mm/s2.
I'm running Marlin Bugfix from 08.11.2020, but the same thing was happening on 2.0.3.
I did not try it with
Junction Deviation
as it is not working very well for me (extruder).My board is a custom one, based on the LPC1768 uC and stepper motor drivers are TMC2208.
On the other hand, I have noticed that the frequency of subsequent pulses does not change with different
Jerk
values, which is weird, because I would expect them to immediately jump to frequency which results fromSteps/mm
andJerk
values.I've talked about this issue with @sjasonsmith on discord and he said he has seen these weird pulses on a STM32 board.
Configuration Files
config_files.zip
Logs
Measurements from the logic analyzer are also attached. You can open them with Saleae Logic 1.2.18 software.
Naming of the files:
[Adaptive_step_smoothing] [S_Curve_Acceleration] [acceleration] [jerk] [speed]
logs.zip
I can do more tests/measurements if needed.
The text was updated successfully, but these errors were encountered: