gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
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 
25 
27 void probe_init()
28 {
29  PROBE_DDR &= ~(PROBE_MASK);
30  #ifdef DISABLE_PROBE_PIN_PULL_UP
31  PROBE_PORT &= ~(PROBE_MASK);
32  #else
33  PROBE_PORT |= PROBE_MASK;
34  #endif
36 }
37 
39 // appropriately set the pin logic according to setting for normal-high/normal-low operation
40 // and the probing cycle modes for toward-workpiece/away-from-workpiece.
41 void probe_configure_invert_mask(uint8_t is_probe_away)
42 {
43  probe_invert_mask = 0;
45  if (is_probe_away) { probe_invert_mask ^= PROBE_MASK; }
46 }
47 
49 uint8_t probe_get_state() { return((PROBE_PIN & PROBE_MASK) ^ probe_invert_mask); }
50 
52 // stepper ISR per ISR tick.
53 //
56 {
57  if (probe_get_state()) {
61  }
62 }
volatile uint8_t sys_probe_state
Probing state value. Used to coordinate the probing cycle with stepper ISR.
Definition: system.h:133
void probe_state_monitor()
Monitors probe pin state and records the system position when detected. Called by the...
Definition: probe.c:55
uint8_t probe_get_state()
Returns the probe pin state. Triggered = true. Called by gcode parser and probe state monitor...
Definition: probe.c:49
#define PROBE_OFF
Values that define the probing state machine.
Definition: probe.h:24
#define bit_true(x, mask)
Definition: nuts_bolts.h:58
void probe_configure_invert_mask(uint8_t is_probe_away)
Called by probe_init() and the mc_probe() routines. Sets up the probe pin invert mask to...
Definition: probe.c:41
uint8_t probe_invert_mask
Inverts the probe pin state depending on user settings and probing cycle mode.
Definition: probe.c:24
uint8_t flags
Contains default boolean settings.
Definition: settings.h:92
void probe_init()
Probe pin initialization routine.
Definition: probe.c:27
int32_t sys_position[N_AXIS]
NOTE: These position variables may need to be declared as volatiles, if problems arise.
Definition: system.h:130
#define bit_isfalse(x, mask)
Definition: nuts_bolts.h:61
#define EXEC_MOTION_CANCEL
bitmask 01000000
Definition: system.h:37
volatile uint8_t sys_rt_exec_state
Global realtime executor bitflag variable for state management. See EXEC bitmasks.
Definition: system.h:134
memcpy(block_coord_system, gc_state.coord_system, sizeof(gc_state.coord_system))
settings_t settings
Definition: settings.c:24
int32_t sys_probe_position[N_AXIS]
Last probe position in machine coordinates and steps.
Definition: system.h:131
#define BITFLAG_INVERT_PROBE_PIN
Definition: settings.h:42