From: Joseph Coffland Date: Sun, 9 Jul 2017 01:49:44 +0000 (-0700) Subject: Homing should be working X-Git-Url: https://git.buildbotics.com/?a=commitdiff_plain;h=9db43bdd7aa4c9ae531132884fede122894cb66b;p=bbctrl-firmware Homing should be working --- diff --git a/avr/src/axis.c b/avr/src/axis.c index 5a48b78..6b8f63a 100644 --- a/avr/src/axis.c +++ b/avr/src/axis.c @@ -176,3 +176,36 @@ float get_home(int axis) { } return NAN; } + + +static int _get_homing_switch(int axis) { + switch (axes[axis].homing_mode) { + case HOMING_MANUAL: break; + + case HOMING_STALL_MIN: case HOMING_SWITCH_MIN: + switch (axis) { + case AXIS_X: return SW_MIN_X; + case AXIS_Y: return SW_MIN_Y; + case AXIS_Z: return SW_MIN_Z; + case AXIS_A: return SW_MIN_A; + } + break; + + case HOMING_STALL_MAX: case HOMING_SWITCH_MAX: + switch (axis) { + case AXIS_X: return SW_MAX_X; + case AXIS_Y: return SW_MAX_Y; + case AXIS_Z: return SW_MAX_Z; + case AXIS_A: return SW_MAX_A; + } + break; + } + + return -1; +} + + +bool get_axis_can_home(int axis) { + return axis_is_enabled(axis) && axes[axis].homing_mode != HOMING_MANUAL && + switch_is_enabled(_get_homing_switch(axis)); +} diff --git a/avr/src/vars.def b/avr/src/vars.def index 70fb49a..2351e01 100644 --- a/avr/src/vars.def +++ b/avr/src/vars.def @@ -78,6 +78,7 @@ VAR(zero_backoff, zb, float, MOTORS, 1, 1, "Homing zero backoff") // Axis VAR(axis_mach_coord, p, float, AXES, 1, 1, "Axis machine coordinate") VAR(axis_work_coord, w, float, AXES, 0, 1, "Axis work coordinate") +VAR(axis_can_home, ch, bool, AXES, 0, 1, "Is axis configured for homing") // Spindle VAR(spindle_type, st, uint8_t, 0, 1, 1, "PWM=0 or HUANYANG=1") diff --git a/src/jade/templates/control-view.jade b/src/jade/templates/control-view.jade index f7faa88..9b324f4 100644 --- a/src/jade/templates/control-view.jade +++ b/src/jade/templates/control-view.jade @@ -16,17 +16,18 @@ script#control-view-template(type="text/x-template") td.absolute {{state.#{axis}p || 0 | fixed 3}} td.offset {{(state.#{axis}w - state.#{axis}p) || 0 | fixed 3}} th.actions - button.pure-button( + button.pure-button(:disabled="state.x != 'READY'", title="Set {{'#{axis}' | upper}} axis position.", @click="show_set_position('#{axis}')") .fa.fa-cog - button.pure-button( + button.pure-button(:disabled="state.x != 'READY'", title="Zero {{'#{axis}' | upper}} axis offset.", @click="set_position('#{axis}', state['#{axis}p'])") | ∅ - button.pure-button(title="Home {{'#{axis}' | upper}} axis.", + button.pure-button(:disabled="state.x != 'READY'", + title="Home {{'#{axis}' | upper}} axis.", @click="home('#{axis}')") .fa.fa-home @@ -77,7 +78,7 @@ script#control-view-template(type="text/x-template") td tr th Reason - td {{get_reason()}} + td.reason {{get_reason()}} td tr th Feed @@ -128,7 +129,7 @@ script#control-view-template(type="text/x-template") .toolbar - button.pure-button(title="Home the machine.", @click="home", + button.pure-button(title="Home the machine.", @click="home()", :disabled="state.x != 'READY'") .fa.fa-home diff --git a/src/js/control-view.js b/src/js/control-view.js index 2ac67ec..46d8947 100644 --- a/src/js/control-view.js +++ b/src/js/control-view.js @@ -221,12 +221,17 @@ module.exports = { home: function (axis) { - var motor = this.get_axis_motor(axis); - if (motor['homing-mode'] == 'manual') { - this.axis_position = this.state[axis + 'w']; - this.manual_home[axis] = true; + if (typeof axis == 'undefined') api.put('home'); + + else { + var motor = this.get_axis_motor(axis); - } else api.put('home' + (typeof axis == 'undefined' ? '' : ('/' + axis))); + if (motor['homing-mode'] == 'manual') { + this.axis_position = this.state[axis + 'w']; + this.manual_home[axis] = true; + + } else api.put('home/' + axis); + } }, diff --git a/src/py/bbctrl/AVR.py b/src/py/bbctrl/AVR.py index 8a67423..aacf75a 100644 --- a/src/py/bbctrl/AVR.py +++ b/src/py/bbctrl/AVR.py @@ -35,12 +35,12 @@ machine_state_vars = ''' # - Backoff to machine zero # - Set axis home position axis_homing_procedure = ''' - G28.2 %(axis)c0 F[#<%(axis)c.sv>] - G38.6 %(axis)c[#<%(axis)c.hd> * [#<%(axis)c.tm> - #<%(axis)c.tn>]] - G38.8 %(axis)c[#<%(axis)c.hd> * -#<%(axis)c.lb>] F[#<%(axis)c.lv>] - G38.6 %(axis)c[#<%(axis)c.hd> * #<%(axis)c.lb> * 1.5] - G0 %(axis)c[#<%(axis)c.hd> * -#<%(axis)c.zb> + #<%(axis)cp>] - G28.3 %(axis)c[#<%(axis)c.hp>] + G28.2 %(axis)s0 F[#<%(axis)s.sv>] + G38.6 %(axis)s[#<%(axis)s.hd> * [#<%(axis)s.tm> - #<%(axis)s.tn>]] + G38.8 %(axis)s[#<%(axis)s.hd> * -#<%(axis)s.lb>] F[#<%(axis)s.lv>] + G38.6 %(axis)s[#<%(axis)s.hd> * #<%(axis)s.lb> * 1.5] + G0 %(axis)s[#<%(axis)s.hd> * -#<%(axis)s.zb> + #<%(axis)sp>] + G28.3 %(axis)s[#<%(axis)s.hp>] ''' class AVR(): @@ -240,7 +240,7 @@ class AVR(): def _update_lcd(self, msg): if 'x' in msg or 'c' in msg: - v = self.ctrl.avr.vars + v = self.vars state = v.get('x', 'INIT') if 'c' in v and state == 'RUNNING': state = v['c'] @@ -288,9 +288,15 @@ class AVR(): self.queue_command('G28.3 %c%f' % (axis, position)) else: - gcode = axis_homing_procedure % {'axis': axis} - for line in gcode.splitlines(): - self.queue_command(line.strip()) + if axis is None: axes = 'zxyabc' # TODO This should be configurable + else: axes = '%c' % axis + + for axis in axes: + if not self.vars.get('%sch' % axis, 0): continue + + gcode = axis_homing_procedure % {'axis': axis} + for line in gcode.splitlines(): + self.queue_command(line.strip()) def estop(self): self._i2c_command(I2C_ESTOP) diff --git a/src/stylus/style.styl b/src/stylus/style.styl index 7cc3302..d9a2554 100644 --- a/src/stylus/style.styl +++ b/src/stylus/style.styl @@ -234,10 +234,12 @@ body .info empty-cells show + max-width 50% th, td padding 3px text-align right + white-space normal th width 5.25em