GRBL四:GRBL框架解析(转载)

因初学GRBL,网上搜集了一些GRBL的资料,怕遗忘,所以转载过来,如有侵权请联系,立即删除。

原文地址:https://blog.csdn.net/zhangjikuan/article/details/46697257

 

GRBL0.8版本中有个doc文件夹,下面是关于GRBL大致的框架介绍
1.commands.txt介绍GRBL命令
2.pinmapping.txt介绍GRBL引脚映射
3.resources.txt介绍GRBL用到资源
4.structure.txt介绍GRBL框架
4.1英文如下
The general structure of Grbl
=============================
4.1.1The main processing stack:

1.'protocol'        : Accepts command lines from the serial port and passes them to 'gcode' for execution.
                    Provides status responses for each command. Also manages run-time commands set by
                    the serial interrupt.
                    接收串口命令传递给gcode执行,给命令提供应答,通过串口中断管理程序命令
                  
2.'gcode'           : Recieves gcode from 'protocol', parses it according to the current state
                    of the parser and issues commands via '..._control' modules
                    从1接收G代码,解析G代码
3.'spindle_control' : Commands for controlling the spindle.
                               主轴控制,雕刻机的主轴带刀的轴,与XYZ无关,M3,4,5有关于主轴正反转停止命令
4.'motion_control'  : Accepts motion commands from 'gcode' and passes them to the 'planner'. This module
                    represents the public interface of the planner/stepper duo.
                      从2接收运动命令将其传递给5,相当于一个发出命令的高层接口

5.'planner'         : Receives linear motion commands from 'motion_control' and adds them to the plan of 
                    prepared motions. It takes care of continuously optimizing the acceleration profile
                    as motions are added.
                    从4接收线性运动的命令,并将其添加到准备运动计划中(计算的数据写入唤醒缓冲区)
                    随着运动不断被添加负责优化计算加速度分布图

6.'stepper'         : Executes the motions by stepping the steppers according to the plan.
                          执行动作,用两个定时器来控制三个轴完成相应的动作

4.1.2Supporting files:


'config.h'        : Compile time user settings
                        一些全局变量的宏定义,例如MINIMUM_STEPS_PER_MINUTE最低每分钟跳动多少下,也就是最低 
                        频率就在这里声明的

'settings'        : Maintains the run time settings record in eeprom and makes it available
                    to all modules.
                    全局中主要的参数设置,$$命令打印出来的参数都是这里设置的
                    上电读取EEPROM的值,如果读取失败调用default值,都在这里

'eeprom'          : A library from Atmel that provides methods for reading and writing the eeprom with 
                    a small addition from us that read and write binary streams with check sums used 
                    to verify validity of the settings record.
                    存放参数的作用,有关于EPROM的读写函数
'nuts_bolts.h'    : A collection of global variable definitions, useful constants, and macros used everywhere
                      一些全局变量的定义

'serial'          : Low level serial communications and picks off run-time commands real-time for asynchronous 
                    control.
                    串口控制台

'print'           : Functions to print strings of different formats (using serial)
                   打印不同格式的字符串函数在这里定义的
大致框架如下所示

 ———————————————— 
版权声明:本文为CSDN博主「zhangjikuan」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhangjikuan/article/details/46697257

 

ain()主函数首先执行下面初始化函数 serial_init(); // Setup serial baud rate and interrupts settings_init(); // Load Grbl settings from EEPROM stepper_init(); // 配置步进方向和中断定时器 system_init(); // 配置引脚分配别针和pin-change中断 memset(&sys, 0, sizeof(system_t)); // Clear all system variables sys.abort = true; // Set abort to complete initialization 完成初始化设置中止 sei(); // Enable interrupts #ifdef HOMING_INIT_LOCK //宏运算(settings.flags & (1 << 4)) != 0结果flags等于执行sys.state = STATE_ALARM //系统状态赋值为报警状态 if (bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; } #endif _____________________________________________________________________________________________________________________________________ 接下来是一些主要初始化循环 for(;;) { serial_reset_read_buffer(); // Clear serial read buffer gc_init(); // Set g-code parser to default state spindle_init(); //主轴 coolant_init(); //冷却液 limits_init(); //极限开关 probe_init(); //探测 plan_reset(); // Clear block buffer and planner variables 清晰块缓冲区和规划师变量 st_reset(); // Clear stepper subsystem variables. 清晰的步进系统变量。 // Sync cleared gcode and planner positions to current system position. 同步清除gcode和策划师职位当前系统位置。 plan_sync_position(); gc_sync_position(); // Reset system variables. sys.abort = false; //系统中止标志 sys_rt_exec_state = 0; //系统执行标志状态变量状态位清零。 sys_rt_exec_alarm = 0; //系统执行警报标志变量清零。 sys.suspend = false; //系统暂停标志位,取消,和安全的门。 sys.soft_limit = false; //系统限制标志状态机复位。(布尔) protocol_main_loop(); //主协议循环 } // ___________________________________________________________________________
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值