Skip to content

Commit

Permalink
External Axis Offset hal pins
Browse files Browse the repository at this point in the history
(65: rebased to master at: 2603145 2017-05-20 16:02:37 -0700)

Docs: docs/src/motion/external-offsets.txt

Hal pins (input interface is similar to wheel jogging pins):
  axis.L.eoffset-enable   Input  (bit):   enable
  axis.L.eoffset-scale    Input  (float): scale factor
  axis.L.eoffset-counts   Input  (s32):   request is counts*scale
  axis.L.eoffset-clear    Input  (bit):   clear request
  axis.L.eoffset          Output (float): current external offset
  axis.L.eoffset-request  Output (float): requested external offset (debug pin)

  motion.eoffset-active   Output (bit):   non-zero external offsets applied
  motion.eoffset-limited  Output (bit):   limited by soft limit

Hal components:
    eoffset_per_angle.comp
    eoffset_pid.comp

Sim configs (configs/sim/axis/external_offsets/)
    eoffset_demo.ini    (XYZ ext offsets)
    jwp_z.ini           (jog-while-pause Z)
    dynamic_offsets.ini (dynamic Z)
    opa.ini             (X ext offset per C angle)
    hpid.ini            (torch height control using eoffset_pid)

Notes:
1) see docs/src/motion/external_offsets.txt for usage restrictions
   man updated: motion.9
   new manpage: offset_per_angle.9 (auto by halcompile)
   new manpage: eoffset_pid.9 (auto by halcompile)
2) In canon.hh, option:
     #undef  STOP_ON_SYNCH_IF_EXTERNAL_OFFSETS
     #define STOP_ON_SYNCH_IF_EXTERNAL_OFFSETS
   forces a stop on any synch() if non-zero external
   offsets.

   Use #undef for testing -- works for many cases but not for
   queue-busters within program loops (repeat,while,do-while)
   using gcodes (like g0,g1) that omit axis letters

3) In command.c, using ALT_EOFFSET_BEHAVIOR for cont/incr jogs

Signed-off-by: Dewey Garrett <dgarrett@panix.com>
  • Loading branch information
dngarrett committed Jun 7, 2017
1 parent c73fa85 commit 08ca67a
Show file tree
Hide file tree
Showing 67 changed files with 4,661 additions and 105 deletions.
5 changes: 5 additions & 0 deletions configs/sim/axis/external_offsets/M111
@@ -0,0 +1,5 @@
#!/bin/bash
halcmd setp axisui.notifications-clear-info 1
sleep .1
halcmd setp axisui.notifications-clear-info 0
exit 0
5 changes: 5 additions & 0 deletions configs/sim/axis/external_offsets/README
@@ -0,0 +1,5 @@
eoffset_demo.ini ----- Basic demo (XYZ)
jwp_z.ini ------------ Jog while paused (Z) demo
dynamic_offsets.ini -- Z offset waveforms demo
opa.ini -------------- Offset per Angle (XZC) demo
hpid.ini ------------- Torch height PID demo
48 changes: 48 additions & 0 deletions configs/sim/axis/external_offsets/ccircle.ngc
@@ -0,0 +1,48 @@
o<ccircle> sub
#<r> = #1 (= 1 radius)
#<frate> = #2 (= 2000 feedrate)
#<revs> = #3 (= 2 +/-Revs)

#<ct> = [#<revs> * 360]
#<z> = 0
#<c> = 0


;------------------------------------
g92 C 0
#<C_save> = #5216
#<C_new> = [#<C_save> MOD 360]
o<r1> if [#<C_save> lt 0]
#<C_new> = [#<C_new> -360]
o<r1> endif
g92.1
g10l20p1 C #<C_new>
;------------------------------------

(debug, one moment --> C#<c>)
g0 c#<c>
g0 x#<r> z#<z>
m68 e0 q#<r> ; set radius for eoffsets
(debug, Enable offsets, s to continue)
m1 ; optional stop
m111

f#<frate>
g1 c[#<revs> * 360]
(debug, Disable offsets, s to continue)
m1 ; optional stop
g0 x0

;------------------------------------
g92 C 0
#<C_save> = #5216
#<C_new> = [#<C_save> MOD 360]
o<r2> if [#<C_save> lt 0]
#<C_new> = [#<C_new> -360]
o<r2> endif
g92.1
g10l20p1 C #<C_new>
;------------------------------------
m111
o<ccircle> endsub

33 changes: 33 additions & 0 deletions configs/sim/axis/external_offsets/dyn_demo.ngc
@@ -0,0 +1,33 @@
#<xmax> = 9
#<ymax> = 4
#<zmax> = 3
#<rct> = 100
#<feed> = 100

#<x1> = #<xmax>
#<y1> = 0
#<z1> = [#<zmax> * 0.5]

#<x2> = #<xmax>
#<y2> = #<ymax>
#<z2> = 0

#<x3> = 0
#<y3> = #<ymax>
#<z3> = #<zmax>

m111 ;clear notifications
g61
g0 x0 y0 z0

o<rpt> repeat [#<rct>]
f #<feed>
g0 x 0 y 0 z 0
g1 x #<x1> y #<y1> z #<z1>
g1 x #<x2> y #<y2> z #<z2>
g1 x #<x3> y #<y3> z #<z3>
g1 x 0 y 0 z 0
o<rpt> endrepeat

m111 ;clear notifications
m2
27 changes: 27 additions & 0 deletions configs/sim/axis/external_offsets/dynamic_offsets.halscope
@@ -0,0 +1,27 @@
THREAD servo-thread
MAXCHAN 8
HMULT 4
HZOOM 1
HPOS 5.186916e-01
CHAN 1
SIG E:z-offset
VSCALE -1
VPOS 0.398564
VOFF 0.000000e+00
CHAN 2
SIG G:waveform
VSCALE -1
VPOS 0.398564
VOFF 0.000000e+00
CHAN 4
SIG G:reset
VSCALE 2
VPOS 0.961120
VOFF 0.000000e+00
CHAN 3
PIN joint.2.motor-pos-cmd
VSCALE 0
VPOS 0.900000
VOFF 0.000000e+00
TMODE 0
RMODE 0
81 changes: 81 additions & 0 deletions configs/sim/axis/external_offsets/dynamic_offsets.ini
@@ -0,0 +1,81 @@
[APPLICATIONS]
# delay because some items are done in postgui
DELAY = 5
APP = halscope -i dynamic_offsets.halscope

[HAL]
HALUI = halui
HALFILE = LIB:basic_sim.tcl
POSTGUI_HALFILE = dynamic_offsets_panel.hal

[EMC]
MACHINE = Dynamic External Offsets
VERSION = 1.0

[DISPLAY]
PYVCP = dynamic_offsets_panel.xml
DISPLAY = axis
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_LINEAR_VELOCITY = 2
OPEN_FILE = ./dyn_demo.ngc

[TASK]
TASK = milltask
CYCLE_TIME = 0.001

[RS274NGC]
USER_M_PATH = .
PARAMETER_FILE = sim.var

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100

[EMCMOT]
EMCMOT = motmod
SERVO_PERIOD = 1000000

[TRAJ]
COORDINATES = XYZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree

[KINS]
JOINTS = 3
KINEMATICS = trivkins coordinates=XYZ

[AXIS_X]
MAX_VELOCITY = 2
MAX_ACCELERATION = 20
MIN_LIMIT = -1
MAX_LIMIT = 10

[AXIS_Y]
MAX_VELOCITY = 2
MAX_ACCELERATION = 20
MIN_LIMIT = -1
MAX_LIMIT = 10

[AXIS_Z]
# Note:give half to external_offsets:
OFFSET_AV_RATIO = 0.5

# Note: modified in pyvcp panel:
MAX_VELOCITY = 2
MAX_ACCELERATION = 50

MIN_LIMIT = -5
MAX_LIMIT = 5

[JOINT_0]
TYPE = LINEAR
HOME_SEQUENCE = 0

[JOINT_1]
TYPE = LINEAR
HOME_SEQUENCE = 0

[JOINT_2]
TYPE = LINEAR
HOME_SEQUENCE = 0
32 changes: 32 additions & 0 deletions configs/sim/axis/external_offsets/dynamic_offsets.txt
@@ -0,0 +1,32 @@
dynamic_offsets

A sinewave is applied to the Z coordinate external offset

The waveform amplitdude and frequency are set by pyvcp panel spinboxes.

The Z coordinate max acceleration and max velocity settings (from the ini file) can be modified with pyvcp panel spinboxes.

Usage:
1) Estop OFF (F1)
2) Machine ON (F2)
3) HOME All (Ctrl-Home)
4) A halscope application is started to
show the offset waveforms and the
z coordinate response
5) Enable the dynamic offset waveform
with the panel 'Z enable' checkbox
5) Use the panel to adjust:
Waveform: amplitude, frequency
Z Coordinate: max accel, max vel

Notes:
The dynamic waveform is applied with and without
running a program.

MDI cannot be started with non-zero external
offsets -- disable the Z offsets and toggle
the machine On/Off to zero offsets.

Changes to the Z max accel, max vel are not
made while a program or mdi move is in progress.

46 changes: 46 additions & 0 deletions configs/sim/axis/external_offsets/dynamic_offsets_panel.hal
@@ -0,0 +1,46 @@
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

setp gen.offset 0.0

# scaling -----------------------------------------------------------
# these should be reciprocals:
# 1 unit (inch) --> 10000 counts
setp axis.z.eoffset-scale 0.0001
setp scalea.gain 10000

net E:amplitude <= pyvcp.gen-amplitude => gen.amplitude
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 E:enable <= pyvcp.z-enable => axis.z.eoffset-enable
net E:enable => nota.in

net E:disable <= nota.out => or2a.in1

net E:z-offset <= axis.z.eoffset => pyvcp.z-offset-f

net E:limited <= motion.eoffset-limited => pyvcp.eoffset-limited

net E:active <= motion.eoffset-active => pyvcp.eoffset-active

net E:reset <= pyvcp.reset => or2a.in0

net E:ini-accel <= pyvcp.ini-accel => ini.z.max_acceleration
net E:ini-vel <= pyvcp.ini-vel => ini.z.max_velocity

net G:reset <= or2a.out => axis.z.eoffset-clear
net G:reset => gen.reset

0 comments on commit 08ca67a

Please sign in to comment.