LAT Hologramm-Software 2.0
Loading...
Searching...
No Matches
modules
Stage
Stage Nikolas
grbl
grbl-master
grbl
probe.c
Go to the documentation of this file.
1
/*
2
probe.c - code pertaining to probing methods
3
Part of Grbl
4
5
Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
6
7
Grbl is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
Grbl is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#include "
grbl.h
"
22
23
24
// Inverts the probe pin state depending on user settings and probing cycle mode.
25
uint8_t
probe_invert_mask
;
26
27
28
// Probe pin initialization routine.
29
void
probe_init
()
30
{
31
PROBE_DDR &= ~(PROBE_MASK);
// Configure as input pins
32
#ifdef DISABLE_PROBE_PIN_PULL_UP
33
PROBE_PORT &= ~(PROBE_MASK);
// Normal low operation. Requires external pull-down.
34
#else
35
PROBE_PORT |= PROBE_MASK;
// Enable internal pull-up resistors. Normal high operation.
36
#endif
37
probe_configure_invert_mask
(
false
);
// Initialize invert mask.
38
}
39
40
41
// Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to
42
// appropriately set the pin logic according to setting for normal-high/normal-low operation
43
// and the probing cycle modes for toward-workpiece/away-from-workpiece.
44
void
probe_configure_invert_mask
(uint8_t is_probe_away)
45
{
46
probe_invert_mask
= 0;
// Initialize as zero.
47
if
(
bit_isfalse
(
settings
.
flags
,
BITFLAG_INVERT_PROBE_PIN
)) {
probe_invert_mask
^= PROBE_MASK; }
48
if
(is_probe_away) {
probe_invert_mask
^= PROBE_MASK; }
49
}
50
51
52
// Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor.
53
uint8_t
probe_get_state
() {
return
((PROBE_PIN & PROBE_MASK) ^
probe_invert_mask
); }
54
55
56
// Monitors probe pin state and records the system position when detected. Called by the
57
// stepper ISR per ISR tick.
58
// NOTE: This function must be extremely efficient as to not bog down the stepper ISR.
59
void
probe_state_monitor
()
60
{
61
if
(
probe_get_state
()) {
62
sys_probe_state
=
PROBE_OFF
;
63
memcpy(
sys_probe_position
,
sys_position
,
sizeof
(
sys_position
));
64
bit_true
(
sys_rt_exec_state
,
EXEC_MOTION_CANCEL
);
65
}
66
}
grbl.h
sys_position
int32_t sys_position[N_AXIS]
Definition:
main.c:27
sys_probe_position
int32_t sys_probe_position[N_AXIS]
Definition:
main.c:28
sys_probe_state
volatile uint8_t sys_probe_state
Definition:
main.c:29
sys_rt_exec_state
volatile uint8_t sys_rt_exec_state
Definition:
main.c:30
bit_isfalse
#define bit_isfalse(x, mask)
Definition:
nuts_bolts.h:65
bit_true
#define bit_true(x, mask)
Definition:
nuts_bolts.h:62
probe_configure_invert_mask
void probe_configure_invert_mask(uint8_t is_probe_away)
Definition:
probe.c:44
probe_get_state
uint8_t probe_get_state()
Definition:
probe.c:53
probe_init
void probe_init()
Definition:
probe.c:29
probe_invert_mask
uint8_t probe_invert_mask
Definition:
probe.c:25
probe_state_monitor
void probe_state_monitor()
Definition:
probe.c:59
PROBE_OFF
#define PROBE_OFF
Definition:
probe.h:25
settings
settings_t settings
Definition:
settings.c:24
BITFLAG_INVERT_PROBE_PIN
#define BITFLAG_INVERT_PROBE_PIN
Definition:
settings.h:49
settings_t::flags
uint8_t flags
Definition:
settings.h:106
EXEC_MOTION_CANCEL
#define EXEC_MOTION_CANCEL
Definition:
system.h:37
Generated on Thu Feb 23 2023 12:36:39 for LAT Hologramm-Software 2.0 by
1.9.5