# plotter_grbl **Repository Path**: JackGao19700/plotter_grbl ## Basic Information - **Project Name**: plotter_grbl - **Description**: modify grbl firmware to plotter - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-11 - **Last Updated**: 2025-09-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # A. 主要功能 在grbl github代码的基础上,修改spindle的作用,因为对于写字机来说,spindle没有意义,所以修改spindle, 利用Arduino Nano的D11(Spindle PWM控制)来控制Micro Servo SG90, 进而控制落笔和抬笔。 - 控制Spindle max转速的\$30 用于控制Micro Servo SG90最大转角,$\leq 180^{\circ}$。在我的plotter中,就是抬笔的最高点。 - 控制Spindle min转速的\$31 用于控制Micro Servo SG90最小转角,$\leq 180^{\circ}$。在我的plotter中,就是落笔的的最低点,所以调整这个可以调整笔的压力大小。 - 在接收的gcode中,检查是不是工作行程(**G1**),是的话自动落笔;如果是空行程(**G0**)或**Homing**, 自动抬笔。不需要额外在gcode中添加落笔和抬笔。 - 由于Spindle 用于Micro Servo SG90,让**S0**和**M5**指令除了抬笔,什么也不做。 ## B. 修改点说明 ## 1. 修改文件 `config.h`, `spindle_control.c`, `spindle_control.h`,`settings.c`和`planner.c` ## 2. 修改说明 - `config.h`中,在#define VARIABLE_SPINDLE附近,增加了: ```c //将SPINDEL控制信号用于Plotter笔的管理 //利用GRBL的 $30 和 $31 参数来配置笔的位置 #define AUTO_PEN_CONTROL #define DEFAULT_PEN_MIN_DEGREE 0 #define DEFAULT_PEN_MAX_DEGREE 180 #define PEN_DOWN_POS settings.rpm_min #define PEN_UP_POS settings.rpm_max ``` - `planner.c`中,增加`static void apply_pen_control_to_pl_data(plan_line_data_t *pl_data)`和修改`uint8_t plan_buffer_line(float *target, plan_line_data_t *pl_data)在gcode中自动添加抬笔和落笔动作. - `settings.c`中,修改`rpm_max`和`rpm_min`固件缺省值($180^{\circ}$和$0^{\circ}$)以及修改函数`uint8_t settings_store_global_setting(uint8_t parameter, float value)`中`rpm_max`和`rpm_min`的通过上位机的设置逻辑。 - `spindle_conbtrol.c和spindle_control.h`中是实现Micro Servo SG90的主要控制逻辑 ## C. 其他 有任何问题可以联系 jackgao19700@qq.com