Comments (12)
The only way with the current code is to first issue $X to go from home state to idle state, then issue $H
from fluidnc.
no, it's not home state, it's hold state (on feed_hold_pin)
and $x do nothing but stuck the console.
actually i can reset the state to idle by pressing Ctrl+X, and then run $Home
.
but how can i do it programmatically? why the code below doesnt work:
static void protocol_do_origin() {
if (state_is(State::Homing) || state_is(State::Cycle) || state_is(State::Jog) || state_is(State::ConfigAlarm)) {
log_warn("Ignore home event at state " << (uint8_t)sys.state);
return;
}
// [bug] press home btn when paused
if (!state_is(State::Idle) && !state_is(State::Alarm)) {
log_warn("Reset before homing at state " << (uint8_t)sys.state);
protocol_do_rt_reset();
// why it doesn't do homing after ?
}
// works fine at `Idle` state
log_info("Do homing by pin at state " << (uint8_t)sys.state);
static char cmd[] = "$Home";
settings_execute_line(cmd, allChannels, WebUI::AuthenticationLevel::LEVEL_ADMIN);
}
from fluidnc.
Sorry, there were lots of mistakes in my post above. I just woke up and haven't had my coffee yet. I meant to say ctrl-x to get from hold to idle.
The reason your code doesn't work is probably related to the timing of the event processing. protocol_do_rt_reset() ends by sending restartEvent to be executed later. Your code is running as an event handler, so the event dispatch cannot run until your code returns.
One way to fix it might be to use the event system instead of trying to run the event handlers directly. Instead of calling protocol_do_rt_reset(), call protocol_send_event(&rtResetEvent) , Also create a event that does the homing step and send it. Then the event handler will run all the steps in sequence.
from fluidnc.
Oh, wish you a good day, Mr. Bradley .
It's midnight here.
Thank you for responding, I will try it later.
from fluidnc.
I am not guaranteeing that my proposed approach will work without problems. What you are trying to do is complicated because of the historical design of the Grbl state machine. The problem is the use of reset to exit from Hold state. Grbl uses reset to do several things that have conflicting requirements:
- Set up the system for initial use and issue a signon message for the sender to see
- Immediately stop a job that is running
- Stop a job that is in hold state
- Exit from critical state after a limit alarm
Reset is a very "heavyweight" operation that reinitialized many variables - perhaps too many for some uses. I have often wanted to fix this problem, but the chances of breaking something is very high.
from fluidnc.
It's ok, any suggestion will be appreciated.
The problem is driving me crazy.
from fluidnc.
It do homing (state=home) but goes the wrong directions (all three axes wrong),
and says a few seconds later: ALARM: Homing Fail Approach
.
—— the limit switch is at the other side...
Any idea?
new code:
static void protocol_do_home() {
log_info("Handle home event at state " << (uint8_t)sys.state);
static char cmd[] = "$Home";
settings_execute_line(cmd, allChannels, WebUI::AuthenticationLevel::LEVEL_ADMIN);
}
static NoArgEvent homeEvent { protocol_do_home };
static void protocol_do_origin() {
if (state_is(State::Homing) || state_is(State::Cycle) || state_is(State::Jog) || state_is(State::ConfigAlarm)) {
log_warn("Ignore home event at state " << (uint8_t)sys.state);
return;
}
// [bug] press home btn when paused
if (!state_is(State::Idle) && !state_is(State::Alarm)) {
log_warn("Reset before homing at state " << (uint8_t)sys.state);
protocol_send_event(&rtResetEvent);
// why it goes wrong direction when homing ?
}
// works fine at `Idle` state
log_info("Do homing by pin at state " << (uint8_t)sys.state);
protocol_send_event(&homeEvent);
}
NoArgEvent originPinEvent { protocol_do_origin };
NoArgEvent pausePinEvent { protocol_do_pause };
logs:
*** firmware uploaded and boot finish ***
Grbl 3.0 [FluidNC v3.0.x (noGit) (wifi) '$' for help]
[MSG:INFO: ALARM: Unhomed]
<Alarm|MPos:0.000,0.000,0.000|FS:0,0>
*** press Home button ***
[MSG:INFO: Do homing by pin at state 1]
[MSG:INFO: Handle home event at state 1]
[MSG:Homed:Z]
[MSG:Homed:XY]
*** press 1.nc button ***
[MSG:INFO: Running macro macro1: $SD/Run=1.nc]
[MSG:/sd/1.nc file job succeeded]
<Hold:0|MPos:103.198,103.198,49.980|FS:0,0>
[MSG:WARN: Reset before homing at state 5]
[MSG:INFO: Do homing by pin at state 5]
[MSG:INFO: Handle home event at state 0]
Grbl 3.0 [FluidNC v3.0.x (noGit) (wifi) '$' for help]
<Home|MPos:378.198,378.198,-30.020|FS:0,0>
[MSG:INFO: ALARM: Homing Fail Approach]
ALARM:9
from fluidnc.
If you send $message/level=debug you will see more details of the homing process
from fluidnc.
It's still the timing.
If I add some delay (like 100ms), it goes the right direction.
But it stuck at settings_execute_line()->do_command_or_setting->Command::action->home_all->home->do{}while
with state 'Home':
do {
protocol_execute_realtime();
} while (state_is(State::Homing)); // It stuck in this loop
It never get to 'Idle' after homed xyz:
[MSG:WARN: Reset before homing at state 5]
Grbl 3.0 [FluidNC v3.0.x (16M) (wifi) '$' for help]
[MSG:INFO: Handle home event at state 0]
<Home|MPos:108.045,108.045,80.375|FS:60,0|Ov:100,100,100>
[MSG:Homed:Z]
[MSG:Homed:XY]
<Home|MPos:0.000,0.000,80.000|FS:0,0|Ov:100,100,100>
new code with delay:
static void protocol_do_home();
static NoArgEvent homeEvent { protocol_do_home };
static int64_t homeEventStart = 0;
static void protocol_do_home() {
// wait at least 100ms, or it will home at the wrong direction.
if (millis() - homeEventStart < 200) {
protocol_send_event(&homeEvent);
return;
}
log_info("Handle home event at state " << (uint8_t)sys.state);
static char cmd[] = "$Home";
settings_execute_line(cmd, allChannels, WebUI::AuthenticationLevel::LEVEL_ADMIN);
log_info("Homed, state=" << (uint8_t)sys.state); // never get here when homing at hold state
}
static void protocol_do_origin() {
if (state_is(State::Homing) || state_is(State::Cycle) || state_is(State::Jog) || state_is(State::ConfigAlarm)) {
log_warn("Ignore home event at state " << (uint8_t)sys.state);
return;
}
if (!state_is(State::Idle) && !state_is(State::Alarm)) {
log_warn("Reset before homing at state " << (uint8_t)sys.state);
protocol_send_event(&rtResetEvent);
homeEventStart = millis();
protocol_send_event(&homeEvent);
return;
}
// log_info("Do homing by pin at state " << (uint8_t)sys.state);
protocol_do_home();
}
NoArgEvent originPinEvent { protocol_do_origin };
from fluidnc.
I managed to fix it by creating another task with the same priority.
When button pressed, send event to the task, and the task will send event back, and do some delay between of course.
from fluidnc.
You could probably do the same thing with a freertos timer. They use much less RAM than a task. There is an example in Motors/Servo.cpp
from fluidnc.
OK
from fluidnc.
Related Issues (20)
- Problem: TMC driver not detected after reinitialize, only one axis driver test passed at the beginning. HOT 4
- Problem: How to install FluidNC the esp32-s2 or esp32-c3. HOT 1
- Feature: Trinamic position control via SPI HOT 1
- Problem: GPIO2 use for limit_neg_pin can't pu 3.3v only 0.31v HOT 4
- Wifi porblem HOT 1
- Problem: FluidNC 6XCNC Controller - strange LED lights and steppers suddenly not working HOT 13
- Problem: All the TMC drivers not detected HOT 1
- [MSG:ERR: Command requires idle state] HOT 4
- Problem: Homing X in >3.7.10 not working on ESP32 HOT 6
- Problem: slow homing speed. `seek_mm_per_min` has no effect HOT 2
- Problem: Web GUI unresponsive, Pendant have a blacscreen HOT 10
- Alarm 14 may not be cleared if an axis is not set to home HOT 1
- Problem: Some alarm conditions can disable the steppers, even with idle_ms set to 255
- Problem with homing with 2 motor HOT 4
- Second limit switch Y axis is not working properly HOT 6
- FluidDial Pendant no read sdcard and Macros don't load HOT 13
- Problem: CL86T v4.1 external driver Timing config, Startup error using ":pu" or the CNC will not move. HOT 24
- Problem: Homing only turns on 1 axis, and that starts to block and whine HOT 11
- Problem: Trying to Run JTAG debugging HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluidnc.