Contact me: hankecnc@gmail.com

潜在的步骤损失 #1293

推推 grbl 3年前 (2023-01-23) 212次浏览

关闭
adichell 打开了这个问题 2017 年 9 月 29 日 · 5 条评论
 Closed

Potential loss of steps#1293

adichell opened this issue on Sep 29, 2017 · 5 comments

注释

潜在的步骤损失 #1293

嗨,
我正在分析步进器代码,在 st_prep_buffer 函数中我认为可能存在导致步数丢失的问题。
如果我没记错的话,在这个函数中,当前块的段被缓冲,然后 mm_remaining 变量被更新。
假设我们正在执行一个块的最后一步段,这个函数计划它们,然后它更新 mm_remaining 并在函数结束时它进入检查的 else 分支:
if (mm_remaining > 0.0)
在这种情况下,当前块被丢弃并且最后的步骤没有执行。

这通常不会发生,因为在更新 mm_remaining 变量和此检查之间的处理器速度和操作数使得有足够的时间触发定时器中断和执行步骤。
但是,如果您要更改处理器(速度)和/或优化代码,则可能会出现此问题。

我建议在 else 分支中添加一个检查,并最终像这样超时:

else { // End of planner block // Check if there is any segment pending to be executed before discarding block volatile int index = 0; while((segment_buffer_tail != segment_buffer_head) && index < TIMEOUT_COUNTER){index++;} // The planner block is complete. All steps are set to be executed in the segment buffer. pl_block = NULL; // Set pointer to indicate check and load next planner block. plan_discard_current_block(); }

最好的问候,
A.

潜在的步骤损失 #1293
成员

不,你误读了代码。步骤段设置为在其头指针在 mm_remaining 行之前更新时执行。在将最终步骤放入段缓冲区后,规划器块将关闭。他们总是被执行。

潜在的步骤损失 #1293
作者

我同意“步骤段设置为在其头指针在 mm_remaining 行之前更新时执行”。它被设置为执行,然后步进器 ISR 被触发,它看到有要执行的步骤并执行,正常。

但是想象一下,处理器执行代码的速度非常快,将 mm_remaining 设置为 0(我说的是最后一步),并且在触发 ISR 之前进行检查。会发生什么?

潜在的步骤损失 #1293
成员

The steps would sit in the step segment buffer until the ISR comes around to service it. I’m failing to see what you think is a problem. I think you are misinterpreting the code. The planner buffer is independent of the step segment buffer. Everything in the step segment buffer is always executed.

潜在的步骤损失 #1293
Author

Yes, you are right about this, the steps would sit in the step segment buffer, I was wrong about this, you would not lose it.
The effect would be the system to go in idle, and then these steps would be executed during the execution of the next planned block.
I still think this is a potential issue, but different from losing steps.

Best regards,
A.

潜在的步骤损失 #1293
Member

不,它也不会闲置。step segment generator的时序设计为只要求它不饿死。更快的处理器只会有所帮助。以后,请尝试提出与可跟踪错误相关的问题,而不是对代码的误解或问题。Grbl 在数以万计的 CNC 机器上可靠地运行,具有广泛的工作类型和长度。几年来没有报告失步问题。记住这一点。

喜欢 (0)