Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions configs/sim/axis/external_offsets/dynamic_offsets_panel.hal
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
loadrt siggen names=gen
loadrt scale names=scalea
loadrt conv_float_s32 names=cvt
loadrt not names=nota
loadrt or2 names=or2a

addf gen.update servo-thread
addf scalea servo-thread
addf cvt servo-thread
addf nota servo-thread
addf or2a servo-thread

Expand All @@ -23,8 +21,7 @@ net E:frequency <= pyvcp.gen-frequency => gen.frequency

# can also use sawtooth (others inappropriate on a reset)
net G:waveform <= gen.sine => scalea.in
net G:swaveform <= scalea.out => cvt.in
net G:counts <= cvt.out => axis.z.eoffset-counts
net G:counts <= scalea.out => axis.z.eoffset-counts

net E:enable <= pyvcp.z-enable => axis.z.eoffset-enable
net E:enable => nota.in
Expand Down
2 changes: 1 addition & 1 deletion configs/sim/axis/external_offsets/eoffsets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Input hal pins:
axis.L.eoffset-enable (bit)
axis.L.eoffset-clear (bit)
axis.L.eoffset-scale (float)
axis.L.eoffset-counts (s32)
axis.L.eoffset-counts (float)

Requested offset == counts*scale
2 changes: 1 addition & 1 deletion configs/sim/axis/external_offsets/eoffsets_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ Pines Input hal:
axis.L.eoffset-enable (bit)
axis.L.eoffset-clear (bit)
axis.L.eoffset-scale (float)
axis.L.eoffset-counts (s32)
axis.L.eoffset-counts (float)

Offset solicitado == counts*scale
2 changes: 1 addition & 1 deletion configs/sim/axis/external_offsets/jwp_z_panel.hal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ addf zctr servo-thread

net E:z-plus <= pyvcp.z-plus => zctr.countup
net E:z-minus <= pyvcp.z-minus => zctr.countdown
net E:z-counts <= zctr.count => axis.z.eoffset-counts
net E:z-counts <= zctr.count-f => axis.z.eoffset-counts
net E:z-scale <= pyvcp.z-scale => axis.z.eoffset-scale
net E:z-offset <= axis.z.eoffset => pyvcp.z-offset-f
net E:limited <= motion.eoffset-limited => pyvcp.limited
Expand Down
13 changes: 7 additions & 6 deletions configs/sim/qtdragon_hd/qtdragon_hd_xyz/qtdragon_hd_postgui.hal
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ loadrt logic names=logic-and personality=0x102
addf logic-and servo-thread

# load a summing component for adding spindle lift and Z compensation
loadrt scaled_s32_sums
addf scaled-s32-sums.0 servo-thread
# (eoffset counts are floats, so sum2 rather than scaled_s32_sums)
loadrt sum2
addf sum2.0 servo-thread

loadusr -Wn z_level_compensation z_level_compensation
# method parameter must be one of nearest(2), linear(1), cubic (0)
Expand Down Expand Up @@ -51,8 +52,8 @@ net zpos-cmd z_level_compensation.z-pos <= axis.z.pos-cmd
net z_compensation_on z_level_compensation.enable-in <= qtdragon.comp-on
net eoffset-zlevel-count z_level_compensation.counts => qtdragon.eoffset-zlevel-count

net eoffset-spindle-count scaled-s32-sums.0.in0
net eoffset-zlevel-count scaled-s32-sums.0.in1
setp scaled-s32-sums.0.scale0 1000
net eoffset-counts scaled-s32-sums.0.out-s
net eoffset-spindle-count sum2.0.in0
net eoffset-zlevel-count sum2.0.in1
setp sum2.0.gain0 1000
net eoffset-counts sum2.0.out

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ loadrt logic names=logic-and personality=0x102
addf logic-and servo-thread

# load a summing component for adding spindle lift and Z compensation
loadrt scaled_s32_sums
addf scaled-s32-sums.0 servo-thread
# (eoffset counts are floats, so sum2 rather than scaled_s32_sums)
loadrt sum2
addf sum2.0 servo-thread

loadusr -Wn z_level_compensation z_level_compensation
# method parameter must be one of nearest(2), linear(1), cubic (0)
Expand Down Expand Up @@ -51,8 +52,8 @@ net zpos-cmd z_level_compensation.z-pos <= axis.z.pos-cmd
net z_compensation_on z_level_compensation.enable-in <= qtdragon.comp-on
net eoffset-zlevel-count z_level_compensation.counts => qtdragon.eoffset-zlevel-count

net eoffset-spindle-count scaled-s32-sums.0.in0
net eoffset-zlevel-count scaled-s32-sums.0.in1
setp scaled-s32-sums.0.scale0 1000
net eoffset-counts scaled-s32-sums.0.out-s
net eoffset-spindle-count sum2.0.in0
net eoffset-zlevel-count sum2.0.in1
setp sum2.0.gain0 1000
net eoffset-counts sum2.0.out

10 changes: 5 additions & 5 deletions configs/sim/woodpecker/1280x1024_5axis/woodpecker_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ def init_pins(self):
# external offset control pins
QHAL.newpin("eoffset-enable", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newpin("eoffset-clear", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newpin("eoffset-spindle-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newpin("eoffset-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newpin("eoffset-spindle-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
QHAL.newpin("eoffset-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)

pin = QHAL.newpin("eoffset-value", QHAL.HAL_S32, QHAL.HAL_IN)
pin = QHAL.newpin("eoffset-value", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.value_changed.connect(self.eoffset_changed)

pin = QHAL.newpin("eoffset-zlevel-count", QHAL.HAL_S32, QHAL.HAL_IN)
pin = QHAL.newpin("eoffset-zlevel-count", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.value_changed.connect(self.comp_count_changed)
pin = QHAL.newpin("comp-count", QHAL.HAL_S32, QHAL.HAL_IN)
pin = QHAL.newpin("comp-count", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.value_changed.connect(self.compensate_count_changed)
pin = QHAL.newpin("map-ready", Qhal.HAL_BIT, Qhal.HAL_IN)
pin.value_changed.connect(self.map_ready_changed)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/config/ini-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ Example: `loadrt motmod ... unlock_joints_mask=0x38` creates unlock-pins for joi
[source,hal]
----
axis.<letter>.eoffset-enable
axis.<letter>.eoffset-count
axis.<letter>.eoffset-counts
axis.<letter>.eoffset-scale
----

Expand Down
13 changes: 7 additions & 6 deletions docs/src/gui/qtdragon.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,9 @@ loadrt logic names=logic-and personality=0x102
addf logic-and servo-thread

# load a summing component for adding spindle lift and Z compensation
loadrt scaled_s32_sums
addf scaled-s32-sums.0 servo-thread
# (eoffset counts are floats, so sum2 rather than scaled_s32_sums)
loadrt sum2
addf sum2.0 servo-thread

loadusr -Wn z_level_compensation z_level_compensation
# method parameter must be one of nearest(2), linear(1), cubic (0)
Expand Down Expand Up @@ -872,10 +873,10 @@ net z_compensation_on z_level_compensation.enable-in <= qtdragon.comp-on
net eoffset-zlevel-count z_level_compensation.counts => qtdragon.eoffset-zlevel-count

# add Z level and scaled spindle raise level values together
net eoffset-spindle-count scaled-s32-sums.0.in0
net eoffset-zlevel-count scaled-s32-sums.0.in1
setp scaled-s32-sums.0.scale0 1000
net eoffset-counts scaled-s32-sums.0.out-s
net eoffset-spindle-count sum2.0.in0
net eoffset-zlevel-count sum2.0.in1
setp sum2.0.gain0 1000
net eoffset-counts sum2.0.out

----

Expand Down
5 changes: 3 additions & 2 deletions docs/src/man/man9/motion.9.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,14 @@ These pins represent the *commanded geometric intent* from the interpreter and a
Current external offset.
**axis.**_L_**.eoffset-clear** IN BIT::
Clear external offset request
**axis.**_L_**.eoffset-counts** IN S32::
**axis.**_L_**.eoffset-counts** IN FLOAT::
Counts input for external offset. The eoffset-counts are transferred
to an internal register. The applied external offset is the product of
the register counts and the eoffset-scale value. The register is
*reset to zero at each machine startup*. If the machine is turned off
with an external offset active, the eoffset-counts pin should be set
to zero before restarting.
to zero before restarting. Non-finite values (NaN, infinity) are
ignored.
**axis.**_L_**.eoffset-enable** IN BIT::
Enable for external offset (also requires INI file setting for [AXIS_L]OFFSET_AV_RATIO)
**axis.**_L_**.eoffset-request** OUT FLOAT::
Expand Down
6 changes: 4 additions & 2 deletions docs/src/motion/external-offsets.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For each axis letter (*_L_* in xyzabcuvw)

. *axis._L_.eoffset-enable* Input(bit): enable
. *axis._L_.eoffset-scale* Input(float): scale factor
. *axis._L_.eoffset-counts* Input(s32): input to counts register
. *axis._L_.eoffset-counts* Input(float): input to counts register
. *axis._L_.eoffset-clear* Input(bit): clear requested offset
. *axis._L_.eoffset* Output(float): current external offset
. *axis._L_.eoffset-request* Output(float): requested external offset
Expand All @@ -68,7 +68,9 @@ pins used for wheel jogging.
At each servo period, the 'axis._L_.eoffset-counts' pin is compared to
its value in the prior period. The increase or decrease (positive
or negative delta) of the 'axis._L_.eoffset-counts' pin is multiplied
by the current 'axis._L_.eoffset-scale' pin value. This product is
by the current 'axis._L_.eoffset-scale' pin value. The pin is a float,
so the counts need not be whole numbers; a non-finite value (NaN or
infinity) is ignored and leaves the register unchanged. This product is
accumulated in an internal register and exported to the
'axis._L_.eoffset-request' HAL pin. The accumulation register is reset
to zero at each machine-on.
Expand Down
2 changes: 1 addition & 1 deletion share/qtvcp/screens/qtdragon/qtdragon_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def init_pins(self):
QHAL.newPin("eoffset-enable", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-clear", QHAL.HAL_BIT, QHAL.HAL_OUT)
self.h['eoffset-clear'] = True
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
pin = QHAL.newPin("eoffset-is-active", QHAL.HAL_BIT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.external_offset_state_changed(v))

Expand Down
6 changes: 3 additions & 3 deletions share/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,16 @@ def init_pins(self):
QHAL.newPin("eoffset-enable", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-clear", QHAL.HAL_BIT, QHAL.HAL_OUT)
self.h['eoffset-clear'] = False
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
pin = QHAL.newPin("eoffset-is-active", QHAL.HAL_BIT, QHAL.HAL_IN)


# total external offsets
pin = QHAL.newPin("eoffset-value", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.external_offset_state_changed(v))

pin = QHAL.newPin("eoffset-zlevel-count", QHAL.HAL_S32, QHAL.HAL_IN)
pin = QHAL.newPin("eoffset-zlevel-count", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.comp_count_changed(v))
QHAL.newPin("comp-on", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newPin("spindle-lift-on", QHAL.HAL_BIT, QHAL.HAL_OUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,16 @@ def init_pins(self):
QHAL.newPin("eoffset-enable", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-clear", QHAL.HAL_BIT, QHAL.HAL_OUT)
self.h['eoffset-clear'] = False
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
pin = QHAL.newPin("eoffset-is-active", QHAL.HAL_BIT, QHAL.HAL_IN)


# total external offsets
pin = QHAL.newPin("eoffset-value", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.external_offset_state_changed(v))

pin = QHAL.newPin("eoffset-zlevel-count", QHAL.HAL_S32, QHAL.HAL_IN)
pin = QHAL.newPin("eoffset-zlevel-count", QHAL.HAL_FLOAT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.comp_count_changed(v))
QHAL.newPin("comp-on", Qhal.HAL_BIT, Qhal.HAL_OUT)
QHAL.newPin("spindle-lift-on", Qhal.HAL_BIT, Qhal.HAL_OUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def init_pins(self):
QHAL.newPin("eoffset-enable", QHAL.HAL_BIT, QHAL.HAL_OUT)
QHAL.newPin("eoffset-clear", QHAL.HAL_BIT, QHAL.HAL_OUT)
self.h['eoffset-clear'] = True
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_S32, QHAL.HAL_OUT)
QHAL.newPin("eoffset-spindle-count", QHAL.HAL_FLOAT, QHAL.HAL_OUT)
pin = QHAL.newPin("eoffset-is-active", QHAL.HAL_BIT, QHAL.HAL_IN)
pin.pinValueChanged.connect(lambda p,v: self.external_offset_state_changed(v))

Expand Down
2 changes: 1 addition & 1 deletion share/qtvcp/screens/qtplasmac/qtplasmac_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def make_hal_pins(self):
self.xOffsetPin = self.h.newpin('x_offset', hal.HAL_FLOAT, hal.HAL_IN)
self.yOffsetPin = self.h.newpin('y_offset', hal.HAL_FLOAT, hal.HAL_IN)
self.zHeightPin = self.h.newpin('z_height', hal.HAL_FLOAT, hal.HAL_IN)
self.zOffsetPin = self.h.newpin('z_offset_counts', hal.HAL_S32, hal.HAL_IN)
self.zOffsetPin = self.h.newpin('z_offset_counts', hal.HAL_FLOAT, hal.HAL_IN)
self.xMinPierceExtentPin = self.h.newpin('x_min_pierce_extent', hal.HAL_FLOAT, hal.HAL_IN)
self.xMaxPierceExtentPin = self.h.newpin('x_max_pierce_extent', hal.HAL_FLOAT, hal.HAL_IN)
self.yMinPierceExtentPin = self.h.newpin('y_min_pierce_extent', hal.HAL_FLOAT, hal.HAL_IN)
Expand Down
22 changes: 16 additions & 6 deletions src/emc/motion/axis.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ typedef struct {

double ext_offset_vel_limit; /* upper limit of axis speed for ext offset */
double ext_offset_acc_limit; /* upper limit of axis accel for ext offset */
int old_eoffset_counts;
double old_eoffset_counts;
simple_tp_t ext_offset_tp; /* planner for external coordinate offsets*/
} emcmot_axis_t;

Expand All @@ -44,7 +44,7 @@ typedef struct {

hal_bool_t eoffset_enable;
hal_bool_t eoffset_clear;
hal_sint_t eoffset_counts;
hal_real_t eoffset_counts;
hal_real_t eoffset_scale;
hal_real_t external_offset;
hal_real_t external_offset_requested;
Expand Down Expand Up @@ -135,7 +135,7 @@ int axis_init_hal_io(int mot_comp_id)
CALL_CHECK(hal_pin_new_bool(mot_comp_id, HAL_OUT, &axis_data->teleop_tp_enable, 0, "axis.%c.teleop-tp-enable",c));
CALL_CHECK(hal_pin_new_bool(mot_comp_id, HAL_IN, &axis_data->eoffset_enable, 0, "axis.%c.eoffset-enable", c));
CALL_CHECK(hal_pin_new_bool(mot_comp_id, HAL_IN, &axis_data->eoffset_clear, 0, "axis.%c.eoffset-clear", c));
CALL_CHECK(hal_pin_new_si32(mot_comp_id, HAL_IN, &axis_data->eoffset_counts, 0, "axis.%c.eoffset-counts", c));
CALL_CHECK(hal_pin_new_real(mot_comp_id, HAL_IN, &axis_data->eoffset_counts, 0.0, "axis.%c.eoffset-counts", c));
CALL_CHECK(hal_pin_new_real(mot_comp_id, HAL_IN, &axis_data->eoffset_scale, 0.0, "axis.%c.eoffset-scale", c));
CALL_CHECK(hal_pin_new_real(mot_comp_id, HAL_OUT, &axis_data->external_offset, 0.0, "axis.%c.eoffset", c));
CALL_CHECK(hal_pin_new_real(mot_comp_id, HAL_OUT, &axis_data->external_offset_requested,
Expand Down Expand Up @@ -486,7 +486,7 @@ bool axis_plan_external_offsets(double servo_period, bool motion_enable_flag, bo
int n;
emcmot_axis_t *axis;
axis_hal_t *axis_data;
int new_eoffset_counts, delta;
double new_eoffset_counts, delta, increment;
static int last_eoffset_enable[EMCMOT_MAX_AXIS];
double ext_offset_epsilon;
bool eoffset_active = 0;
Expand All @@ -499,7 +499,14 @@ bool axis_plan_external_offsets(double servo_period, bool motion_enable_flag, bo

axis_data = &hal_data->axis[n];

new_eoffset_counts = hal_get_si32(axis_data->eoffset_counts);
new_eoffset_counts = hal_get_real(axis_data->eoffset_counts);
/* eoffset-counts is a float pin, so a HAL writer can hand us a
non-finite value. Latching it would make every subsequent delta
NaN as well, so keep the previous value and let delta come out
zero instead. */
if (!isfinite(new_eoffset_counts)) {
new_eoffset_counts = axis->old_eoffset_counts;
}
delta = new_eoffset_counts - axis->old_eoffset_counts;
axis->old_eoffset_counts = new_eoffset_counts;

Expand Down Expand Up @@ -548,7 +555,10 @@ bool axis_plan_external_offsets(double servo_period, bool motion_enable_flag, bo
if (!all_homed) { continue; }
if (!motion_enable_flag) { continue; }

axis->ext_offset_tp.pos_cmd += delta * hal_get_real(axis_data->eoffset_scale);
increment = delta * hal_get_real(axis_data->eoffset_scale);
if (!isfinite(increment)) { continue; }

axis->ext_offset_tp.pos_cmd += increment;
hal_set_real(axis_data->external_offset_requested, axis->ext_offset_tp.pos_cmd);
} // for n
first_pass = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/hal/components/eoffset_per_angle.comp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ description
An offset is computed (from one of several functions) based on an input angle
in degrees. The angle could be a rotary coordinate value or a spindle angle.

The computed offset is represented as an s32 *kcounts* output pin that is a
The computed offset is represented as a float *kcounts* output pin that is a
compatible input to external offset pins like *axis.L.eoffset-counts* where *L*
is the coordinate letter. Scaling of the s32 *kcounts* is controlled by the
is the coordinate letter. Scaling of the *kcounts* value is controlled by the
input (*k*) -- its reciprocal value is presented on an output pin *kreciprocal*
for connection to *axis.L.eoffset-scale*. The default value for *k* should be
suitable for most uses.
Expand Down Expand Up @@ -77,7 +77,7 @@ pin out bool is_off "invert is_on (for convenience)";

pin out bool enable_out "To: axis.L.eoffset-enable";
pin out bool clear "To: axis.L.eoffset-clear";
pin out si32 kcounts "To: axis.L.eoffset-counts";
pin out real kcounts "To: axis.L.eoffset-counts";
pin out real kreciprocal "To: axis.L.eoffset-scale (1/k)";

pin out real eoffset_dbg "offset (debug pin--use kcounts & kreciprocal)";
Expand Down Expand Up @@ -137,7 +137,7 @@ static ofunc func0,func1,func2,func3;
#define LVL RTAPI_MSG_INFO
#define dprint(msg,n) do { \
rtapi_set_msg_level(LVL); \
rtapi_print_msg(LVL,"%20s %5d\n",msg,n); \
rtapi_print_msg(LVL,"%20s %9.3f\n",msg,(double)(n)); \
} while (0)
#else
#define dprint(msg,n)
Expand Down
Loading