Repository navigation
Replies: 3 comments 2 replies
|
Timing is correct with the MSP432 driver I am currently working on, could be a driver issue?
I'll check with a STM32F7 dev board later, the H7 code is derived from that driver. |
|
You were right — it was a driver clock issue, not the AMASS logic itself. Found it by diffing against the STM32F7xx driver (this H7 driver was ported from it, as you guessed): STM32F7xx (correct): STM32H7xx (this project, before fix): The hardcoded 240000000 is HCLK, not PCLK1. On this clock tree, PCLK1 = 120MHz (HCLK/2 via D2PPRE1), and the APB1 timer kernel clock is PCLK1×2 = 240MHz (confirmed directly in the STM32CubeMX clock diagram: "To APB1 Timer Clocks" = 240MHz). So hal.f_step_timer was computed as 240,000,000×2/4 = 120MHz, exactly double the real post-prescaler counting rate of 240,000,000/4 = 60MHz. Fix: I also directly measured this with a hardware cycle counter (DWT->CYCCNT) timestamping actual step pulses in _stepper_step_out(), independent of any planner/AMASS math: F20 (AMASS level 3): measured 15.00ms/pulse vs 7.4995ms predicted — exactly 2.00x Both of your points about the AMASS #if/#else and the steps.value/step_event_count scaling were correct too — I traced through the Bresenham math by hand at both AMASS levels and it's self-consistent regardless of level, not the cause. Fix confirmed on real hardware — motion now runs at the actual commanded feed rate. Thanks for pointing at the driver instead of the core logic, that's exactly where it was. |
|
Hi, thanks for reporting. I'm not able to replicate this in the upstream H7xx driver, is there a difference in your clock setup? The step timer is set here from PCLK1, and confirmed as 60MHz on both H723 and H743 boards. @terjeio I will increase STEPPER_TIMER_DIV from 4 to 6 in the next commit if you feel it's safer to bring it down to 40MHz. |
Uh oh!
There was an error while loading. Please reload this page.
Actual motion time is exactly 2x the planner-predicted time on segments that fall into AMASS level 3 (step rate < 2000 Hz)
Environment
$110/$111/$112=10000(max rate),$120/$121/$122=200/200/100(acceleration, mm/s²),$11=0.050(junction deviation) — all confirmed via$$to match the values used in the independent time model below.f_step_timer= 120 MHz (240000000*2/STEPPER_TIMER_DIV,STEPPER_TIMER_DIV=4).Summary
On isolated, single-line G1 moves with no acceleration/cornering ambiguity (entry/exit velocity essentially at rest, single axis or near-single-axis move), the actual elapsed motion time is consistently exactly 2.00x the time predicted by a from-scratch re-implementation of grblHAL's own planner formulas (
limit_value_by_axis_maximum, the junction-deviation cornering formula, and the standard trapezoidal velocity profile — all three verified line-for-line againstnuts_bolts.c/planner.cin thegnea/grblreference source and found to match exactly).The 2x factor appears specifically on moves whose step rate falls in the AMASS level 3 band (step rate < 2000 Hz, i.e.
cycles >= amass.level_3). A move at a step rate that falls into AMASS level 2 (2000–4000 Hz) shows no discrepancy (measured time matches the model to within measurement precision).Reproduction / measurements
Test rig: temporary instrumentation added to the firmware that timestamps (via
HAL_GetTick()) the momentplan_get_current_block()->line_number(i.e. the currently executing block) first reaches a given target line, for two adjacent single-line G-code moves, isolated from any lookahead ambiguity by running them from/to rest.G1 Z-1.19 F20(pure Z, 1.5 mm)G1 X4.5 Y25.25 Z0 F102(mostly Z, 3.6 mm)G1 Z0 F500(pure Z, 1.5 mm, same move as the F20 case, only F changed)Two wider multi-segment ranges (60–200 G1 lines each, dense/short segments, mixed feed 20–1330 mm/min) from a real finishing pass also showed the same ~2.00x ratio end-to-end, confirming this isn't an artifact of the single-line isolation:
What's been ruled out
$$)SPINDLE_LOAD_GUARD_ENABLE— project-specific feature, confirmed disabled at compile time, not linked in this buildENABLE_JERK_ACCELERATION— confirmedOff(default)plan_get_block_buffer_available()never approaches 0 during these moves; step generation is interrupt/timer-driven and consumes negligible CPUADAPTIVE_MULTI_AXIS_STEP_SMOOTHINGset to0(tested by editing the definition directly ingrbl.h, confirmed via a full Clean+Build that the change was picked up) — the exact same 2.00x ratio persists with AMASS completely disabled. This was surprising and is the main reason for this report — disabling AMASS does not fix it, but the bug's domain (only manifests at very low step rates) still strongly points at the AMASS-adjacent code.What I found while reading
stepper.cI don't have hardware-level (oscilloscope) confirmation of the mechanism, so take the following as "things I noticed that look suspicious", not a confirmed diagnosis:
st_prep_segment()(around what's currently ~line 1397-1407) computesamass_leveland doescycles >>= level; n_step <<= levelentirely inside#if ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING, with no#elsebranch. When the symbol is set to 0,prep_segment->amass_levelis simply never assigned in that call (relies on whatever was last in that segment ring-buffer slot / its0initializer). This alone seems worth a second look independent of my main question below.In block prep (around ~line 929-944), the per-axis Bresenham reference data is scaled unconditionally:
This scaling is fixed once per block (at
MAX_AMASS_LEVEL, i.e. 3, when AMASS is on). But at execution time,st.steps.value[idx] = st.exec_block->steps.value[idx] >> st.amass_levelis re-derived per segment, using that segment's ownamass_level(which, per point 1, can legitimately differ between segments of the same block as the feed profile ramps through different AMASS bands). Meanwhilest.step_event_countis copied from the block once, unscaled by any per-segment level (st.step_event_count = st.exec_block->step_event_count;, only on block boundary). For a segment landing on level 3,<<3 >>3cancels exactly against the fixed<<3denominator. For a segment landing on any level other thanMAX_AMASS_LEVEL, it doesn't cancel — I think this could produce a real proportion mismatch between the Bresenham numerator and the fixed-per-block denominator when a block's segments span more than one AMASS level, but I have not been able to fully trace the consequence to a confident conclusion (and it doesn't obviously explain why the disabled case — point 1 — also shows exactly 2x).Question
Is either of the above expected/compensated somewhere else I'm missing, or does this look like a genuine issue? Any pointers toward where to look next (or what to capture with a logic analyzer) would be very welcome — happy to provide the exact G-code test files, the from-scratch Python re-implementation of the planner math used for the "predicted" column above, or run further isolated single-line tests on request.
All reactions