【龙印】3d打印固件Marlin中bresenham算法注解

本文介绍了基于龙芯1c的3D打印机(龙印)在Marlin固件中如何实现Bresenham算法。通过分析源码,解释了算法如何与打印机运动控制相结合,详细展示了从(0,0,0)到(31,21,5)的步进过程。" 109419995,10241470,Python编程绘制与打印爱心代码详解,"['Python编程', '图形绘制', '字符艺术', '编程表白']
摘要由CSDN通过智能技术生成

本文为在用龙芯1c做3D打印机过程中的笔记。龙芯1c做的3d打印机简称“龙印”

参考了以下两篇博文,再其基础上增加了对marlin源码的注解和我的一些理解。

http://blog.sina.com.cn/s/blog_6ad165790102vo09.html

http://blog.sina.com.cn/s/blog_679933490102vv8z.html


先来看一下marlin中bresenham算法的相关代码。源码位于源文件“Marlin\stepper.cpp”中的函数ISR(TIMER1_COMPA_vect)内。如下

  // If there is no current block, attempt to pop one from the buffer
  if (!current_block) {
    // Anything in the buffer?
    current_block = plan_get_current_block();
    if (current_block) {
      current_block->busy = true;
      trapezoid_generator_reset();
      counter_x = -(current_block->step_event_count >> 1);
      counter_y = counter_z = counter_e = counter_x;
      step_events_completed = 0;

      #if ENABLED(Z_LATE_ENABLE)
        if (current_block->steps[Z_AXIS] > 0) {
          enable_z();
          OCR1A = 2000; //1ms wait
          return;
        }
      #endif

      // #if ENABLED(ADVANCE)
      //   e_steps[current_block->active_extruder] = 0;
      // #endif
    }
    else {
      OCR1A = 2000; // 1kHz.
    }
  }

  if (current_block != NULL) {

    // Update endstops state, if enabled
    #if ENABLED(HAS_Z_MIN_PROBE)
      if (check_endstops || z_probe_is_active) update_endstops();
    #else
      if (check_endstops) update_endstops();
    #endif

    // Take multiple steps per interrupt (For 
  • 4
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值