Skip to content

Commit 32863b3

Browse files
author
ashelly
committed
fixes for reporting homing counts
1 parent f46a0b6 commit 32863b3

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

counters.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ void counters_init()
4343
void counters_reset(uint8_t axis)
4444
{
4545
counters.counts[axis]=0;
46-
if (axis == Z_AXIS) { counter.idx=0; }
46+
if (axis == Z_AXIS) { counters.idx=0; }
4747
}
4848

4949

5050
// Returns the counters pin state. Triggered = true. and counters state monitor.
51-
uint16_t counters_get_count(uint8_t axis)
51+
count_t counters_get_count(uint8_t axis)
5252
{
5353
return counters.counts[axis];
5454
}
@@ -57,7 +57,7 @@ uint8_t counters_get_state(){
5757
return counters.state;
5858
}
5959

60-
uint16_t counters_get_idx(){
60+
int16_t counters_get_idx(){
6161
return counters.idx;
6262
}
6363

counters.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
#ifndef counters_h
2222
#define counters_h
2323

24+
typedef int32_t count_t;
25+
2426
typedef struct counters {
25-
int32_t counts[N_AXIS];
27+
count_t counts[N_AXIS];
2628
int16_t idx; //encoder index counts
27-
int16_t idx_offset; //encoder index counts
29+
count_t idx_offset; //encoder index counts
2830
int8_t dir; //last known direction
2931
uint8_t state;
3032
uint8_t anew; //new a encode
@@ -40,9 +42,9 @@ void counters_init();
4042
uint8_t counters_get_state();
4143

4244
// Returns counts for a given axis
43-
uint16_t counters_get_count(uint8_t axis);
45+
count_t counters_get_count(uint8_t axis);
4446

45-
uint16_t counters_get_idx();
47+
int16_t counters_get_idx();
4648

4749

4850
void counters_reset(uint8_t axis);

limits.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ void limits_go_home(uint8_t cycle_mask)
125125
}
126126
}
127127
max_travel *= HOMING_AXIS_SEARCH_SCALAR; // Ensure homing switches engaged by over-estimating max travel.
128+
max_travel += settings.homing_pulloff;
128129
homing_rate = min_seek_rate;
129130

130131
plan_reset(); // Reset planner buffer to zero planner current position and to clear previous motions.
@@ -138,10 +139,10 @@ void limits_go_home(uint8_t cycle_mask)
138139
if (bit_istrue(cycle_mask,bit(idx))) {
139140
n_active_axis++;
140141
axislock |= (1<<(X_STEP_BIT+idx)); //assumes axes are in bit order.
141-
if ((flipped&(1<<idx))^approach) { target[idx] = plan_get_position(idx) - max_travel; }
142-
else { target[idx] = plan_get_position(idx) + max_travel; }
142+
if ((flipped&(1<<idx))^approach) { target[idx] = -max_travel; }
143+
else { target[idx] = max_travel; }
143144
}
144-
else { target[idx] = plan_get_position(idx); //TODO: this needs test
145+
else { target[idx] = 0;
145146
}
146147
}
147148

@@ -194,6 +195,7 @@ void limits_go_home(uint8_t cycle_mask)
194195
//force report of known position for compare to zero.
195196
linenumber_insert(HOMING_CYCLE_LINE_NUMBER);
196197
request_report_status(1);
198+
protocol_execute_runtime();
197199

198200
// The active cycle axes should now be homed and machine limits have been located. By
199201
// default, grbl defines machine space as all negative, as do most CNCs. Since limit switches

0 commit comments

Comments
 (0)