grblhal / plugins Goto Github PK
View Code? Open in Web Editor NEWPlugins overview
Plugins overview
I've started to write a plugin to work with my ATC Setup... I've added the code needed to plugins_init and can confirm that I am seeing the report options in the console... I've setup a breakpoint on my functions for hal.tool.change and select and they never seem to trigger... Am I missing something here? This is a STM32F401. Tried M6 T2 to see if I could get to the breakpoint
`#include "driver.h"
#include "grbl/hal.h"
#include "grbl/protocol.h"
#include "grbl/motion_control.h"
#if ATC == 1
static tool_data_t *current_tool = NULL, *next_tool = NULL;
static on_report_options_ptr on_report_options;
char alignment[1];
static void report_options (bool newopt)
{
on_report_options(newopt);
if(!newopt) {
hal.stream.write("[PLUGIN:ATC v0.01]" ASCII_EOL);
}
}
static void atc_tool_select (tool_data_t *tool, bool next)
{
if(next)
next_tool = tool;
else
current_tool = tool;
}
static status_code_t atc_tool_change (parser_state_t *gc_state)
{
if(current_tool == NULL || next_tool == NULL)
return Status_GCodeToolError;
if(current_tool == next_tool)
return Status_OK;
if(!sys.homed.mask || sys.homed.mask != sys.homing.mask)
return Status_HomingRequired;
hal.stream.write_all("Tool Change Taking Place");
}
void atc_init (void) {
hal.tool.select = atc_tool_select;
hal.tool.change = atc_tool_change;
//settings_register(&setting_details);
on_report_options = grbl.on_report_options;
grbl.on_report_options = report_options;
}
#endif`
I'm trying to setup a Format_Decimal to take a nagative value but it does not seem to allow me to do so.
{ 904, Group_UserSettings, "Pocket 1 X Position", "mm", Format_Decimal, "###0.000", "-9999.999", "9999.999", Setting_IsExtended, &my_settings.pocket_1_x_pos, NULL, NULL },
No matter what i try it will not take negative values.
Am I missing something?
I have a HY 1.5K Spindle that works perfectly. I can start and stop the spindle from io sender without any problems. From time to time when i have to abort the program the spindle does not stop. IO Sender says its off and the rpm is 0 but its still spinning. I'm not sure what else you would like to help debug this but will answer any questions and provide any data you need.
At the point where I am ready to have the plugin measure each tool as tool changes happen... I figured I could just set $341=2 and have the core do a automatic tool change... Tracing the code I get to settings.c set_tool_change_mode(). It says if hal.driver_cap.atc is set to return that it is an invalid statement.
What is the proper / expected way to have the atc do a TLO
I wrote a plugin that adds a custom M command to drive the AUX and flood/mist/spindle pins such that when you send M101 Q1
it would turn on a binary representation of that number on the pins, allowing for 64 different pin states (since we're not using the cool or spindle functions for anything else in my use-case). My issue is that when I send the Gcode via websocket to the board, the m code command, while very clearly being after all movement, is executed before the machine stops moving. I'm not sure with the documentation, but is there a certain step I'm missing in my plugin to handle waiting for the movement of the axis to complete before execution?
This is the current code for the m-code handling of my plugin:
static user_mcode_t mcode_check (user_mcode_t mcode)
{
return mcode == (user_mcode_t)101 || mcode == (user_mcode_t)102
? mcode
: (user_mcode.check ? user_mcode.check(mcode) : UserMCode_Ignore);
}
static status_code_t mcode_validate (parser_block_t *gc_block, parameter_words_t *deprecated)
{
status_code_t state = Status_OK;
switch((uint16_t)gc_block->user_mcode) {
case 101:
if(gc_block->words.q) {
if(isnanf(gc_block->values.q))
state = Status_BadNumberFormat;
else {
if(!isintf(gc_block->values.q) || gc_block->values.q < 0.0f || (uint8_t)gc_block->values.q > max_pin_selection - 1)
state = Status_GcodeValueOutOfRange;
gc_block->words.q = Off;
}
}
break;
case 102:
break;
default:
state = Status_Unhandled;
break;
}
return state == Status_Unhandled && user_mcode.validate ? user_mcode.validate(gc_block, deprecated) : state;
}
static void mcode_execute (uint_fast16_t state, parser_block_t *gc_block)
{
bool handled = true;
if (state != STATE_CHECK_MODE)
{
coolant_state_t coolant_state = hal.coolant.get_state();
spindle_state_t spindle_state = hal.spindle.get_state();
switch((uint16_t)gc_block->user_mcode) {
case 101:
if(gc_block->words.q)
pin_selection = (uint8_t)gc_block->values.q;
hal.port.digital_out(Aux_0, pin_selection & 0b0001);
hal.port.digital_out(Aux_1, pin_selection>>1 & 0b0001);
hal.port.digital_out(Aux_2, pin_selection>>2 & 0b0001);
coolant_state.mist = pin_selection>>3 & 0b0001;
coolant_state.flood = pin_selection>>4 & 0b0001;
hal.coolant.set_state(coolant_state);
sys.report.coolant = On;
spindle_state.on = pin_selection>>5 & 0b0001;
hal.spindle.set_state(spindle_state, 0);
sys.report.spindle = On;
hal.delay_ms(SELECTION_DEBOUNCE, NULL); // Delay a bit to let any contact bounce settle.
break;
case 102:
hal.port.digital_out(Aux_0, 0);
hal.port.digital_out(Aux_1, 0);
hal.port.digital_out(Aux_2, 0);
hal.coolant.set_state((coolant_state_t){0});
sys.report.coolant = On;
hal.spindle.set_state((spindle_state_t){0}, 0);
sys.report.spindle = On;
pin_selection = 0;
hal.delay_ms(SELECTION_DEBOUNCE, NULL); // Delay a bit to let any contact bounce settle.
break;
default:
handled = false;
break;
}
}
if(!handled && user_mcode.execute)
user_mcode.execute(state, gc_block);
}
Is there a place here where I can basically enqueue the execution of the m command until its order in the actual execution of the gcode? This is a snippet of the end of the gcode where I'm issuing the M102
command which turns off all pins. The pins are actually being triggered time-wise at about the beginning of this section of gcode, rather than nearly 5 seconds later, after the G0 X0 Y0 Z0
command is complete.
G1 X2.84391 Y1.76805 A0.04465
G1 X2.70321 Y1.99107 A0.04476
G1 X2.54500 Y2.20289 A0.04488
G1 X2.37018 Y2.40212 A0.04499
G1 F2500 ; Pins change around here
G1 X4.54249 Y0.87083
G1 X2.75876 Y2.54603
G1 X2.58425 Y2.81492
G1 X2.38436 Y3.07175
G1 X2.15992 Y3.31418
G1 X1.91199 Y3.53994
G1 X1.64183 Y3.74681
G1 X1.35092 Y3.93269
G1 X1.04092 Y4.09560
G1Z10
G90
G0 X0 Y0 Z0
G91
M102 ; Command to turn off pins is here
Hi @terjeio , would it be possible to add plugin for Nextion displays ? https://nextion.tech
I mean something like when you press a button it sends a Gcode command to serial.print
I played with Nextion Editor and it should be quite easy to do that.
But i dont know how to implement it to grblHAL, i want to use it on ESP32..
Displays are not that expensive so maybe it will be viable options for all of us.
Thank you.
I am writing a plug in and when I raise Alarm_Spindle it will not clear unless I click reset in I/O Sender twice within a second or so. A single click will not clear the alarm. Is there a call I should make when an alarm condition has gone away after raising an alarm. Or should a reset clear it and wait to see if it comes back? My alarm handling closely follows the code in Huanyang plug in.
Thanks,
Jeff
Is it possible to add / create a plugin that allows the use of an ESP32 Module (in Slave mode) to add Wi-Fi / Bluetooth functionality via the SPI port?
Regards
George
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.