kitamura_test/New Folder/pyvcp_demo1.xml 0000644 0001750 0001750 00000034640 13365511272 021073 0 ustar linuxcnc linuxcnc
("Helvetica",10)
3SUNKEN"spinbox0"-1233100.1"2.3f"
("Arial",16)
1"spinbox1"-1233200.1"2.3f"
("Arial",16)
1"spinbox2"-1233300.1"2.3f"
("Arial",16)
1
("Helvetica",16)
"30""scale0"1HORIZONTAL501001
("Helvetica",16)
"30""scale1"1HORIZONTAL1501001
("Helvetica",16)
"30""scale2"1HORIZONTAL2501001"number0"
("Helvetica",16)
"+4.4f""number1"
("Helvetica",16)
"+4.4f""number2"
("Helvetica",16)
"+4.4f"
("Helvetica",10)
3RAISED1501000100"Dial0"100.01"dial0""yellow""green""black"11501000100"Dial1"120.1"dial1""green""red""black"11501000100"Dial2"51"dial2""yellow""green""black"1
("Helvetica",16)
"25""scale3"0.01VERTICAL101001
("Helvetica",16)
"25""scale4"0.1VERTICAL1001001
("Helvetica",16)
"25""scale5"1VERTICAL2001001
("Helvetica",10)
3FLAT["one","two","three"]"radio0"0["four","five","six"]"radio1"1["Radio1-Selected","Now Radio2-Selected","And Now Radio3-Selected"]
("Helvetica", 10)
True0["Radio4-Selected","Now Radio5-Selected","And Now Radio6-Selected"]
("Helvetica", 10)
True1
("Helvetica",10)
3GROOVE"checkbutton0""Button 0"1"checkbutton1""Button 1"0"checkbutton2""Button 2"0"checkbutton3""Button 3"0"checkbutton4""Button 4"1"checkbutton5""Button 5"0"led0"30"green""red""led1"30"green""red""led2"30"green""red""led3"30"green""red""led4"30"green""red""led5"30"green""red"
("Helvetica",10)
3RIDGE"my-bar"0150"grey"(0,100,"green")(101,129,"orange")(130,150,"red")"green"
("Helvetica",16)
"25""my-hscale"1HORIZONTAL00150
kitamura_test/New Folder/pyvcp_demo1.hal 0000644 0001750 0001750 00000003021 13365511272 021024 0 ustar linuxcnc linuxcnc # #########################################
# Example hal file showing some linkages
# of pyvcp_widgets
# top row of scales and spinboxes
net scale2spin1 pyvcp.scale0-f => pyvcp.spinbox.0.param_pin => pyvcp.number0
net scale2spin3 pyvcp.scale1-f => pyvcp.spinbox.1.param_pin => pyvcp.number1
net scale2spin5 pyvcp.scale2-f => pyvcp.spinbox.2.param_pin => pyvcp.number2
# second row of dials and scales
net dial2scale0 pyvcp.scale.3.param_pin <= pyvcp.dial0
net dial2scale2 pyvcp.scale.4.param_pin <= pyvcp.dial1
net dial2scale4 pyvcp.scale.5.param_pin <= pyvcp.dial2
# third row of label and led activating radio buttons
net 1pressed pyvcp.multilabel.0.legend0 <= pyvcp.radio0.one
net 2pressed pyvcp.multilabel.0.legend1 <= pyvcp.radio0.two
net 3pressed pyvcp.multilabel.0.legend2 <= pyvcp.radio0.three
net 4pressed pyvcp.multilabel.1.legend0 <= pyvcp.radio1.four
net 5pressed pyvcp.multilabel.1.legend1 <= pyvcp.radio1.five
net 6pressed pyvcp.multilabel.1.legend2 <= pyvcp.radio1.six
net cb0active pyvcp.checkbutton0 => pyvcp.led0
net cb1active pyvcp.checkbutton1 => pyvcp.led1
net cb2active pyvcp.checkbutton2 => pyvcp.led2
net cb3active pyvcp.checkbutton3 => pyvcp.led3
net cb4active pyvcp.checkbutton4 => pyvcp.led4
net cb5active pyvcp.checkbutton5 => pyvcp.led5
# fourth row checkboxes with checkbox0 toggled by push button
net toggle0 pyvcp.checkbutton0.changepin <= pyvcp.toggle-button0
net toggle1 pyvcp.checkbutton5.changepin <= pyvcp.toggle-button1
# sixth row 3 colour bar activated by slider
net bar1 pyvcp.my-bar <= pyvcp.my-hscale-f
kitamura_test/hallib/xhc-hb04-layout1.cfg 0000644 0000000 0000000 00000000570 13542571435 017270 0 ustar root root [XHC-HB04]
BUTTON=01:button-stop
BUTTON=02:button-start-pause
BUTTON=03:button-rewind
BUTTON=04:button-safe-z
BUTTON=05:button-home
BUTTON=06:button-x2
BUTTON=07:button-y2
BUTTON=08:button-probe-z
BUTTON=09:button-x0
BUTTON=0A:button-y0
BUTTON=0B:button-z0
BUTTON=0C:button-goto-zero
BUTTON=0D:button-step
BUTTON=0E:button-mode
BUTTON=0F:button-spindle
BUTTON=17:button-reset
kitamura_test/hallib/check_config.tcl 0000644 0000000 0000000 00000016013 13542571435 017003 0 ustar root root # check_config.tcl
# Usage: tclsh path_to_this_file inifilename
# if a check fails, print message and exit 1
#
# checks:
# 1) mandatory items per ::mandatory_items list
# 2) if trivkins, check consistency of [JOINT_] and [AXIS_]
# MIN_LIMIT and MAX_LIMIT
#----------------------------------------------------------------------
set ::mandatory_items {KINS KINEMATICS
KINS JOINTS
}
# Ref: src/emc/nml_intf/emccfg.h,src/emc/ini/inijoint.cc,src/emc/iniaxis.cc:
set ::DEFAULT_AXIS_MAX_VELOCITY 1.0
set ::DEFAULT_AXIS_MAX_ACCELERATION 1.0
set ::DEFAULT_JOINT_MAX_VELOCITY 1.0
set ::DEFAULT_JOINT_MAX_ACCELERATION 1.0
# Ref: src/emc/ini/iniaxis.cc:
set ::DEFAULT_AXIS_MIN_LIMIT -1e99
set ::DEFAULT_AXIS_MAX_LIMIT +1e99
#----------------------------------------------------------------------
proc warnings msg {
puts "\n$::progname: ($::kins(module) kinematics) WARNING:"
foreach m $msg {puts " $m"}
puts ""
} ;# warnings
proc err_exit msg {
puts "\n$::progname: ($::kins(module) kinematics) ERROR:"
foreach m $msg {puts " $m"}
puts ""
exit 1
} ;# err_exit
proc check_mandatory_items {} {
foreach {section item} $::mandatory_items {
if ![info exists ::[set section]($item) ] {
set section [string trim $section :]
lappend emsg "Missing \[$section\]$item="
}
}
if [info exists emsg] {
err_exit $emsg
}
} ;# check_mandatory_items
proc uniq {list_name} { ;# make list unique
foreach item $list_name { set tmp($item) "" }
return [array names tmp]
} ;# uniq
proc joints_for_trivkins {coords} {
# ref: src/emc/kinematics/trivkins.c
# order of coord letters determines assigned joint number
if {"$coords" == ""} {set coords {X Y Z A B C U V W}}
set i 0
foreach a [string toupper $coords] {
# assign to consecutive joints:
lappend ::kins(jointidx,$a) $i
incr i
}
} ;# joints_for_trivkins
proc consistent_coords_for_trivkins {trivcoords} {
set m {" " "" "\t" ""} ;# mapping to remove whitespace
set trivcoords [string map $m $trivcoords]
if {"$trivcoords" == "XYZABCUVW"} {
return ;# unspecified trivkins coordinates
# allows use of any coordinates
}
set trajcoords ""
if [info exists ::TRAJ(COORDINATES)] {
set trajcoords [string map $m [lindex $::TRAJ(COORDINATES) 0]]
}
if {[string toupper "$trivcoords"] != [string toupper "$trajcoords"]} {
lappend ::wmsg "INCONSISTENT coordinates specifications:
trivkins coordinates=$trivcoords
\[TRAJ\]COORDINATES=$trajcoords"
}
} ;# consistent_coords_for_trivkins
proc validate_identity_kins_limits {} {
set emsg ""
for {set j 0} {$j < $::KINS(JOINTS)} {incr j} {
if {![info exists ::JOINT_[set j](MAX_VELOCITY)] } {
lappend ::wmsg "Unspecified \[JOINT_$j\]MAX_VELOCITY, default used: $::DEFAULT_JOINT_MAX_VELOCITY"
}
if {![info exists ::JOINT_[set j](MAX_ACCELERATION)] } {
lappend ::wmsg "Unspecified \[JOINT_$j\]MAX_ACCELERATION, default used: $::DEFAULT_JOINT_MAX_ACCELERATION"
}
}
foreach c [uniq $::kins(coordinates)] {
# array test avoids superfluous messages when coordinates= not specified
if [array exists ::AXIS_[set c]] {
if {![info exists ::AXIS_[set c](MAX_VELOCITY)] } {
lappend ::wmsg "Unspecified \[AXIS_$c\]MAX_VELOCITY, default used: $::DEFAULT_AXIS_MAX_VELOCITY"
}
if {![info exists ::AXIS_[set c](MAX_ACCELERATION)] } {
lappend ::wmsg "Unspecified \[AXIS_$c\]MAX_ACCELERATION, default used: $::DEFAULT_AXIS_MAX_ACCELERATION"
}
}
set missing_axis_min_limit 0
set missing_axis_max_limit 0
if ![info exists ::AXIS_[set c](MIN_LIMIT)] {
set ::AXIS_[set c](MIN_LIMIT) $::DEFAULT_AXIS_MIN_LIMIT
set missing_axis_min_limit 1
}
if ![info exists ::AXIS_[set c](MAX_LIMIT)] {
set ::AXIS_[set c](MAX_LIMIT) $::DEFAULT_AXIS_MAX_LIMIT
set missing_axis_max_limit 1
}
foreach j $::kins(jointidx,$c) {
if [info exists ::JOINT_[set j](MIN_LIMIT)] {
set jlim [set ::JOINT_[set j](MIN_LIMIT)]
set clim [set ::AXIS_[set c](MIN_LIMIT)]
if {$jlim > $clim} {
if $missing_axis_min_limit {
lappend ::wmsg "Unspecified \[AXIS_$c\]MIN_LIMIT, default used: $::DEFAULT_AXIS_MIN_LIMIT"
}
lappend emsg "\[JOINT_$j\]MIN_LIMIT > \[AXIS_$c\]MIN_LIMIT ($jlim > $clim)"
}
}
if [info exists ::JOINT_[set j](MAX_LIMIT)] {
set jlim [set ::JOINT_[set j](MAX_LIMIT)]
set clim [set ::AXIS_[set c](MAX_LIMIT)]
if {$jlim < $clim} {
if $missing_axis_max_limit {
lappend ::wmsg "Unspecified \[AXIS_$c\]MAX_LIMIT, default used: $::DEFAULT_AXIS_MAX_LIMIT"
}
lappend emsg "\[JOINT_$j\]MAX_LIMIT < \[AXIS_$c\]MAX_LIMIT ($jlim < $clim)"
}
}
}
}
return $emsg
} ;# validate_identity_kins_limits
proc check_extrajoints {} {
if ![info exists ::EMCMOT(EMCMOT)] return
if {[string first motmod $::EMCMOT(EMCMOT)] <= 0} return
set mot [split [lindex $::EMCMOT(EMCMOT) 0]]
foreach item $mot {
set pair [split $item =]
set parm [lindex $pair 0]
set val [lindex $pair 1]
if {"$parm" == "num_extrajoints"} {
set ::num_extrajoints $val
}
}
if [info exists ::num_extrajoints] {
lappend ::wmsg [format "Extra joints specified=%d\n \
\[KINS\]JOINTS=%d must accomodate kinematic joints *plus* extra joints " \
$::num_extrajoints $::KINS(JOINTS)]
}
} ;#check_extrajoints
#----------------------------------------------------------------------
# begin
package require Linuxcnc ;# parse_ini
set ::progname [file rootname [file tail [info script]]]
set inifile [lindex $::argv 0]
if ![file exists $inifile] {
err_exit [list "No such file <$inifile>"]
}
if ![file readable $inifile] {
err_exit [list "File not readable <$inifile>"]
}
parse_ini $inifile
check_mandatory_items
set kins_kinematics [lindex $::KINS(KINEMATICS) end]
set ::kins(module) [lindex $kins_kinematics 0]
# parameters specified as parm=value --> ::kins(parm)=value
foreach item $kins_kinematics {
if {[string first = $item] >= 0} {
set l [split $item =]
set ::kins([lindex $l 0]) [lindex $l 1]
} else {
if {"$item" != $::kins(module)} {
puts "Unknown \[KINS\]KINEMATICS item: <$item>"
}
}
}
# coordinates --> ::kins(coordinates) (all if not specified)
if [info exists ::kins(coordinates)] {
set ::kins(coordinates) [split $::kins(coordinates) ""]
set ::kins(coordinates) [string toupper $::kins(coordinates)]
} else {
set ::kins(coordinates) {X Y Z A B C U V W}
}
# list of joints for each coord --> ::kins(jointidx,coordinateletter)
switch $::kins(module) {
trivkins {joints_for_trivkins $::kins(coordinates)}
default {
puts "$::progname: Unchecked: \[KINS\]KINEMATICS=$::KINS(KINEMATICS)"
exit 0
}
}
check_extrajoints
#parray ::kins
set emsg [validate_identity_kins_limits]
consistent_coords_for_trivkins $::kins(coordinates)
if [info exists ::wmsg] {warnings $::wmsg}
if {"$emsg" == ""} {exit 0}
err_exit $emsg
kitamura_test/hallib/lathe.hal 0000644 0000000 0000000 00000004443 13542571435 015464 0 ustar root root # counting the spindle encoder in software
loadrt encoder names=encoder_0
# simulate the encoder
loadrt sim_encoder names=sim_encoder_0
loadrt limit2 names=limit_speed
addf limit_speed servo-thread
#######################################################
# Beginning of threading related stuff
#######################################################
# spindle speed control
net spindle-speed-cmd spindle.0.speed-out => limit_speed.in
net spindle-speed-limited limit_speed.out => sim_encoder_0.speed
# simulate spindle mass
setp limit_speed.maxv 500.0 # rpm/second
# spindle encoder
# connect encoder signals to encoder counter
net spindle-phase-A sim_encoder_0.phase-A => encoder_0.phase-A
net spindle-phase-B sim_encoder_0.phase-B => encoder_0.phase-B
net spindle-phase-Z sim_encoder_0.phase-Z => encoder_0.phase-Z
# assume 120 ppr = 480 counts/rev for the spindle
setp sim_encoder_0.ppr 120
# iocontrol output is in rpm, but sim-encoder speed is rps
setp sim_encoder_0.scale 60
# scale encoder output to read in revolutions
# (that way thread pitches can be straightforward,
# a 20 tpi thread would multiply the encoder output
# by 1/20, etc)
setp encoder_0.position-scale 480
# encoder reset control
# hook up motion controller's sync output
net spindle-index-enable spindle.0.index-enable <=> encoder_0.index-enable
# report our revolution count to the motion controller
net spindle-pos encoder_0.position => spindle.0.revs
# for spindle velocity estimate
loadrt lowpass names=lowpass_velocity
loadrt scale names=scale_to_rpm
net spindle-rps-raw encoder_0.velocity lowpass_velocity.in
net spindle-rps-filtered lowpass_velocity.out scale_to_rpm.in spindle.0.speed-in
net spindle-rpm-filtered scale_to_rpm.out
setp scale_to_rpm.gain 60
setp lowpass_velocity.gain .07
addf lowpass_velocity servo-thread
addf scale_to_rpm servo-thread
# for at-speed detection
loadrt near names=near_speed
addf near_speed servo-thread
setp near_speed.scale 1.1
setp near_speed.difference 10
net spindle-speed-cmd => near_speed.in1
net spindle-rpm-filtered => near_speed.in2
net spindle-at-speed near_speed.out spindle.0.at-speed
net spindle-fwd <= spindle.0.forward
addf encoder.capture-position servo-thread
addf sim-encoder.update-speed servo-thread
addf sim-encoder.make-pulses base-thread
addf encoder.update-counters base-thread
kitamura_test/hallib/core_stepper.hal 0000644 0000000 0000000 00000003747 13542571435 017067 0 ustar root root # core HAL config file for steppers
# first load the core RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# stepper module, three step generators, all three using step/dir
loadrt stepgen step_type=0,0,0
# hook functions to base thread (high speed thread for step generation)
addf stepgen.make-pulses base-thread
# hook functions to servo thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
# connect position commands from motion module to step generator
net Xpos-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
net Ypos-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
net Zpos-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
# connect position feedback from step generators
# to motion module
net Xpos-fb stepgen.0.position-fb => joint.0.motor-pos-fb
net Ypos-fb stepgen.1.position-fb => joint.1.motor-pos-fb
net Zpos-fb stepgen.2.position-fb => joint.2.motor-pos-fb
# connect enable signals for step generators
net Xen joint.0.amp-enable-out => stepgen.0.enable
net Yen joint.1.amp-enable-out => stepgen.1.enable
net Zen joint.2.amp-enable-out => stepgen.2.enable
# connect signals to step pulse generator outputs
net Xstep <= stepgen.0.step
net Xdir <= stepgen.0.dir
net Ystep <= stepgen.1.step
net Ydir <= stepgen.1.dir
net Zstep <= stepgen.2.step
net Zdir <= stepgen.2.dir
# set stepgen module scaling - get values from ini file
setp stepgen.0.position-scale [JOINT_0]SCALE
setp stepgen.1.position-scale [JOINT_1]SCALE
setp stepgen.2.position-scale [JOINT_2]SCALE
# set stepgen module accel limits - get values from ini file
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
kitamura_test/hallib/README 0000644 0000000 0000000 00000006506 13542571435 014563 0 ustar root root This directory contains halfiles (*.hal and *.tcl) that are available
using the LinuxCNC halfile search path or by an explicit directive.
The HALLIB_PATH is '.:HALLIB_DIR'
The '.' specifies the directory containing the ini file.
HALIB_DIR specifies this directory.
The explicit directive uses a prefix (LIB:) to identify halfiles:
[HAL]
HALFILE = LIB:filename.[hal|tcl]
The LinuxCNC startup script (linuxcnc) finds each halfile using the
HALLIB_PATH unless the explicit directive is used.
Also included in this directory are files associated with included
system halfiles. For example, the button layout files
(xhc-hb04-layout*.cfg) that are used with the halfile xhc-hb04.tcl.
------------------------------------------------------------------------
Hal files (*.hal) Notes
----------------------- ---------------------------------------------
axis_manualtoolchange.hal setup for using hal_manualtoolchange
(for axis or other guis)
core_sim.hal xyz simulator config
core_servo.hal xyz servo (pid) config
core_sim9.hal 9 axis (xyzabcuvw) simulation config
core_stepper.hal xyz stepper config
gantrysim.hal gantrykins config, 4 joints: X Y Y Z
lathe.hal simulate spindle with encoder,sim_encoder
locking_indexer.hal simulate locking rotary using timedelay comp
wheeljogpins.tcl enable wheel jog pins for joints & axes
moveoff_external.hal Simulate external control connections for
a moveoff component
servo_sim.hal simulate servo (pid) xyz using lowpass comp
sim_spindle_encoder.hal simulate spindle with lowpass filter
simulated-gantry-home.hal simulate gantry home switches (4 joints)
simulated_home.hal simulate xyz home switches
simulated_limits.hal simulate xyz limit switches
tripodsim.hal simulated tripodkins system
Haltcl Files (*.tcl) Notes
----------------------- ---------------------------------------------
basic_sim.tcl set up a sim config (arbitrary no. of axes)
var_show.tcl show ini variables and context
hookup_moveoff.tcl make connections for a moveoff component
xhc-hb04.tcl Configuration builder for xhc-hb04 pendant
xhc-hb04-layout1.cfg button layout 1 for xhc-hb04.tcl
xhc-hb04-layout2.cfg button layout 2 for xhc-hb04.tcl
halcheck.tcl Report: 1) functions without addf
2) signals with no inputs
3) signals with no output
Haltcl libs (*_lib.tcl) Notes
----------------------- ---------------------------------------------
sim_lib.tcl simulator config procedures
procs:
core_sim (arbitrary axes)
make-ddts (arbitrary axes)
simulated_home (arbitrary axes)
use_hal_manualtoolchange
sim_spindle
util_lib.tcl utility procedures
procs:
show_context (calling parms)
show_ini (ini file settings)
show_env (environmental vars)
kitamura_test/hallib/hal_procs_lib.tcl 0000644 0000000 0000000 00000014113 13542571435 017200 0 ustar root root # hal_procs_lib.tcl
package require Hal ;# provides hal commands
proc pin_exists {name} {
# return 1 if pin exists
if { [lindex [hal list pin "$name"] 0] == "$name"} {return 1}
return 0
} ;# pin_exists
proc connection_info {result_name pinname } {
# return 0 if pinname not found, else 1
# result_name is associative array with details
# owner type direction value separator signame
upvar $result_name ay
set ans [hal show pin $pinname]
set lines [split $ans \n]
set sig ""
set sep ""
set ct [scan [lindex $lines 2] "%s %s %s %s %s %s %s" \
owner type dir val name sep sig]
if {$ct <0} {
return 0
}
set ay(owner) $owner
set ay(type) $type
set ay(direction) $dir
set ay(value) $val
set ay(separator) $sep
set ay(signame) $sig
return 1
} ;# connection_info
proc is_connected {pinname {signame {} } } {
# return is_input or is_output or is_io or not_connected
# set signame to signal name if connected
upvar $signame thesig
set ans [hal show pin $pinname]
set lines [split $ans \n]
set thesig ""
set sep ""
set ct [scan [lindex $lines 2] "%s %s %s %s %s %s %s" \
owner type dir val name sep thesig]
if {$ct <0} {return not_connected}
if {"$sep" == "<=="} {return is_input}
if {"$sep" == "==>"} {return is_output}
if {"$sep" == "<=>"} {return is_io}
return "not_connected"
} ;# is_connected
proc thread_info {ay_name} {
# return details about threads in associative array ay_name
# items for each $threadname:
# ($threadname,$componentname) $threadname index for $componentname
# ($threadname,fp) $threadname uses floatingpoint
# ($threadname,period) $threadname period
# ($threadname,index,last) $threadname last index used
#
# motion specific items:
# (motion-command-handler,threadname) threadname
# (motion-command-handler,index) index
# (motion-controller,threadname) threadname
# (motion-controller,index) index
# other:
# (threadnames) list of all threanames
#
# return string is $ay(motion-controller,threadname)
upvar $ay_name ay
set ans [hal show thread]
set lines [split $ans \n]
set header_len 2
set lines [lreplace $lines 0 [expr $header_len -1]]
set lines [lreplace $lines end end]
set remainder ""
set ct 0
foreach line $lines {
catch {unset f1 f2 f3 f4}
scan [lindex $lines $ct] \
"%s %s %s %s" \
f1 f2 f3 f4
if ![info exists f3] {
set index $f1; set compname $f2
set ay($threadname,$compname) $index
set ay($threadname,index,last) $index
if {"$compname" == "motion-command-handler"} {
set ay(motion-command-handler,threadname) $threadname
set ay(motion-command-handler,index) $index
}
if {"$compname" == "motion-controller"} {
set ay(motion-controller,threadname) $threadname
set ay(motion-controller,index) $index
}
} else {
set period $f1; set fp $f2; set threadname $f3
lappend ay(threadnames) $threadname
set ay($threadname,fp) $fp
set ay($threadname,period) $period
}
incr ct
}
if [info exists ay(motion-controller,threadname)] {
if [info exists ay(motion-command-handler,threadname)] {
if { "$ay(motion-controller,threadname)" \
!= "$ay(motion-command-handler,threadname)" \
} {
return -code error "thread_info: mot funcs on separate threads"
if { $ay(motion-command-handler,index) \
> $ay(motion-controller,index) \
} {
return -code error "thread_info: mot funcs OUT-OF-SEQUENCE"
}
}
return $ay(motion-controller,threadname)
} else {
return -code error "thread_info: motion-controller not found"
}
}
} ;# thread_info
proc get_netlist {inpins_name outpin_name iopins_name signame} {
# input: signame
# outputs:
# inpins_name list of input pins for signame or ""
# iopins_name list of io pins for signame or ""
# outpin_name output pin for signame or ""
upvar $inpins_name inpins
upvar $iopins_name iopins
upvar $outpin_name outpin
set inpins ""
set iopins ""
set outpin ""
set header_len 2
set lines [split [hal show signal $signame] \n]
set lines [lreplace $lines 0 [expr $header_len -1]]
set lines [lreplace $lines end end]
set ct 0
foreach line $lines {set l($ct) [string trim $line];incr ct}
set ct_max $ct
set ct 0
for {set ct 0} {$ct < $ct_max} {incr ct} {
set v0 [lindex $l($ct) 0]
set v1 [lindex $l($ct) 1]
set v2 [lindex $l($ct) 2]
switch $v0 {
float -
bit -
u32 -
s32 {set sname $v2} ;# set on 1st non-header line
"==>" {}
"<==" {}
"<=>" {}
* {return -code error "get_netlist: Unexpected <$line">}
}
if {"$signame"=="$sname"} {
switch $v0 {
"==>" {lappend inpins $v1}
"<==" {lappend outpin $v1}
"<=>" {lappend iopins $v1}
}
}
}
} ;# get_netlist
proc find_file_in_hallib_path {filename {inifile .}} {
# find halfile using path HALLIB_PATH=.:HALLIB_DIR (see scripts/linuxcnc.in)
set libtag LIB: ;# special prefix for explicit use of hallib file
set halname [lindex $filename end]
if {[string first "$libtag" $halname] == 0} {
# explicit $libtag used
set halname [string range $halname [string len $libtag] end]
set usehalname [file join $::env(HALLIB_DIR) $halname]
} else {
if {[file pathtype $filename] == "absolute"} {
set usehalname $filename
} else {
# relative file specifier (relative to ini file directory)
set usehalname [file join [file dirname $inifile] $halname]
if ![file readable $usehalname] {
# use ::env(HALLIB_DIR)
set usehalname [file join $::env(HALLIB_DIR) $halname]
}
}
}
if [file readable $usehalname] {
return $usehalname
}
return -code error "find_file_in_hallib_path: cannot find: <$filename>"
} ;# find_file_in_hallib_path
kitamura_test/hallib/core_sim.hal 0000644 0000000 0000000 00000003453 13542571435 016167 0 ustar root root # core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# load 6 differentiators (for velocity and accel signals
loadrt ddt names=ddt_x,ddt_xv,ddt_y,ddt_yv,ddt_z,ddt_zv
# load additional blocks
loadrt hypot names=vel_xy,vel_xyz
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# link the differentiator functions into the code
addf ddt_x servo-thread
addf ddt_xv servo-thread
addf ddt_y servo-thread
addf ddt_yv servo-thread
addf ddt_z servo-thread
addf ddt_zv servo-thread
addf vel_xy servo-thread
addf vel_xyz servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt_x.in
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt_y.in
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt_z.in
# send the position commands thru differentiators to
# generate velocity and accel signals
net Xvel ddt_x.out => ddt_xv.in vel_xy.in0
net Xacc <= ddt_xv.out
net Yvel ddt_y.out => ddt_yv.in vel_xy.in1
net Yacc <= ddt_yv.out
net Zvel ddt_z.out => ddt_zv.in vel_xyz.in0
net Zacc <= ddt_zv.out
# Cartesian 2- and 3-axis velocities
net XYvel vel_xy.out => vel_xyz.in1
net XYZvel <= vel_xyz.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
kitamura_test/hallib/simulated-gantry-home.hal 0000644 0000000 0000000 00000002267 13542571435 020610 0 ustar root root
loadrt comp names=comp_j0,comp_j1,comp_j2,comp_j3
loadrt or2 names=or_homesws
# Joint 0 = X axis, home switch is on negative end
# Joint 1 = Y1 axis, home switch is on negative end
# Joint 2 = Z axis, home switch is on positive end
# Joint 3 = Y2 axis, home switch is on negative end
net J0homeswpos => comp_j0.in1
net J1homeswpos => comp_j1.in1
net J2homeswpos => comp_j2.in0
net J3homeswpos => comp_j3.in1
sets J0homeswpos -0.1
sets J1homeswpos -0.1
sets J2homeswpos 0.1
sets J3homeswpos -0.1
net J0pos => comp_j0.in0
net J1pos => comp_j1.in0
net J2pos => comp_j2.in1
net J3pos => comp_j3.in0
setp comp_j0.hyst .02
setp comp_j1.hyst .02
setp comp_j2.hyst .02
setp comp_j3.hyst .02
# the X and Z joints share a home switch
# the Y joints each have their own home switches
net J0homesw <= comp_j0.out
net J1homesw <= comp_j1.out => joint.1.home-sw-in
net J2homesw <= comp_j2.out
net J3homesw <= comp_j3.out => joint.3.home-sw-in
net J0homesw => or_homesws.in0
net J2homesw => or_homesws.in1
net J0.J1homesw or_homesws.out => joint.0.home-sw-in joint.2.home-sw-in
addf comp_j0 servo-thread
addf comp_j1 servo-thread
addf comp_j2 servo-thread
addf comp_j3 servo-thread
addf or_homesws servo-thread
kitamura_test/hallib/core_servo.hal 0000644 0000000 0000000 00000004357 13542571435 016541 0 ustar root root # core HAL config file for servos
# first load the core RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# PID module, for three PID loops
loadrt pid num_chan=3
# hook functions to realtime thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.0.do-pid-calcs servo-thread
addf pid.1.do-pid-calcs servo-thread
addf pid.2.do-pid-calcs servo-thread
# connect position feedback
net Xpos-fb joint.0.motor-pos-fb => pid.0.feedback
net Ypos-fb joint.1.motor-pos-fb => pid.1.feedback
net Zpos-fb joint.2.motor-pos-fb => pid.2.feedback
# create PID to DAC output signals
net Xoutput <= pid.0.output
net Youtput <= pid.1.output
net Zoutput <= pid.2.output
# set PID loop output limits to +/-1.00
setp pid.0.maxoutput [JOINT_0]MAX_VELOCITY
setp pid.1.maxoutput [JOINT_1]MAX_VELOCITY
setp pid.2.maxoutput [JOINT_2]MAX_VELOCITY
# set PID loop gains from inifile
# the values below come from the ini
setp pid.0.Pgain [JOINT_0]P
setp pid.0.Igain [JOINT_0]I
setp pid.0.Dgain [JOINT_0]D
setp pid.0.bias [JOINT_0]BIAS
setp pid.0.FF0 [JOINT_0]FF0
setp pid.0.FF1 [JOINT_0]FF1
setp pid.0.FF2 [JOINT_0]FF2
# deadband should be just over 1 count
setp pid.0.deadband [JOINT_0]DEADBAND
setp pid.1.Pgain [JOINT_1]P
setp pid.1.Igain [JOINT_1]I
setp pid.1.Dgain [JOINT_1]D
setp pid.1.bias [JOINT_1]BIAS
setp pid.1.FF0 [JOINT_1]FF0
setp pid.1.FF1 [JOINT_1]FF1
setp pid.1.FF2 [JOINT_1]FF2
# deadband should be just over 1 count
setp pid.1.deadband [JOINT_1]DEADBAND
setp pid.2.Pgain [JOINT_2]P
setp pid.2.Igain [JOINT_2]I
setp pid.2.Dgain [JOINT_2]D
setp pid.2.bias [JOINT_2]BIAS
setp pid.2.FF0 [JOINT_2]FF0
setp pid.2.FF1 [JOINT_2]FF1
setp pid.2.FF2 [JOINT_2]FF2
# deadband should be just over 1 count
setp pid.2.deadband [JOINT_2]DEADBAND
# position command signals
net Xpos-cmd joint.0.motor-pos-cmd => pid.0.command
net Ypos-cmd joint.1.motor-pos-cmd => pid.1.command
net Zpos-cmd joint.2.motor-pos-cmd => pid.2.command
# joint enable signals
net Xenable joint.0.amp-enable-out => pid.0.enable
net Yenable joint.1.amp-enable-out => pid.1.enable
net Zenable joint.2.amp-enable-out => pid.2.enable
kitamura_test/hallib/check_xyz_constraints.hal 0000644 0000000 0000000 00000002700 13542571435 020777 0 ustar root root # HAL config file to check vel/acc constraints
#
loadrt wcomp names=wcomp_xacc,wcomp_xvel,wcomp_yacc,wcomp_yvel,wcomp_zacc,wcomp_zvel
addf wcomp_xacc servo-thread
addf wcomp_xvel servo-thread
addf wcomp_yacc servo-thread
addf wcomp_yvel servo-thread
addf wcomp_zacc servo-thread
addf wcomp_zvel servo-thread
net Xacc => wcomp_xacc.in
net Xvel => wcomp_xvel.in
net Yacc => wcomp_yacc.in
net Yvel => wcomp_yvel.in
net Zacc => wcomp_zacc.in
net Zvel => wcomp_zvel.in
net acc-ok-x <= wcomp_xacc.out
net vel-ok-x <= wcomp_xvel.out
net acc-ok-y <= wcomp_yacc.out
net vel-ok-y <= wcomp_yvel.out
net acc-ok-z <= wcomp_zacc.out
net vel-ok-z <= wcomp_zvel.out
setp wcomp_xacc.max 50.001
setp wcomp_xacc.min -50.001
setp wcomp_xvel.max 5.001
setp wcomp_xvel.min -5.001
setp wcomp_yacc.max 50.001
setp wcomp_yacc.min -50.001
setp wcomp_yvel.max 5.001
setp wcomp_yvel.min -5.001
setp wcomp_zacc.max 50.001
setp wcomp_zacc.min -50.001
setp wcomp_zvel.max 5.001
setp wcomp_zvel.min -5.001
loadrt match8 names=match_all
addf match_all servo-thread
net acc-ok-x => match_all.a0
setp match_all.b0 1
net vel-ok-x => match_all.a1
setp match_all.b1 1
net acc-ok-y => match_all.a2
setp match_all.b2 1
net vel-ok-y => match_all.a3
setp match_all.b3 1
net acc-ok-z => match_all.a4
setp match_all.b4 1
net vel-ok-z => match_all.a5
setp match_all.b5 1
setp match_all.a6 0
setp match_all.a7 0
setp match_all.b6 0
setp match_all.b7 0
setp match_all.in 1
net constraints-ok <= match_all.out
kitamura_test/hallib/servo_sim.hal 0000644 0000000 0000000 00000024313 13542571435 016373 0 ustar root root # HAL config file for simulated servo machine
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# PID module, for three PID loops
loadrt pid names=pid_x,pid_y,pid_z
# 6 differentiators (for velocity and accel sigs)
loadrt ddt names=ddt_x,ddt_xv,ddt_y,ddt_yv,ddt_z,ddt_zv
# three scale blocks (to simulate motor and leadscrew scaling)
loadrt scale names=scale_x,scale_y,scale_z
# three lowpass filters (to simulate motor inertia), and nine
loadrt lowpass names=lowpass_x,lowpass_y,lowpass_z
# window comparators (to simulate limit and home switches)
loadrt wcomp names=wcomp_xneg,wcomp_xpos,wcomp_xhome,wcomp_yneg,wcomp_ypos,wcomp_yhome,wcomp_zneg,wcomp_zpos,wcomp_zhome
# simulated encoders
loadrt sim_encoder names=sim_encoder_px,sim_encoder_py,sim_encoder_pz
# software encoder counters, 3 for feedback, 3 for actual axis pos
loadrt encoder names=encoder_px,encoder_py,encoder_pz,encoder_x,encoder_y,encoder_z
# add encoder counter and simulator functions to high speed thread
addf sim-encoder.make-pulses base-thread
addf encoder.update-counters base-thread
# add all required functions to servo thread
addf encoder.capture-position servo-thread
addf wcomp_xneg servo-thread
addf wcomp_xpos servo-thread
addf wcomp_xhome servo-thread
addf wcomp_yneg servo-thread
addf wcomp_ypos servo-thread
addf wcomp_yhome servo-thread
addf wcomp_zneg servo-thread
addf wcomp_zpos servo-thread
addf wcomp_zhome servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid_x.do-pid-calcs servo-thread
addf pid_y.do-pid-calcs servo-thread
addf pid_z.do-pid-calcs servo-thread
addf scale_x servo-thread
addf scale_y servo-thread
addf scale_z servo-thread
addf lowpass_x servo-thread
addf lowpass_y servo-thread
addf lowpass_z servo-thread
addf sim-encoder.update-speed servo-thread
# link the differentiator functions into the code
addf ddt_x servo-thread
addf ddt_xv servo-thread
addf ddt_y servo-thread
addf ddt_yv servo-thread
addf ddt_z servo-thread
addf ddt_zv servo-thread
# get position feedback from encoder module
# connect position feedback to PID loop and motion module
net Xpos-fb encoder_px.position => pid_x.feedback joint.0.motor-pos-fb
net Ypos-fb encoder_py.position => pid_y.feedback joint.1.motor-pos-fb
net Zpos-fb encoder_pz.position => pid_z.feedback joint.2.motor-pos-fb
# set position feedback scaling
setp encoder_px.position-scale [JOINT_0]INPUT_SCALE
setp encoder_py.position-scale [JOINT_1]INPUT_SCALE
setp encoder_pz.position-scale [JOINT_2]INPUT_SCALE
# connect encoder index-enables for homing on index
net Xindex-enable encoder_px.index-enable <=> joint.0.index-enable pid_x.index-enable
net Yindex-enable encoder_py.index-enable <=> joint.1.index-enable
net Zindex-enable encoder_pz.index-enable <=> joint.2.index-enable
# connect position commands from motion controller to PID input
net Xpos-cmd <= joint.0.motor-pos-cmd => pid_x.command
net Ypos-cmd <= joint.1.motor-pos-cmd => pid_y.command
net Zpos-cmd <= joint.2.motor-pos-cmd => pid_z.command
# connect motion controller enables to PID blocks
net Xenable joint.0.amp-enable-out => pid_x.enable
net Yenable joint.1.amp-enable-out => pid_y.enable
net Zenable joint.2.amp-enable-out => pid_z.enable
# connect PID loops to scale blocks that translate to motor revs per sec
net Xoutput pid_x.output => scale_x.in
net Youtput pid_y.output => scale_y.in
net Zoutput pid_z.output => scale_z.in
# set scaling, number of motor revs needed to
# travel one inch
setp scale_x.gain [JOINT_0]DRIVE_RATIO
setp scale_y.gain [JOINT_1]DRIVE_RATIO
setp scale_z.gain [JOINT_2]DRIVE_RATIO
# motor speed command sigs come from scale blocks
# motor speed commands go thru lowpass filters
# to simulate motor inertia
net Xmtr-cmd scale_x.out => lowpass_x.in
net Ymtr-cmd scale_y.out => lowpass_y.in
net Zmtr-cmd scale_z.out => lowpass_z.in
# set "inertia" here, probalby by trial and error
setp lowpass_x.gain 0.1
setp lowpass_y.gain 0.1
setp lowpass_z.gain 0.1
# "actual" motor speed signals
# output of lowpass is simulated motor speed
# speed goes to simulated encoders
net Xmtr-spd lowpass_x.out => sim_encoder_px.speed
net Ymtr-spd lowpass_y.out => sim_encoder_py.speed
net Zmtr-spd lowpass_z.out => sim_encoder_pz.speed
# set simulated encoder scaling
setp sim_encoder_px.ppr [JOINT_0]MOTOR_PPR
setp sim_encoder_py.ppr [JOINT_1]MOTOR_PPR
setp sim_encoder_pz.ppr [JOINT_2]MOTOR_PPR
# simulated encoder output signals
# connect them up
net XphA sim_encoder_px.phase-A => encoder_px.phase-A
net XphB sim_encoder_px.phase-B => encoder_px.phase-B
net XphZ sim_encoder_px.phase-Z => encoder_px.phase-Z
net YphA sim_encoder_py.phase-A => encoder_py.phase-A
net YphB sim_encoder_py.phase-B => encoder_py.phase-B
net YphZ sim_encoder_py.phase-Z => encoder_py.phase-Z
net ZphA sim_encoder_pz.phase-A => encoder_pz.phase-A
net ZphB sim_encoder_pz.phase-B => encoder_pz.phase-B
net ZphZ sim_encoder_pz.phase-Z => encoder_pz.phase-Z
# set PID loop output limits to max velocity
setp pid_x.maxoutput [JOINT_0]MAX_VELOCITY
setp pid_y.maxoutput [JOINT_1]MAX_VELOCITY
setp pid_z.maxoutput [JOINT_2]MAX_VELOCITY
# set PID loop gains
# NOTE: eventually these will be non-zero values as
# needed to tune the performance of each axis. The
# initial values shown here are extremely conservative
# to prevent unexpected behavior. After this file
# has been "executed" by halcmd, the gains can be
# interactively adjusted using commands like
# "halcmd setp pid..Pgain "
# Once the axis has been tuned to your satisfaction,
# do "halcmd show param | grep pid" to get a listing
# of the tuning parameters, and enter those values here.
# the values below come from the ini
setp pid_x.Pgain [JOINT_0]PGAIN
setp pid_x.Igain [JOINT_0]IGAIN
setp pid_x.Dgain [JOINT_0]DGAIN
setp pid_x.bias [JOINT_0]BIAS
setp pid_x.FF0 [JOINT_0]FF0
setp pid_x.FF1 [JOINT_0]FF1
setp pid_x.FF2 [JOINT_0]FF2
# deadband should be just over 1 count
setp pid_x.deadband [JOINT_0]DEADBAND
setp pid_y.Pgain [JOINT_1]PGAIN
setp pid_y.Igain [JOINT_1]IGAIN
setp pid_y.Dgain [JOINT_1]DGAIN
setp pid_y.bias [JOINT_1]BIAS
setp pid_y.FF0 [JOINT_1]FF0
setp pid_y.FF1 [JOINT_1]FF1
setp pid_y.FF2 [JOINT_1]FF2
# deadband should be just over 1 count
setp pid_y.deadband [JOINT_1]DEADBAND
setp pid_z.Pgain [JOINT_2]PGAIN
setp pid_z.Igain [JOINT_2]IGAIN
setp pid_z.Dgain [JOINT_2]DGAIN
setp pid_z.bias [JOINT_2]BIAS
setp pid_z.FF0 [JOINT_2]FF0
setp pid_z.FF1 [JOINT_2]FF1
setp pid_z.FF2 [JOINT_2]FF2
# deadband should be just over 1 count
setp pid_z.deadband [JOINT_2]DEADBAND
# send the position commands thru differentiators to
# generate velocity and accel signals
net Xvel ddt_x.out => ddt_xv.in
net Xacc <= ddt_xv.out
net Yvel ddt_y.out => ddt_yv.in
net Yacc <= ddt_yv.out
net Zvel ddt_z.out => ddt_zv.in
net Zacc <= ddt_zv.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
net xflt => joint.0.amp-fault-in
net yflt => joint.1.amp-fault-in
net zflt => joint.2.amp-fault-in
# a second set of encoder counters keeps track of position
net XphA => encoder_x.phase-A
net XphB => encoder_x.phase-B
net YphA => encoder_y.phase-A
net YphB => encoder_y.phase-B
net ZphA => encoder_z.phase-A
net ZphB => encoder_z.phase-B
setp encoder_x.position-scale [JOINT_0]INPUT_SCALE
setp encoder_y.position-scale [JOINT_1]INPUT_SCALE
setp encoder_z.position-scale [JOINT_2]INPUT_SCALE
# connect "actual" position from encoders
# to window comparators
net Xaxis-pos encoder_x.position => wcomp_xneg.in wcomp_xpos.in wcomp_xhome.in
net Yaxis-pos encoder_y.position => wcomp_yneg.in wcomp_ypos.in wcomp_yhome.in
net Zaxis-pos encoder_z.position => wcomp_zneg.in wcomp_zpos.in wcomp_zhome.in
# connect simulated switch outputs to motion controller
net Xminlim wcomp_xneg.out => joint.0.neg-lim-sw-in
net Xmaxlim wcomp_xpos.out => joint.0.pos-lim-sw-in
net Xhome wcomp_xhome.out => joint.0.home-sw-in
net Yminlim wcomp_yneg.out => joint.1.neg-lim-sw-in
net Ymaxlim wcomp_ypos.out => joint.1.pos-lim-sw-in
net Yhome wcomp_yhome.out => joint.1.home-sw-in
net Zminlim wcomp_zneg.out => joint.2.neg-lim-sw-in
net Zmaxlim wcomp_zpos.out => joint.2.pos-lim-sw-in
net Zhome wcomp_zhome.out => joint.2.home-sw-in
# configure the points at which the simulated switches trip
# X axis first
# min limit switch
setp wcomp_xneg.max [JOINT_0]MIN_HARD_LIMIT
setp wcomp_xneg.min [JOINT_0]MIN_HARD_LIMIT_RELEASE
# max limit switch
setp wcomp_xpos.min [JOINT_0]MAX_HARD_LIMIT
setp wcomp_xpos.max [JOINT_0]MAX_HARD_LIMIT_RELEASE
# home switch
setp wcomp_xhome.min [JOINT_0]HOME_SW_MIN
setp wcomp_xhome.max [JOINT_0]HOME_SW_MAX
# Y axis
# min limit switch
setp wcomp_yneg.max [JOINT_1]MIN_HARD_LIMIT
setp wcomp_yneg.min [JOINT_1]MIN_HARD_LIMIT_RELEASE
# max limit switch
setp wcomp_ypos.min [JOINT_1]MAX_HARD_LIMIT
setp wcomp_ypos.max [JOINT_1]MAX_HARD_LIMIT_RELEASE
# home switch
setp wcomp_yhome.min [JOINT_1]HOME_SW_MIN
setp wcomp_yhome.max [JOINT_1]HOME_SW_MAX
# Z axis
# min limit switch
setp wcomp_zneg.max [JOINT_2]MIN_HARD_LIMIT
setp wcomp_zneg.min [JOINT_2]MIN_HARD_LIMIT_RELEASE
# max limit switch
setp wcomp_zpos.min [JOINT_2]MAX_HARD_LIMIT
setp wcomp_zpos.max [JOINT_2]MAX_HARD_LIMIT_RELEASE
# home switch
setp wcomp_zhome.min [JOINT_2]HOME_SW_MIN
setp wcomp_zhome.max [JOINT_2]HOME_SW_MAX
# Configure fake probing
loadrt sphereprobe names=sphereprobe
addf sphereprobe base-thread 2
setp sphereprobe.cx -2811 # this is where it ends up after homing
setp sphereprobe.cz -6000 # this is where it ends up after homing
setp sphereprobe.r 5000 # 5/6 inch
net px encoder_px.rawcounts => sphereprobe.px
net py encoder_py.rawcounts => sphereprobe.py
net pz encoder_pz.rawcounts => sphereprobe.pz
net probe-out sphereprobe.probe-out => motion.probe-input
net probe-out => encoder_px.latch-input encoder_py.latch-input
net probe-out => encoder_pz.latch-input
setp encoder_px.latch-rising 1
setp encoder_px.latch-falling 1
setp encoder_py.latch-rising 1
setp encoder_py.latch-falling 1
setp encoder_pz.latch-rising 1
setp encoder_pz.latch-falling 1
kitamura_test/hallib/locking_indexer.hal 0000644 0000000 0000000 00000000453 13542571435 017530 0 ustar root root # simulate a locking rotary axis B
loadrt timedelay names=timedelay_unlock
addf timedelay_unlock servo-thread
net B-unlock joint.4.unlock => timedelay_unlock.in
net B-is-unlocked timedelay_unlock.out => joint.4.is-unlocked
setp timedelay_unlock.on-delay 0.75
setp timedelay_unlock.off-delay 0.5
kitamura_test/hallib/wheeljogpins.tcl 0000644 0000000 0000000 00000000726 13542571435 017103 0 ustar root root # tcl file to enable jog pins
# for all axis letters
# for up to 9 joints
# errors are ignored
# scale defaults to 1, use ::argv otherwise for all
set scalevalue 1 ;# default
if {[llength $::argv] == 1} {
set scalevalue $::argv
}
catch {
foreach l {x y z a b c u v w} {
setp axis.$l.jog-enable 1
setp axis.$l.jog-scale $::scalevalue
}
for {set i 0} {$i < 9} {incr i} {
setp joint.$i.jog-enable 1
setp joint.$i.jog-scale $::scalevalue
}
}
kitamura_test/hallib/sim_rdelta.hal 0000644 0000000 0000000 00000003032 13542571435 016503 0 ustar root root loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadusr -W rotarydelta
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net J0pos joint.0.motor-pos-cmd => joint.0.motor-pos-fb
net J1pos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
net J2pos joint.2.motor-pos-cmd => joint.2.motor-pos-fb
net J3pos joint.3.motor-pos-cmd => joint.3.motor-pos-fb
net J4pos joint.4.motor-pos-cmd => joint.4.motor-pos-fb
net J5pos joint.5.motor-pos-cmd => joint.5.motor-pos-fb
net J6pos joint.6.motor-pos-cmd => joint.6.motor-pos-fb
net J7pos joint.7.motor-pos-cmd => joint.7.motor-pos-fb
net J8pos joint.8.motor-pos-cmd => joint.8.motor-pos-fb
net J0cmd joint.0.pos-cmd => rotarydelta.joint0
net J1cmd joint.1.pos-cmd => rotarydelta.joint1
net J2cmd joint.2.pos-cmd => rotarydelta.joint2
net pfr rotarydeltakins.platformradius => rotarydelta.pfr
net tl rotarydeltakins.thighlength => rotarydelta.tl
net sl rotarydeltakins.shinlength => rotarydelta.sl
net fr rotarydeltakins.footradius => rotarydelta.fr
sets pfr 10
sets tl 10
sets sl 18
sets fr 5
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
kitamura_test/hallib/var_show.tcl 0000644 0000000 0000000 00000000542 13542571435 016231 0 ustar root root # var_show.tcl
# this halfile can be used to show context and
# ini variable arrays available to tcl halfiles
# example: [HAL]LIB:var_show.tcl arg1 arg2
#begin-----------------------------------------------------------------
source [file join $::env(HALLIB_DIR) util_lib.tcl]
show_ini
show_context
puts ::argv=$::argv
puts ::arglen=[llength $::argv]
kitamura_test/hallib/basic_sim.tcl 0000644 0000000 0000000 00000004344 13542571435 016336 0 ustar root root # basic_sim.tcl
#
# Provide common hal components and connections for a simulated machine.
# By default, the script makes and connects ddts, simulated_home,
# spindle, and hal_manualtoolchange components.
#
# Options are available to
# a) disable specific hal components and connections
# b) save a halfile equivalent to the hal commands executed by
# this script (and any prior executed hal commands)
#
# Coordinate letters and number_of_joints are determined from the usual
# ini # file settings.
#
# Ini file usage:
# [HAL]HALFILE = basic_sim.tcl [Options]
# Options:
# -no_make_ddts
# -no_simulated_home
# -no_use_hal_manualtoolchange
# -no_sim_spindle
#----------------------------------------------------------------------
# Notes:
# 1) ::env() is a global associative array of environmental variables
# as exported by the main LinuxCNC script (linuxcnc)
# 2) Settings from the ini file are available as global associative
# arrays named: ::SECTION(varname)
# example: ::EMCMOT(SERVO_PERIOD)
# 3) procs are from sim_lib.tcl
#begin-----------------------------------------------------------------
source [file join $::env(HALLIB_DIR) sim_lib.tcl]
set save_options {}
if [catch {check_ini_items} msg] {
puts "\nbasic_sim.tcl ERROR: $msg\n"
exit 1
}
set axes [get_traj_coordinates]
set number_of_joints $::KINS(JOINTS)
set base_period 0 ;# 0 means no thread
if [info exists ::EMCMOT(BASE_PERIOD)] {
set base_period $::EMCMOT(BASE_PERIOD)
}
core_sim $axes \
$number_of_joints \
$::EMCMOT(SERVO_PERIOD) \
$base_period \
$::EMCMOT(EMCMOT)
if {[lsearch -nocase $::argv -no_make_ddts] < 0} {
make_ddts $number_of_joints
}
if {[lsearch -nocase $::argv -no_simulated_home] < 0} {
simulated_home $number_of_joints
}
if {[lsearch -nocase $::argv -no_use_hal_manualtoolchange] < 0} {
use_hal_manualtoolchange
lappend save_options use_hal_manualtoolchange
}
if {[lsearch -nocase $::argv -no_sim_spindle] < 0} {
sim_spindle
}
# make a halfile (inifilename_cmds.hal) with equivalent hal commands
set savefilename \
./[file rootname [file tail $::env(INI_FILE_NAME)]]_cmds.hal
save_hal_cmds $savefilename $save_options
kitamura_test/hallib/axis_manualtoolchange.hal 0000644 0000000 0000000 00000000541 13542571435 020727 0 ustar root root loadusr -W hal_manualtoolchange
# in case they were linked already
unlinkp iocontrol.0.tool-change
unlinkp iocontrol.0.tool-changed
net tool-change hal_manualtoolchange.change iocontrol.0.tool-change
net tool-changed hal_manualtoolchange.changed iocontrol.0.tool-changed
net tool-prep-number hal_manualtoolchange.number iocontrol.0.tool-prep-number
kitamura_test/hallib/util_lib.tcl 0000644 0000000 0000000 00000003440 13542571435 016204 0 ustar root root # util_lib.tcl -- utilities
set ::util_lib_quiet 0
# ::tp is the namespace for [HAL]TWOPASS processing
# quiet irrelevant messages in pass0
if { [namespace exists ::tp] \
&& ([::tp::passnumber] == 0) } { set ::util_lib_quiet 1 }
proc show_context {} {
if { $::util_lib_quiet } { return }
set pname show_context
puts "$pname: argv0=$::argv0"
puts "$pname: argv=$::argv"
foreach arg $::argv {
puts "$pname: arg=$arg"
}
puts "$pname: INI_FILE_NAME=$::env(INI_FILE_NAME)"
} ;# show_context
proc show_ini {} {
if { $::util_lib_quiet } { return }
set vars [uplevel #0 {info vars}]
set exclude_list {TP auto_index tcl_platform env}
foreach v $vars {
if { [lsearch $exclude_list $v] >= 0 } {continue}
set vg ::$v
if [array exists $vg] {
parray $vg
}
}
} ;# show_ini_info
proc show_env {} {
parray ::env
} ;# show_env
proc joint_number_for_axis {axis_letter} {
# For JOINTS_AXES:
# Apply rule for known kins with KINEMATICS_IDENTITY
set kinematics [lindex $::env(KINS_KINEMATICS) 0]
set coordinates $::env(TRAJ_COORDINATES)
if {[ string first " " $coordinates] < 0} {
set coordinates [split $coordinates ""]
}
set coordinates [string toupper $coordinates]
set axis_letter [string toupper $axis_letter]
# rules for known kinematics types
switch $kinematics {
trivkins {set joint_number [lsearch $coordinates $axis_letter]}
default {return -code error \
"joint_number_for_axis: <$axis_letter> unavailable for kinematics:\
<$::env(KINS_KINEMATICS)>"
}
}
#puts stderr "kins=$kinematics coords=$coordinates a=$axis_letter j=$joint_number"
if { $joint_number < 0} {
return -code error \
"joint_number_for_axis <$axis_letter> not in $::env(TRAJ_COORDINATES)"
}
return $joint_number
} ;# joint_number_for_axis
kitamura_test/hallib/sim_spindle_encoder.hal 0000644 0000000 0000000 00000002515 13542571435 020372 0 ustar root root # simulated spindle encoder (for spindle-synced moves)
loadrt sim_spindle names=sim_spindle
setp sim_spindle.scale 0.01666667
loadrt limit2 names=limit_speed
loadrt lowpass names=spindle_mass
loadrt near names=near_speed
loadrt scale names=rpm_rps
setp rpm_rps.gain .0167
# this limit doesnt make any sense to me:
setp limit_speed.maxv 5000.0 # rpm/second
# encoder reset control
# hook up motion controller's sync output
net spindle-index-enable spindle.0.index-enable <=> sim_spindle.index-enable
# report our revolution count to the motion controller
net spindle-pos sim_spindle.position-fb => spindle.0.revs
# simulate spindle mass
setp spindle_mass.gain .07
# spindle speed control
net spindle-speed-cmd spindle.0.speed-out => limit_speed.in
net spindle-speed-limited limit_speed.out => sim_spindle.velocity-cmd spindle_mass.in
# for spindle velocity estimate
net spindle-rpm-filtered spindle_mass.out near_speed.in2
net spindle-rpm-filtered rpm_rps.in
net spindle-rps-filtered rpm_rps.out spindle.0.speed-in
# at-speed detection
setp near_speed.scale 1.1
setp near_speed.difference 10
net spindle-speed-cmd => near_speed.in1
net spindle-at-speed near_speed.out spindle.0.at-speed
addf limit_speed servo-thread
addf spindle_mass servo-thread
addf rpm_rps servo-thread
addf near_speed servo-thread
addf sim_spindle servo-thread
kitamura_test/hallib/hookup_moveoff.tcl 0000644 0000000 0000000 00000025126 13542571435 017434 0 ustar root root # hallib procs:
source [file join $::env(HALLIB_DIR) hal_procs_lib.tcl]
#
# hookup_moveoff.tcl -- HALFILE to:
# 1) disconnect initial pos-cmd and pos-fb pin connections
# 2) loadrt the moveoff component with name=mv
# 3) addf the moveoff component functions in required sequence
# 4) reconnect the pos-cmd and pos-fb pins to use the component
#
# Support for demo type ini files where the pos-cmd and pos-fb pins are
# 'shortcircuit' connected together is included.
#
# The moveoff component may be initialized with settings from the ini file
#
# Usage:
# 1) Specify this file in the ini file as [HAL]HALFILE
# Its position must follow halfiles that connect the pos-cmd and
# pos-fb pins.
# [HAL]
# ...
# HALFILE = hookup_moveoff.tcl
# ...
#
# 2) Include ini file entries for moveoff component settings:
# [MOVEOFF]
# EPSILON =
# WAYPOINT_SAMPLE_SECS =
# WAYPOINT_THRESHOLD =
# BACKTRACK_ENABLE =
#
# If these settings are not found in the ini file, the moveoff
# component defaults will be used.
#
# 3) Include ini file entries for the per-joint settings
# [MOVEOFF_n]
# MAX_VELOCITY =
# MAX_ACCELERATION =
# MAX_LIMIT =
# MIN_LIMIT =
#
# If settings are not found in the ini file, the items
# [JOINT_n]
# MAX_VELOCITY =
# MAX_ACCELERATION =
# MAX_LIMIT =
# MIN_LIMIT =
# are used. If these are not defined, the moveoff component
# defaults are used.
#
# To use the (optional) demonstration gui named moveoff_gui,
# include an ini entry:
#
# [APPLICATIONS]
# APP = moveoff_gui option1 option2 ...
#
# For available options, Use:
# $ moveoff_gui --help
#
# The moveoff_gui will provide a display and control for
# enabling offsetting if the pin mv.move-enable is not connected
# when moveoff_gui is started.
#
# If the mv.move-enable pin is connected when moveoff_gui
# is started, then it will provide a display but no control.
# This mode supports hal connections for a jog wheel or other
# methods of controlling the offset input pins (mv.offset-M)
#-----------------------------------------------------------------------
# Copyright: 2014
# Authors: Dewey Garrett
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#-----------------------------------------------------------------------
proc do_hal {args} {
if {[info exists ::noexecute] && $::noexecute} {
puts "((do_hal))$args"
} else {
if {$::HU(verbose)} {puts do_hal:$args}
eval hal $args
}
} ;# do_hal
proc setup_pinnames {} {
# Note: works for standard names but a custom proc is needed
# here if the Hal alias command is used on the names
# Identify JOINT_n stanzas
for {set a 0} {$a < 9} {incr a} {
if [info exists ::JOINT_[set a](TYPE)] {
lappend ::HU(axes) $a
set ::HU(highest_joint_num) $a
}
}
foreach a $::HU(axes) {
set ::HU($a,pos,pinname) joint.${a}.motor-pos-cmd
set ::HU($a,fb,pinname) joint.${a}.motor-pos-fb
}
} ;# setup_pinnames
proc install_moveoff {} {
# note expected name for moveoff_gui is $::m
set pnumber [expr 1 + $::HU(highest_joint_num)]
do_hal loadrt moveoff personality=$pnumber names=$::m
set mot_thread $::HU(motion-controller,threadname)
if [info exists ::HU($mot_thread,motion-controller)] {
set write_index [expr 1 + $::HU($mot_thread,motion-controller)]
} else {
set write_index [expr 1 + $::HU($mot_thread,index,last)]
}
do_hal addf $::m.write-outputs $mot_thread $write_index
if [info exists ::HU($mot_thread,motion-command-handler)] {
if {1 == $::HU($mot_thread,motion-command-handler) } {
set read_index 1
} else {
set read_index [expr -1 + $::HU($mot_thread,motion-command-handler)]
}
} else {
set read_index 1
}
do_hal addf $::m.read-inputs $mot_thread $read_index
} ;# install_moveoff
proc disconnect_pos_from_motion {a} {
set pinname $::HU($a,pos,pinname)
set inpins {}; set outpin {}
if [connection_info tmp $pinname] {
if {$tmp(signame) != ""} {
get_netlist inpins outpin iopins $tmp(signame)
set ::HU($a,pos,signame) $tmp(signame)
set ::HU($a,pos,inputs) $inpins
set ::HU($a,pos,output) $outpin
}
} else {
return -code error "<$pinname> not connected as expected"
}
do_hal unlinkp $pinname
} ;# disconnect_pos_from_motion
proc disconnect_fb_to_motion {a} {
set pinname $::HU($a,fb,pinname)
set inpins {}; set outpin {}
if [connection_info tmp $pinname] {
if {$tmp(signame) != ""} {
get_netlist inpins outpin iopins $tmp(signame)
set ::HU($a,fb,signame) $tmp(signame)
set ::HU($a,fb,inputs) $inpins
set ::HU($a,fb,output) $outpin
}
} else {
return -code error "<$pinname> not connected as expected"
}
do_hal unlinkp $pinname
} ;# disconnect_fb_to_motion
proc check_for_short_circuit {a} {
if {$::HU($a,fb,signame) == $::HU($a,pos,signame)} {
set ::HU($a,shortcircuit) 1
} else {
set ::HU($a,shortcircuit) 0
}
} ;# check_for_short_circuit
proc new_connect_pos_to_moveoff {a} {
do_hal delsig $::HU($a,pos,signame)
do_hal net hu:pos-$a <= $::HU($a,pos,pinname)
do_hal net hu:pos-$a => $::m.pos-$a
} ;# new_connect_pos_to_moveoff
proc new_connect_plus_offset {a} {
if $::HU($a,shortcircuit) return
do_hal net hu:plus-$a <= $::m.pos-plusoffset-$a
foreach in_pinname $::HU($a,pos,inputs) {
if {"$in_pinname" == "$::HU($a,fb,pinname)"} continue
do_hal unlinkp $in_pinname
do_hal net hu:plus-$a => $in_pinname
}
} ;# new_connect_plus_offset
proc new_connect_minus_offset {a} {
do_hal net hu:minus-$a <= $::m.fb-minusoffset-$a
do_hal net hu:minus-$a => $::HU($a,fb,pinname)
} ;# new_connect_plus_offset
proc new_connect_fb_to_moveoff {a} {
if $::HU($a,shortcircuit) return
do_hal delsig $::HU($a,fb,signame)
do_hal net hu:fb-$a => $::m.fb-$a
do_hal net hu:fb-$a <= $::HU($a,fb,output)
foreach in_pinname $::HU($a,fb,inputs) {
if {"$in_pinname" == "$::HU($a,fb,pinname)"} continue
do_hal unlinkp $in_pinname
do_hal net hu:fb-$a => $in_pinname
}
} ;# new_connect_fb_to_moveoff
proc reconnect_short_circuit {a} {
do_hal net hu:shortcircuit-$a <= $::m.pos-plusoffset-$a
do_hal net hu:shortcircuit-$a => $::m.fb-$a
foreach in_pinname $::HU($a,pos,inputs) {
if {"$in_pinname" == "$::HU($a,fb,pinname)"} {continue}
do_hal unlinkp $in_pinname
do_hal net hu:shortcircuit-$a => $in_pinname
}
} ;# reconnect_short_circuit
proc set_moveoff_inputs {a} {
foreach {pin ininame} { offset-vel MAX_VELOCITY \
offset-accel MAX_ACCELERATION \
offset-max MAX_LIMIT \
offset-min MIN_LIMIT \
} {
if [info exists ::MOVEOFF_[set a]($ininame)] {
set ::HU($a,$pin) [set ::MOVEOFF_[set a]($ininame)]
# lindex is used in case there are duplicate entries
set ::HU($a,$pin) [lindex $::HU($a,$pin) end]
} elseif { [info exists ::JOINT_[set a]($ininame)] } {
set ::HU($a,$pin) [set ::JOINT_[set a]($ininame)]
# lindex is used in case there are duplicate entries
set ::HU($a,$pin) [lindex $::HU($a,$pin) end]
puts "hookup_moveoff.tcl:use \[JOINT_$a\]$ininame=$::HU($a,$pin)"
}
if [info exists ::HU($a,$pin)] {
do_hal setp $::m.$pin-$a $::HU($a,$pin)
}
}
} ;# set_moveoff_inputs
proc set_moveoff_parms {} {
foreach {pin ininame} { epsilon EPSILON \
waypoint-sample-secs WAYPOINT_SAMPLE_SECS \
waypoint-threshold WAYPOINT_THRESHOLD \
backtrack-enable BACKTRACK_ENABLE \
} {
if {[info exists ::MOVEOFF($ininame)]} {
# lindex is used in case there are duplicate entries
set ::HU($pin) [lindex $::MOVEOFF($ininame) end]
do_hal setp $::m.$pin $::HU($pin)
}
}
} ;# set_moveoff_parms
proc set_moveoff_controls {} {
return
# provision for future offset control connections
} ;# set_moveoff_controls
# begin-----------------------------------------------------------------
set ::m mv ;# moveoff component name
#(must agree with the (optionaL) gui moveoff_gui)
# debugging items
set ::HU(verbose) 0
set ::noexecute 0
# Provision for twopass compatibility
# (::tp is the namespace for [HAL]TWOPASS processing)
if [namespace exists ::tp] {
set passno [::tp::passnumber]
if {$passno == 0} {
# With twopass processing, the initial pass0 only collects
# loadrt and loadusr commands with no execution.
# So the checks etc herein cannot work until pass1
# Note that this file only uses loadrt once for the moveoff
# component so it manages its loadrt exclusively
puts "hookup_moveoff.tcl: twopass active, pass $passno skipped"
return
} else {
puts "hookup_moveoff.tcl: twopass active, pass $passno active"
}
}
if [catch {
set ::HU(cmd) "thread_info ::HU"; eval $::HU(cmd)
set ::HU(cmd) setup_pinnames; eval $::HU(cmd)
set ::HU(cmd) install_moveoff; eval $::HU(cmd)
foreach a $::HU(axes) {
set ::HU(cmd) "disconnect_pos_from_motion $a"; eval $::HU(cmd)
set ::HU(cmd) "disconnect_fb_to_motion $a"; eval $::HU(cmd)
set ::HU(cmd) "check_for_short_circuit $a"; eval $::HU(cmd)
set ::HU(cmd) "new_connect_pos_to_moveoff $a"; eval $::HU(cmd)
set ::HU(cmd) "new_connect_plus_offset $a"; eval $::HU(cmd)
set ::HU(cmd) "new_connect_minus_offset $a"; eval $::HU(cmd)
set ::HU(cmd) "new_connect_fb_to_moveoff $a"; eval $::HU(cmd)
if $::HU($a,shortcircuit) {
set ::HU(cmd) "reconnect_short_circuit $a "; eval $::HU(cmd)
}
set ::HU(cmd) "set_moveoff_inputs $a"; eval $::HU(cmd)
}
set ::HU(cmd) "set_moveoff_parms"; eval $::HU(cmd)
set ::HU(cmd) "set_moveoff_controls"; eval $::HU(cmd)
if $::HU(verbose) {parray ::HU}
} msg ] {
puts "\n\n$::argv0 $::argv"
parray ::HU
catch {puts filename=$filename}
puts "\n failing cmd=$::HU(cmd)"
puts msg=<$msg>
return -code error
}
kitamura_test/hallib/simulated_home.hal 0000644 0000000 0000000 00000001221 13542571435 017355 0 ustar root root loadrt or2 names=or2_0
loadrt comp names=comp_x,comp_y,comp_z
net Xhomeswpos => comp_x.in0
net Yhomeswpos => comp_y.in0
net Zhomeswpos => comp_z.in0
sets Xhomeswpos 1
sets Yhomeswpos .5
sets Zhomeswpos 2
net Xpos => comp_x.in1
net Ypos => comp_y.in1
net Zpos => comp_z.in1
setp comp_x.hyst .02
setp comp_y.hyst .02
setp comp_z.hyst .02
net Xhomesw <= comp_x.out
net Yhomesw <= comp_y.out => joint.1.home-sw-in
net Zhomesw <= comp_z.out
net Xhomesw => or2_0.in0
net Zhomesw => or2_0.in1
net XZhomesw or2_0.out => joint.0.home-sw-in joint.2.home-sw-in
addf comp_x servo-thread
addf comp_y servo-thread
addf comp_z servo-thread
addf or2_0 servo-thread
kitamura_test/hallib/sim_ldelta.hal 0000644 0000000 0000000 00000002654 13542571435 016506 0 ustar root root # core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
#loadrt lineardeltakins
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadusr -W lineardelta MIN_JOINT=-420
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net J0pos joint.0.motor-pos-cmd => joint.0.motor-pos-fb lineardelta.joint0
net J1pos joint.1.motor-pos-cmd => joint.1.motor-pos-fb lineardelta.joint1
net J2pos joint.2.motor-pos-cmd => joint.2.motor-pos-fb lineardelta.joint2
net Apos joint.3.motor-pos-cmd => joint.3.motor-pos-fb
net L lineardeltakins.L => lineardelta.L
net R lineardeltakins.R => lineardelta.R
sets L 269
sets R 130.25
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
net spindle-fwd spindle.0.forward
net spindle-rev spindle.0.reverse
#net spindle-speed spindle.0.speed-out
net lube iocontrol.0.lube
net flood iocontrol.0.coolant-flood
net mist iocontrol.0.coolant-mist
kitamura_test/hallib/simulated_limits.hal 0000644 0000000 0000000 00000004663 13542571435 017743 0 ustar root root # HAL config file to simulate limit switches using window comparators
#
# first install nine comparators
loadrt wcomp names=wcomp_xmin,wcomp_xmax,wcomp_xhome,wcomp_ymin,wcomp_ymax,wcomp_yhome,wcomp_zmin,wcomp_zmax,wcomp_zhome
# add comparators to servo thread so they will be evaluated
# every servo period
addf wcomp_xmin servo-thread
addf wcomp_xmax servo-thread
addf wcomp_xhome servo-thread
addf wcomp_ymin servo-thread
addf wcomp_ymax servo-thread
addf wcomp_yhome servo-thread
addf wcomp_zmin servo-thread
addf wcomp_zmax servo-thread
addf wcomp_zhome servo-thread
# connect position feedback from step generators
# to window comparators
net Xpos-fb => wcomp_xmin.in
net Xpos-fb => wcomp_xmax.in
net Xpos-fb => wcomp_xhome.in
net Ypos-fb => wcomp_ymin.in
net Ypos-fb => wcomp_ymax.in
net Ypos-fb => wcomp_yhome.in
net Zpos-fb => wcomp_zmin.in
net Zpos-fb => wcomp_zmax.in
net Zpos-fb => wcomp_zhome.in
# connect simulated switch outputs to motion controller
net Xminlim wcomp_xmin.out => joint.0.neg-lim-sw-in
net Xmaxlim wcomp_xmax.out => joint.0.pos-lim-sw-in
net Xhome wcomp_xhome.out => joint.0.home-sw-in
net Yminlim wcomp_ymin.out => joint.1.neg-lim-sw-in
net Ymaxlim wcomp_ymax.out => joint.1.pos-lim-sw-in
net Yhome wcomp_yhome.out => joint.1.home-sw-in
net Zminlim wcomp_zmin.out => joint.2.neg-lim-sw-in
net Zmaxlim wcomp_zmax.out => joint.2.pos-lim-sw-in
net Zhome wcomp_zhome.out => joint.2.home-sw-in
# configure the points at which the simulated switches trip
# X axis first
# set min limit switch to trip at -10.2, release at -1000
setp wcomp_xmin.max -10.2
setp wcomp_xmin.min -1000
# set max limit switch to trip at +10.2, release at +10.21
setp wcomp_xmax.min 10.20
setp wcomp_xmax.max 10.21
# set home switch to trip at 9.5 and release at 9.75
setp wcomp_xhome.min 9.5
setp wcomp_xhome.max 9.75
# Y axis
# set min limit switch to trip at -10.2, release at -1000
setp wcomp_ymin.max -10.2
setp wcomp_ymin.min -1000
# set max limit switch to trip at +10.2, release at +10.21
setp wcomp_ymax.min 10.20
setp wcomp_ymax.max 10.21
# set home switch to trip at 9.5 and release at 9.75
setp wcomp_yhome.min 9.5
setp wcomp_yhome.max 9.75
# Z axis
# set min limit switch to trip at -2.1, release at -1000
setp wcomp_zmin.max -2.1
setp wcomp_zmin.min -1000
# set max limit switch to trip at +4.05,release at +5
setp wcomp_zmax.min 4.05
setp wcomp_zmax.max 5
# set home switch to trip at 3.9 and release at 4.1
setp wcomp_zhome.min 3.9
setp wcomp_zhome.max 4.1
kitamura_test/hallib/tripodsim.hal 0000644 0000000 0000000 00000003503 13542571435 016375 0 ustar root root # core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
setp tripodkins.Bx 10
setp tripodkins.Cx 5
setp tripodkins.Cy 7.071
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD
# 6 differentiators (for velocity and accel sigs)
loadrt ddt names=ddt_j0,ddt_j1,ddt_j2,ddt_j0v,ddt_j1v,ddt_j2v
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# link the differentiator functions into the code
addf ddt_j0 servo-thread
addf ddt_j0v servo-thread
addf ddt_j1 servo-thread
addf ddt_j1v servo-thread
addf ddt_j2 servo-thread
addf ddt_j2v servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net J0pos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt_j0.in
net J1pos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt_j1.in
net J2pos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt_j2.in
# send the position commands thru differentiators to
# generate velocity and accel signals
net J0vel ddt_j0.out => ddt_j0v.in
net J0acc <= ddt_j0v.out
net J1vel ddt_j1.out => ddt_j1v.in
net J1acc <= ddt_j1v.out
net J2vel ddt_j2.out => ddt_j2v.in
net J2acc <= ddt_j2v.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
# amp control
net J0ena <= joint.0.amp-enable-out
net J1ena <= joint.1.amp-enable-out
net J2ena <= joint.2.amp-enable-out
net J0flt => joint.0.amp-fault-in
net J1flt => joint.1.amp-fault-in
net J2flt => joint.2.amp-fault-in
kitamura_test/hallib/sim_lib.tcl 0000644 0000000 0000000 00000035225 13542571435 016025 0 ustar root root # sim_lib.tcl: haltcl procs for sim configurations
#----------------------------------------------------------------------
# Notes (Joints-Axes):
# 1) if ::KINS(KINEMATICS) exists:
# loadrt the kins using any included parameters
# example: for inifile item:
# [KINS]KINEMATICS = trivkins coordinates=XZ kinstype=BOTH
# use:
# loadrt trivkins coordinates=xz kinstype=BOTH
# else:
# loadrt trivkins
#
# 2) NB: If $::KINS(KINEMATICS) specifies coordinates=, the
# coordinates must agree with ::TRAJ(COORDINATES)
#
# 3) if known kins (trivkins) and xyz, make hypotenuse velocity
# pins for xy,xyz
#----------------------------------------------------------------------
proc indices_for_trivkins {axes} {
# ref: src/emc/kinematics/trivkins.c
if {"$axes" == ""} {set axes {x y z a b c u v w}}
set i 0
foreach a [string tolower $axes] {
# assign to consecutive joints:
set ::SIM_LIB(jointidx,$a) $i
incr i
}
} ;# indices_for_trivkins
proc get_traj_coordinates {} {
# initraj.cc: coordinates may be with or without spaces X Z or XZ
# convert either form to list like {x z}
set coordinates [lindex $::TRAJ(COORDINATES) 0]
set coordinates [string map {" " "" "\t" ""} $coordinates]
set coordinates [split $coordinates ""]
return [string tolower $coordinates]
} ;# get_traj_coordinates
proc check_ini_items {} {
foreach {section item} {KINS KINEMATICS
KINS JOINTS
TRAJ COORDINATES
} {
if ![info exists ::${section}($item)] {
return -code error "Missing inifile item: \[$section\]$item"
}
}
if { [info exists ::DISPLAY(LATHE)]
&& [lsearch $::KINS(KINEMATICS) trivkins] >= 0
} {
# reject historical lathe config using default trivkins coordinates (all)
if {[string first "=" $::KINS(KINEMATICS)] < 0} {
set msg "trivkins lathe config must specify coordinates= "
set msg "$msg\n(typically use \[KINS]KINEMATICS trivkins coordinates=XZ)"
return -code error "$msg"
}
}
set n_extrajoints 0
if [info exists ::EMCMOT(EMCMOT)] {
set mot [split [lindex $::EMCMOT(EMCMOT) 0]]
if {[string first motmod $mot] >= 0} {
foreach item $mot {
if {[string first num_extrajoints= $item] < 0} continue
set n_extrajoints [lindex [split $item =] end]
} ;# foreach
}
}
set kins [split [lindex $::KINS(KINEMATICS) 0]]
if {[string first trivkins $kins] >= 0} {
foreach item $kins {
if {[string first coordinates= $item] < 0} continue
set tcoords [lindex [split $item =] end]
set len_tcoords [string len $tcoords]
set expected_joints [expr $len_tcoords + $n_extrajoints]
if {$expected_joints != $::KINS(JOINTS)} {
set m "\ncheck_ini_items: WARNING:\n"
set m "$m trivkins coordinates=$tcoords specifies $len_tcoords joints\n"
set m "$m trivkins extrajoints=$n_extrajoints\n"
set m "$m trivkins totaljoints=$expected_joints\n"
set m "$m !!! but \[KINS\]JOINTS=$::KINS(JOINTS)\n"
puts stderr $m
}
} ;# foreach
}
return
} ;# check_ini_items
proc setup_kins {axes} {
if ![info exists ::KINS(KINEMATICS)] {
puts stderr "setup_kins: NO \[KINS\]KINEMATICS, trying default trivkins"
loadrt trivkins
return
}
set kins_kinematics [lindex $::KINS(KINEMATICS) end]
set cmd "loadrt $kins_kinematics" ;# may include parms
set kins_module [lindex $kins_kinematics 0]
puts stderr "setup_kins: cmd=$cmd"
if [catch {eval $cmd} msg] {
puts stderr "\nmsg=$msg\n"
}
# set up axis indices for known kins
switch $kins_module {
trivkins {indices_for_trivkins $axes}
default {
puts stderr "setup_kins: unknown \[KINS\]KINEMATICS=<$::KINS(KINEMATICS)>"
}
}
} ;# setup_kins
proc core_sim {axes
number_of_joints
servo_period
{base_period 0}
{emcmot motmod}
} {
# adapted as haltcl proc from core_sim.hal
# note: with default emcmot==motmot,
# thread will not be added for (default) base_pariod == 0
setup_kins $axes
if {"$emcmot" == "motmod"} {
if [catch {loadrt $emcmot \
base_period_nsec=$base_period \
servo_period_nsec=$servo_period \
num_joints=$number_of_joints} msg
] {
# typ: too many joints attempted
puts stderr "\n"
puts stderr "core_sim: loadrt $emcmot FAIL"
puts stderr " msg=$msg\n"
exit 1
}
} else {
# known special case with additional parameter:
# unlock_joint_mask=0xNN
# num_extrajoints=n
set module [split [lindex $emcmot 0]]
set modname [lindex $module 0]
set modparm [lreplace $module 0 0]
if [catch {eval loadrt $modname $modparm \
base_period_nsec=$base_period \
servo_period_nsec=$servo_period \
num_joints=$number_of_joints} msg
] {
puts stderr "\n"
puts stderr "core_sim:unhandled emcmot<$emcmot>"
puts stderr " modname=$modname"
puts stderr " modparm=$modparm"
puts stderr " msg=$msg\n"
exit 1
}
}
addf motion-command-handler servo-thread
addf motion-controller servo-thread
set pid_names ""
set mux_names ""
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
set pid_names "${pid_names},J${jno}_pid"
set mux_names "${mux_names},J${jno}_mux"
}
set pid_names [string trimleft $pid_names ,]
set mux_names [string trimleft $mux_names ,]
loadrt pid names=$pid_names
loadrt mux2 names=$mux_names
# pid components
# The pid comp is used as a pass-thru device (FF0=1,all other gains=0)
# to emulate the connectivity of a servo system
# (e.g., no short-circuit connection of motor-pos-cmd to motor-pos-fb)
foreach cname [split $pid_names ,] {
addf ${cname}.do-pid-calcs servo-thread
# FF0 == 1 for pass-thru, all others 0
do_setp ${cname}.FF0 1.0
foreach pin {Pgain Dgain Igain FF1 FF2} { do_setp ${cname}.$pin 0 }
}
# mux components
# The mux comp is used as a sample-hold to simulate a machine
# with encoders that measure output position when power
# is not applied to the motors or controllers
foreach cname [split $mux_names ,] {
addf $cname servo-thread
}
# signal connections:
net estop:loop <= iocontrol.0.user-enable-out
net estop:loop => iocontrol.0.emc-enable-in
net tool:prep-loop <= iocontrol.0.tool-prepare
net tool:prep-loop => iocontrol.0.tool-prepared
net tool:change-loop <= iocontrol.0.tool-change
net tool:change-loop => iocontrol.0.tool-changed
net sample:enable <= motion.motion-enabled
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
net sample:enable => J${jno}_mux.sel
net J${jno}:enable <= joint.$jno.amp-enable-out
net J${jno}:enable => J${jno}_pid.enable
net J${jno}:pos-cmd <= joint.$jno.motor-pos-cmd
net J${jno}:pos-cmd => J${jno}_pid.command
net J${jno}:on-pos <= J${jno}_pid.output
net J${jno}:on-pos => J${jno}_mux.in1 ;# pass thru when motion-enabled
net J${jno}:pos-fb <= J${jno}_mux.out
net J${jno}:pos-fb => J${jno}_mux.in0 ;# hold position when !motion-enabled
net J${jno}:pos-fb => joint.$jno.motor-pos-fb
}
} ;# core_sim
proc make_ddts {number_of_joints} {
# make vel,accel ddts and signals for all joints
# if xyz, make hypotenuse xy,xyz vels
set ddt_limit 16 ;# limited by ddt component
set ddt_names ""
set ddt_ct 0
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
incr ddt_ct 2
if {$ddt_ct > $ddt_limit} {
puts stderr "make_ddts: number of ddts limited to $ddt_limit"
break
}
set ddt_names "${ddt_names},J${jno}_vel,J${jno}_accel"
}
set ddt_names [string trimleft $ddt_names ,]
loadrt ddt names=$ddt_names
foreach cname [split $ddt_names ,] {
addf $cname servo-thread
}
# joint vel,accel signal connections:
set ddt_ct 0
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
incr ddt_ct 2
if {$ddt_ct > $ddt_limit} { continue }
net J${jno}:pos-fb => J${jno}_vel.in ;# net presumed to exist
net J${jno}:vel <= J${jno}_vel.out
net J${jno}:vel => J${jno}_accel.in
net J${jno}:acc <= J${jno}_accel.out
}
set has_xyz 1
foreach letter {x y z} {
if ![info exists ::SIM_LIB(jointidx,$letter)] {
set has_xyz 0
break
}
}
if $has_xyz {
loadrt hypot names=hyp_xy,hyp_xyz ;# vector velocities
addf hyp_xy servo-thread
addf hyp_xyz servo-thread
net J$::SIM_LIB(jointidx,x):vel <= J$::SIM_LIB(jointidx,x)_vel.out
net J$::SIM_LIB(jointidx,x):vel => hyp_xy.in0
net J$::SIM_LIB(jointidx,x):vel => hyp_xyz.in0
net J$::SIM_LIB(jointidx,y):vel <= J$::SIM_LIB(jointidx,y)_vel.out
net J$::SIM_LIB(jointidx,y):vel => hyp_xy.in1
net J$::SIM_LIB(jointidx,y):vel => hyp_xyz.in1
net J$::SIM_LIB(jointidx,z):vel <= J$::SIM_LIB(jointidx,z)_vel.out
net J$::SIM_LIB(jointidx,z):vel => hyp_xyz.in2
net xy:vel => hyp_xy.out
net xyz:vel <= hyp_xyz.out
}
} ;# make_ddts
proc use_hal_manualtoolchange {} {
# adapted as haltcl proc from axis_manualtoolchange.hal
loadusr -W hal_manualtoolchange
# disconnect if previously connected:
unlinkp iocontrol.0.tool-change
unlinkp iocontrol.0.tool-changed
# remove signal with no connections:
delsig tool:change-loop
net tool:change <= iocontrol.0.tool-change
net tool:change => hal_manualtoolchange.change
net tool:changed <= hal_manualtoolchange.changed
net tool:changed => iocontrol.0.tool-changed
net tool:prep-number <= hal_manualtoolchange.number
net tool:prep-number => iocontrol.0.tool-prep-number
} ;# use_hal_manualtoolchange
proc simulated_home {number_of_joints} {
# uses sim_home_switch component
set switch_names ""
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
set switch_names "${switch_names},J${jno}_switch"
}
set switch_names [string trimleft $switch_names ,]
loadrt sim_home_switch names=$switch_names
foreach cname [split $switch_names ,] {
addf $cname servo-thread
}
for {set jno 0} {$jno < $number_of_joints} {incr jno} {
# add pin to pre-existing signal:
net J${jno}:pos-fb => J${jno}_switch.cur-pos
net J${jno}:homesw <= J${jno}_switch.home-sw
net J${jno}:homesw => joint.$jno.home-sw-in
# set sim_home_switch .hysteresis,.home-pos pins
# according to traj units and joint type
if ![info exists ::JOINT_[set jno](TYPE)] {
# use component defaults
} else {
if {"[set ::JOINT_[set jno](TYPE)]" == "ANGULAR"} {
# use component defaults
} else {
if ![info exists ::TRAJ(LINEAR_UNITS)] {
# use component defaults
} else {
switch $::TRAJ(LINEAR_UNITS) {
in - inch - imperial {
do_setp J${jno}_switch.hysteresis 0.05
do_setp J${jno}_switch.home-pos 0.10
}
default { # use component default }
}
}
if { [info exists ::JOINT_[set jno](HOME_SEARCH_VEL)]
&& [set ::JOINT_[set jno](HOME_SEARCH_VEL)] < 0} {
do_setp J${jno}_switch.home-pos -[getp J${jno}_switch.home-pos]
}
}
} ;# type
if [info exists ::JOINT_[set jno](HOME_USE_INDEX)] {
if [set ::JOINT_[set jno](HOME_USE_INDEX)] {
# Note: use default for joint.${jno}.index-delay-ms
net J${jno}:index-enable <= joint.${jno}.index-enable
net J${jno}:index-enable => J${jno}_switch.index-enable
}
}
} ;# for
} ;# simulated_home
proc sim_spindle {} {
# adapted as haltcl proc from sim_spindle_encoder.hal
# simulated spindle encoder (for spindle-synced moves)
loadrt sim_spindle names=sim_spindle
do_setp sim_spindle.scale 0.01666667
loadrt limit2 names=limit_speed
loadrt lowpass names=spindle_mass
loadrt near names=near_speed
# this limit doesnt make any sense to me:
do_setp limit_speed.maxv 5000.0 ;# rpm/second
# encoder reset control
# hook up motion controller's sync output
net spindle-index-enable <=> spindle.0.index-enable
net spindle-index-enable <=> sim_spindle.index-enable
# report our revolution count to the motion controller
net spindle-pos <= sim_spindle.position-fb
net spindle-pos => spindle.0.revs
# simulate spindle mass
do_setp spindle_mass.gain .07
# spindle speed control
net spindle-speed-cmd <= spindle.0.speed-out
net spindle-speed-cmd => limit_speed.in
net spindle-speed-cmd => near_speed.in1
net spindle-speed-limited <= limit_speed.out
net spindle-speed-limited => sim_spindle.velocity-cmd
net spindle-speed-limited => spindle_mass.in
# for spindle velocity estimate
net spindle-rpm-filtered <= spindle_mass.out
net spindle-rpm-filtered => spindle.0.speed-in
net spindle-rpm-filtered => near_speed.in2
# at-speed detection
do_setp near_speed.scale 1.1
do_setp near_speed.difference 10
net spindle-at-speed <= near_speed.out
net spindle-at-speed => spindle.0.at-speed
addf limit_speed servo-thread
addf spindle_mass servo-thread
addf near_speed servo-thread
addf sim_spindle servo-thread
} ;# sim_spindle
proc save_hal_cmds {savefilename {options ""} } {
set tmpfile /tmp/save_hal_cmds_tmp
set date [clock format [clock seconds]]
set script [info script]
set fd [open $savefilename w] ;# overwrite any existing file
puts $fd "# $date
#
# This file: $savefilename
# Created by: $script
# With options: $::argv
# From inifile: $::env(INI_FILE_NAME)
#
# This file contains the hal commands produced by [file tail $script]
# (and any hal commands executed prior to its execution).
#
# To use $savefilename in the original inifile (or a copy of it),
# edit to change:
# \[HAL\]
# HALFILE = LIB:basic_sim.tcl parameters
# to:
# \[HAL\]
# HALFILE = $savefilename
#
# Note: Inifile Variables substitutions specified in the inifile
# and interpreted by halcmd are automatically substituted
# in the created halfile ($savefilename).
#
"
if {[lsearch $options use_hal_manualtoolchange] >= 0} {
puts $fd "# user space components"
puts $fd "loadusr -W hal_manualtoolchange"
puts $fd ""
}
close $fd
hal save all $tmpfile
set fd [open $savefilename a]
set ftmp [open $tmpfile r]
while {![eof $ftmp]} {
gets $ftmp line
puts $fd $line
} ;# while
close $ftmp
file delete $tmpfile
if [info exists ::SIM_LIB(setp_list)] {
puts $fd "# setp commands for unconnected input pins"
foreach {pname value} $::SIM_LIB(setp_list) {
puts $fd "setp $pname $value"
}
}
close $fd
} ;# save_hal_cmds
proc do_setp {pname value} {
setp $pname $value
lappend ::SIM_LIB(setp_list) $pname $value
} ;# do_setp
kitamura_test/hallib/xhc-hb04-layout2.cfg 0000644 0000000 0000000 00000000675 13542571435 017277 0 ustar root root [XHC-HB04]
BUTTON=01:button-goto-zero
BUTTON=02:button-start-pause
BUTTON=03:button-rewind
BUTTON=04:button-probe-z
BUTTON=05:button-macro-3
BUTTON=06:button-half
BUTTON=07:button-zero
BUTTON=08:button-safe-z
BUTTON=09:button-home
BUTTON=0A:button-macro-1
BUTTON=0B:button-macro-2
BUTTON=0C:button-spindle
BUTTON=0D:button-step
BUTTON=0E:button-mode
BUTTON=0F:button-macro-6
BUTTON=10:button-macro-7
BUTTON=16:button-stop
BUTTON=17:button-reset
kitamura_test/hallib/gantrysim.hal 0000644 0000000 0000000 00000002465 13542571435 016406 0 ustar root root loadrt [KINS]KINEMATICS
show comp
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net J0pos joint.0.motor-pos-cmd => joint.0.motor-pos-fb
net J1pos joint.1.motor-pos-cmd => joint.1.motor-pos-fb
net J2pos joint.2.motor-pos-cmd => joint.2.motor-pos-fb
net J3pos joint.3.motor-pos-cmd => joint.3.motor-pos-fb
# estop loopback
net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
# amp control - these nets are not used, but are placeholders for
# converting this sample config to actual machines
net J0ena <= joint.0.amp-enable-out
net J1ena <= joint.1.amp-enable-out
net J2ena <= joint.2.amp-enable-out
net J3ena <= joint.3.amp-enable-out
net J0flt => joint.0.amp-fault-in
net J1flt => joint.1.amp-fault-in
net J2flt => joint.2.amp-fault-in
net J3flt => joint.3.amp-fault-in
kitamura_test/hallib/halcheck.tcl 0000644 0000000 0000000 00000011446 13542571435 016150 0 ustar root root # halcheck.tcl: a halfile to report:
# 1) functions with no addf (usually an error)
# 2) signals with no inputs (not an error)
# 3) signals with no output (not an error)
#
# Usage in ini file (must be the last HALFILE):
# [HAL]
# ...
# HALFILE = LIB:halcheck.tcl
#
# Note: connections in a POSTGUI_HALFILE are not checked
#
# config items:
set ::popup 1 ;# default: enable popup (in addition to prints)
set ::bigfont {Helvetica 12 bold} ;# {Family size weight}
#----------------------------------------------------------------------
set ::prog halcheck
# test for ::argv items on halfile line (requires 2.7)
if [info exists ::argv] {
if {[lsearch $::argv nopopup] >= 0} {
set ::popup 0 ;# disable popup
}
}
#----------------------------------------------------------------------
proc gui_message { type items } {
if { "$items" == "" } return
# twopass processing uses built-ins only (no Tk)
if {$::popup && [catch {package require Tk} msg]} {
set ::popup 0
}
if { !$::popup } return
if { ![winfo exists .b] } {
wm title . "HAL checks"
pack [button .b \
-text Dismiss \
-command {destroy .} \
] -side bottom
}
set items [string map {" " \n} $items]
switch $type {
no_addfs {
pack [label .noa1 \
-text "Functions with no addf: " \
-font $::bigfont \
-relief ridge -bd 3 \
] -side top -fill x -expand 1
pack [label .noa2 \
-text "$items" \
-justify left \
-anchor w \
-relief sunken -bd 3 \
] -side top -fill x -expand 1
}
no_inputs {
pack [label .noi1 \
-text "Signals with no inputs: " \
-font $::bigfont \
-relief ridge -bd 3 \
] -side top -fill x -expand 1
pack [label .noi2 \
-text "$items" \
-justify left \
-anchor w \
-relief sunken -bd 3 \
] -side top -fill x -expand 1
}
no_output {
pack [label .noo1 \
-text "Signals with no output: " \
-font $::bigfont \
-relief ridge -bd 3 \
] -side top -fill x -expand 1
pack [label .noo2 \
-text "$items" \
-justify left \
-anchor w \
-relief sunken -bd 3 \
] -side top -fill x -expand 1
}
}
} ;# gui_message
proc check_function_usage {} {
set ans [hal show function]
set lines [split $ans \n]
set header_len 2
set lines [lreplace $lines 0 [expr $header_len -1]]
set lines [lreplace $lines end end]
set ct 0
set no_addfs ""
foreach line $lines {
catch {unset f1 f2 f3 f4}
scan [lindex $lines $ct] \
"%s %s %s %s %s %s" \
owner codeaddr arg fp users name
if {"$users" == 0} {
puts "$::prog: Functions with no addf: $name"
lappend no_addfs $name
}
incr ct
}
gui_message no_addfs $no_addfs
} ;# check_function_usage
proc check_signal_usage {} {
set ans [hal show signal]
set lines [split $ans \n]
set header_len 2
set lines [lreplace $lines 0 [expr $header_len -1]]
set lines [lreplace $lines end end]
set ct 0
foreach line $lines {
set howmany [scan $line "%s%s%s" fld1 fld2 fld3]
if {$howmany == 3} {
set signame $fld3
set ::SIG($signame,type) $fld1
set ::SIG($signame,value) $fld2
set ::SIG($signame,inputs) ""
set ::SIG($signame,output) ""
set ::SIG($signame,ios) ""
continue
}
switch $fld1 {
"==>" {lappend ::SIG($signame,inputs) $fld2}
"<==" {lappend ::SIG($signame,output) $fld2}
"<=>" {lappend ::SIG($signame,ios) $fld2}
default {return -code error "check-signal_usage: unrecognized <$line>"}
}
incr ct
}
set no_inputs ""
foreach iname [array names ::SIG *,inputs] {
set signame [lindex [split $iname ,] 0]
if {$::SIG($iname) == ""} {
set msg "$::prog: Signal: $signame <$::SIG($signame,value)> NO inputs"
if {$::SIG($signame,ios) != ""} {
set msg "$msg (i/o:$::SIG($signame,ios))"
} else {
lappend no_inputs $signame
}
puts "$msg"
}
}
set no_output ""
foreach oname [array names ::SIG *,output] {
set signame [lindex [split $oname ,] 0]
if {$::SIG($oname) == ""} {
set msg "$::prog: Signal: $signame <$::SIG($signame,value)> NO output"
if {$::SIG($signame,ios) != ""} {
set msg "$msg (i/o:$::SIG($signame,ios))"
} else {
lappend no_output $signame
}
puts "$msg"
}
}
foreach iname [array names ::SIG *,ios] {
if { $::SIG($iname) == ""} {unset ::SIG($iname)}
}
gui_message no_inputs $no_inputs
gui_message no_output $no_output
} ;# check_signal_usage
#----------------------------------------------------------------------
# begin
check_function_usage
check_signal_usage
kitamura_test/hallib/core_sim9.hal 0000644 0000000 0000000 00000004644 13542571435 016263 0 ustar root root #!!! DECLINING USAGE use: HALFILE=LIB:basic_sim.tcl to automatically
#!!! make the components and connections required for sim configs
# core HAL config file for simulation
# first load all the RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# load 6 differentiators (for velocity and accel signals
loadrt ddt names=ddt_x,ddt_xv,ddt_y,ddt_yv,ddt_z,ddt_zv
# load additional blocks
loadrt hypot names=vel_xy,vel_xyz
# add motion controller functions to servo thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# link the differentiator functions into the code
addf ddt_x servo-thread
addf ddt_xv servo-thread
addf ddt_y servo-thread
addf ddt_yv servo-thread
addf ddt_z servo-thread
addf ddt_zv servo-thread
addf vel_xy servo-thread
addf vel_xyz servo-thread
# create HAL signals for position commands from motion module
# loop position commands back to motion module feedback
net Xpos joint.0.motor-pos-cmd => joint.0.motor-pos-fb ddt_x.in
net Ypos joint.1.motor-pos-cmd => joint.1.motor-pos-fb ddt_y.in
net Zpos joint.2.motor-pos-cmd => joint.2.motor-pos-fb ddt_z.in
net Apos joint.3.motor-pos-cmd => joint.3.motor-pos-fb
net Bpos joint.4.motor-pos-cmd => joint.4.motor-pos-fb
net Cpos joint.5.motor-pos-cmd => joint.5.motor-pos-fb
net Upos joint.6.motor-pos-cmd => joint.6.motor-pos-fb
net Vpos joint.7.motor-pos-cmd => joint.7.motor-pos-fb
net Wpos joint.8.motor-pos-cmd => joint.8.motor-pos-fb
# send the position commands thru differentiators to
# generate velocity and accel signals
net Xvel ddt_x.out => ddt_xv.in vel_xy.in0
net Xacc <= ddt_xv.out
net Yvel ddt_y.out => ddt_yv.in vel_xy.in1
net Yacc <= ddt_yv.out
net Zvel ddt_z.out => ddt_zv.in vel_xyz.in0
net Zacc <= ddt_zv.out
# Cartesian 2- and 3-axis velocities
net XYvel vel_xy.out => vel_xyz.in1
net XYZvel <= vel_xyz.out
# estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
net spindle-fwd spindle.0.forward
net spindle-rev spindle.0.reverse
#net spindle-speed spindle.0.speed-out
net lube iocontrol.0.lube
net flood iocontrol.0.coolant-flood
net mist iocontrol.0.coolant-mist
kitamura_test/hallib/xhc-hb04.tcl 0000644 0000000 0000000 00000046523 13542571435 015727 0 ustar root root # xhc-hb04.tcl: HALFILE for xhc-hb04 pendant
# library procs:
source [file join $::env(HALLIB_DIR) hal_procs_lib.tcl]
source [file join $::env(HALLIB_DIR) util_lib.tcl]
# Usage:
# In ini file, include:
# [HAL]
# HALFILE = existing halfiles
# ...
# HALFILE = xhc-hb04.tcl
#
# [XHC_HB04_CONFIG]
# layout = 2 (required: 1|2 are supported)
# coords = x y z a (up to 4 unique letters from x y z a b c u v w)
# coefs = 1 1 1 1 (optional, filter coefs, 0 < coef < 1, not usually reqd)
# scales = 1 1 1 1 (optional)
# threadname = servo-thread (optional)
# sequence = 1 (optional: 1|2)
# jogmode = normal (optional: normal|vnormal)
# require_pendant = yes (optional: yes|no)
# inch_or_mm = in (optional: in|mm, default is mm)
# [XHC_HB04_BUTTONS]
# name = pin (connect button to hal pin)
# name = "" (no connect button)
# special cases:
# start-pause = std_start_pause (for usual behavior)
# step = xhc-hb04.stepsize-up (for usual behavior)
# (see ini files for more exanples)
# Notes:
# 1) the 'start-pause' pin can be set to "std_start_pause" to
# implement default behavior
# 2) the 'step' pin is normally connected to xhc-hb04.stepsize-up
# 3) non-root access to the usb device requires an additional
# udev rule. Typically, create /etc/udev/rules.d/90-xhc.rules:
# SYSFS{idProduct}=="eb70", SYSFS{idVendor}=="10ce", MODE="666", OWNER="root", GROUP="users"
# or (for ubuntu12 and up):
# ATTR{idProduct}=="eb70", ATTR{idVendor}=="10ce", MODE="666", OWNER="root", GROUP="users"
# 4) For jogmode==vnormal (man motion -- see joint.N.jog-vel-mode),
# the max movement is limited by the machine velocity and acceleration limits
# such that delta_x = 0.5 * vmax**2/accelmx
# so for sim example:
# inch: vmax= 1.2 accelmax= 20 delta_x=0.036
# mm: vmax=30.48 acclemax=508 delta_x=0.9144
# Typically:
# (-s1) sequence 1 (1,10,100,1000) is ok for mm-based machines
# (-s2) sequence 2 (1,5,10,20) is ok for inch-based machines
#
# 5) updated for joints_axes: support only configs with known kins
# and they must be KINEMATICS_IDENTITY (trivkins)
# a) connect axis.L.jog-counts to joint.N.jog-counts
# axis.L.jog-scale to joint.L.jog-scale
# c) use [AXIS_N]MAX_ACCELERATION for both axis.L, joint.N
#-----------------------------------------------------------------------
# Copyright: 2014-16
# Author: Dewey Garrett
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#-----------------------------------------------------------------------
proc is_uniq {list_name} {
set tmp(xxxxxxxx) "" ;# make an array first
foreach item $list_name {
if {[array names tmp $item] == $item} {
return 0 ;# not unique
}
set tmp($item) $item
}
return 1 ;# unique
} ;# is_uniq
proc connect_pins {} {
foreach bname [lsort [array names ::XHC_HB04_BUTTONS]] {
set thepin $::XHC_HB04_BUTTONS($bname)
set thepin [lindex $thepin 0]
if {"$thepin" == "\"\""} {
#puts stderr "$::progname: no pin defined for <$bname>"
continue
}
# this pin is can specify std behavior
if { ([string tolower $bname] == "start-pause")
&& ([string tolower $thepin] == "std_start_pause")
} {
std_start_pause_button
puts stderr "$::progname: using std_start_pause_button"
continue
}
# these are warnings in the ini file examples but aren't real pins
if {[string tolower "$thepin"] == "caution"} {
puts stderr "$::progname: skipping button $bname marked <$thepin>"
continue
}
set fullbname xhc-hb04.button-$bname
if !$::xhc_hb04_quiet {
if ![pin_exists $fullbname] {
puts stderr "$::progname: !!! <$fullbname> pin does not exist, continuing"
continue
}
if ![pin_exists $thepin] {
puts stderr "$::progname: !!! <$thepin> target pin does not exist, continuing"
continue
}
}
makenet pendant:$bname <= $fullbname => $thepin
}
} ;# connect_pins
proc wheel_setup {jogmode} {
for {set idx 0} {$idx < 4} {incr idx} {
set ::XHC_HB04_CONFIG(accel,$idx) 1.0 ;# default if unspecified
}
if [info exists ::XHC_HB04_CONFIG(mpg_accels)] {
set idx 0
foreach g $::XHC_HB04_CONFIG(mpg_accels) {
set g1 $g
if {$g < 0} {
set g [expr -1 * $g]
puts stderr "$::progname: mpg_accel #$idx must be positive was:$g1, is:$g"
}
set ::XHC_HB04_CONFIG(accel,$idx) [format %f $g] ;# ensure floatingpt
incr idx
}
}
# defaults if not in inifile:
set ::XHC_HB04_CONFIG(coef,0) 1.0
set ::XHC_HB04_CONFIG(coef,1) 1.0
set ::XHC_HB04_CONFIG(coef,2) 1.0
set ::XHC_HB04_CONFIG(coef,3) 1.0
if [info exists ::XHC_HB04_CONFIG(coefs)] {
set idx 0
foreach g $::XHC_HB04_CONFIG(coefs) {
set g1 $g
if {$g < 0} {
set g [expr -1 * $g]
puts stderr "$::progname: coef #$idx must be positive was:$g1, is:$g"
}
if {$g > 1} {
set g .5
puts stderr "$::progname: coef #$idx must < 1 coef was:$g1, is:$g"
}
set ::XHC_HB04_CONFIG(coef,$idx) $g
incr idx
}
}
# defaults if not in inifile:
set ::XHC_HB04_CONFIG(scale,0) 1.0
set ::XHC_HB04_CONFIG(scale,1) 1.0
set ::XHC_HB04_CONFIG(scale,2) 1.0
set ::XHC_HB04_CONFIG(scale,3) 1.0
if [info exists ::XHC_HB04_CONFIG(scales)] {
set idx 0
foreach g $::XHC_HB04_CONFIG(scales) {
set ::XHC_HB04_CONFIG(scale,$idx) $g
incr idx
}
}
# to support fractional scales:
# divide the xhc-hb04.jog.scale by $kvalue
# and
# multiply the pendant_util.scale$idx by $kvalue
# to manipulate the integer (s32) joint.N.jog-counts
set kvalue 100.0; # allow fractional scales (.1, .01)
# Note: larger values not advised as the
# jog-counts are type s32 (~ +/-2e9)
setp pendant_util.k $kvalue
makenet pendant:jog-prescale <= xhc-hb04.jog.scale
makenet pendant:jog-prescale => pendant_util.divide-by-k-in
makenet pendant:jog-scale <= pendant_util.divide-by-k-out
# pendant:jog-scale connects to each:
# and axis.$coord.jog-scale
# joint.$jnum.jog-scale (if applicable)
makenet pendant:wheel-counts <= xhc-hb04.jog.counts
makenet pendant:wheel-counts-neg <= xhc-hb04.jog.counts-neg
set anames {x y z a}
set available_idx {0 1 2 3}
# The pendant has fixed labels and displays for letters: x y z a
# and xhc-hb04.cc hardcodes pin names for these letters: x y z a
# Herein: Use label corresponding to coord if possible.
# Otherwise, use next available label. When this occurs,
# pin names will be a little confusing but the signal names will
# align correctly.
#
# With this method, any coord (xyzabcuvw) can be controlled by
# the wheel (providing it exists)
#
set unassigned_coords {}
foreach coord $::XHC_HB04_CONFIG(coords) {
set i [lsearch $anames $coord]
if {$i >= 0} {
set i [lsearch $available_idx $i]
# use idx corresponding to coord
set use_idx($coord) [lindex $available_idx $i]
set available_idx [lreplace $available_idx $i $i]
} else {
lappend unassigned_coords $coord
}
}
foreach coord $unassigned_coords {
# use next available_idx
set use_idx($coord) [lindex $available_idx 0]
set available_idx [lreplace $available_idx 0 0]
}
set mapmsg ""
foreach coord $::XHC_HB04_CONFIG(coords) {
if [catch {set jnum [joint_number_for_axis $coord]} msg] {
puts stderr "$::progname: $msg"
set has_jnum 0
} else {
set has_jnum 1
}
set use_lbl($coord) [lindex $anames $use_idx($coord)]
set idx $use_idx($coord)
if {"$use_lbl($coord)" != "$coord"} {
set mapmsg "$mapmsg\
coord: $coord is mapped to pendant switch/display:\
$use_lbl($coord) index: $idx\n"
}
setp pendant_util.coef$idx $::XHC_HB04_CONFIG(coef,$idx)
setp pendant_util.scale$idx [expr $kvalue * $::XHC_HB04_CONFIG(scale,$idx)]
set acoord [lindex $anames $idx]
# accommodate existing signames for halui outpins:
makenet [existing_outpin_signame halui.axis.$coord.pos-feedback pendant:pos-$coord] \
<= halui.axis.$coord.pos-feedback \
=> xhc-hb04.$acoord.pos-absolute
makenet [existing_outpin_signame halui.axis.$coord.pos-relative pendant:pos-rel-$coord] \
<= halui.axis.$coord.pos-relative \
=> xhc-hb04.$acoord.pos-relative
makenet pendant:jog-scale => axis.$coord.jog-scale
makenet pendant:wheel-counts => pendant_util.in$idx
makenet pendant:wheel-counts-$coord-filtered <= pendant_util.out$idx \
=> axis.$coord.jog-counts
set COORD [string toupper $coord]
makenet pendant:jog-$coord <= xhc-hb04.jog.enable-$acoord \
=> axis.$coord.jog-enable
switch $jogmode {
vnormal {
setp axis.$coord.jog-vel-mode 1
}
}
set afraction 1.0 ;# default
if [catch {
set afraction [expr $::XHC_HB04_CONFIG(accel,$idx)\
/[set ::AXIS_[set COORD](MAX_ACCELERATION)] ]
} msg] {
err_exit "<$msg>\n\nMissing ini setting: \[AXIS_$COORD\]MAX_ACCELERATION"
}
setp axis.$coord.jog-accel-fraction $afraction
# connect for joint pins if known (trivkins)
if $has_jnum {
if ![pin_exists joint.$jnum.jog-scale] {
err_exit "Not configured for coords = $::XHC_HB04_CONFIG(coords),\
missing joint.$jnum.* pins"
}
makenet pendant:jog-scale => joint.$jnum.jog-scale
makenet pendant:wheel-counts-$coord-filtered => joint.$jnum.jog-counts
if [catch {set std_accel [set ::JOINT_[set jnum](MAX_ACCELERATION)]} msg] {
err_exit "Error: missing \[JOINT_[set jnum]\]MAX_ACCELERATION"
}
if { [set ::JOINT_[set jnum](MAX_ACCELERATION)]
!= [set ::AXIS_[set COORD](MAX_ACCELERATION)] } {
puts stderr "$::progname: Warning accel values differ:"
puts stderr " \[JOINT_[set jnum]\]MAX_ACCELERATION=[set ::JOINT_[set jnum](MAX_ACCELERATION)]"
puts stderr " \[AXIS_[set COORD]\]MAX_ACCELERATION=[set ::AXIS_[set COORD](MAX_ACCELERATION)]"
}
makenet pendant:jog-$coord => joint.$jnum.jog-enable
set jfraction 1.0 ;# default
if [catch {
set jfraction [expr $::XHC_HB04_CONFIG(accel,$idx)\
/[set ::JOINT_[set jnum](MAX_ACCELERATION)] ]
} msg] {
err_exit "<$msg>\n\nMissing ini setting: \[JOINT_$jnum\]MAX_ACCELERATION"
}
setp joint.$jnum.jog-accel-fraction $jfraction
switch $jogmode {
vnormal {
setp joint.$jnum.jog-vel-mode 1
}
}
}
} ;# for coord
if {"$mapmsg" != ""} {
puts "\n$::progname:\n$mapmsg"
}
setp halui.feed-override.scale 0.01
makenet pendant:wheel-counts => halui.feed-override.counts
setp halui.spindle.0.override.scale 0.01
makenet pendant:wheel-counts => halui.spindle.0.override.counts
makenet pendant:feed-override-enable => halui.feed-override.count-enable \
<= xhc-hb04.jog.enable-feed-override
makenet pendant:spindle-override-enable => halui.spindle.0.override.count-enable \
<= xhc-hb04.jog.enable-spindle-override
# accommodate existing signames for motion outpins
makenet [existing_outpin_signame motion.current-vel pendant:feed-value] \
<= motion.current-vel \
=> xhc-hb04.feed-value
makenet [existing_outpin_signame spindle.0.speed-out-rps-abs pendant:spindle-rps] \
<= spindle.0.speed-out-rps-abs \
=> xhc-hb04.spindle-rps
# accommodate existing signames for halui outpins:
makenet [existing_outpin_signame halui.max-velocity.value pendant:jog-speed] \
<= halui.max-velocity.value
makenet [existing_outpin_signame halui.feed-overide.value pendant:feed-override] \
<= halui.feed-override.value \
=> xhc-hb04.feed-override
makenet [existing_outpin_signame halui.spindle.0.override.value pendant:spindle-override] \
<= halui.spindle.0.override.value \
=> xhc-hb04.spindle-override
} ;# wheel_setup
proc existing_outpin_signame {pinname newsigname} {
# return existing outpin signame if it exists, else newsigname
set answer [is_connected $pinname signame]
switch $answer {
not_connected {return $newsigname}
is_output {puts "$::progname: Using existing outpin signame: $signame"
return "$signame"
}
default {return -code error \
"existing_outpin_signame:UNEXPECTED $answer"
}
}
} ;# existing_outpin_signame
proc std_start_pause_button {} {
# hardcoded setup for button-start-pause
makenet pendant:start-or-pause <= xhc-hb04.button-start-pause \
=> pendant_util.start-or-pause
makenet pendant:program-resume <= pendant_util.resume \
=> halui.program.resume
makenet pendant:program-pause <= pendant_util.pause \
=> halui.program.pause
makenet pendant:program-run <= pendant_util.run \
=> halui.program.run \
=> halui.mode.auto
# accommodate existing signames for halui outpins:
makenet [existing_outpin_signame halui.program.is-idle pendant:is-idle] \
<= halui.program.is-idle \
=> pendant_util.is-idle
makenet [existing_outpin_signame halui.program.is-paused pendant:is-paused] \
<= halui.program.is-paused \
=> pendant_util.is-paused
makenet [existing_outpin_signame halui.program.is-running pendant:is-running] \
<= halui.program.is-running \
=> pendant_util.is-running
} ;# std_start_pause_button
proc popup_msg {msg} {
puts stderr "$msg"
if [catch {package require Tk
wm withdraw .
tk_messageBox \
-title "$::progname" \
-type ok \
-message "$msg"
destroy .
} msg] {
puts stderr "$msg"
}
} ;# popup_msg
proc err_exit {msg} {
popup_msg $msg
puts stderr "\n$::progname: $msg\n"
exit 1
} ;# err_exit
proc makenet {args} {
if [catch {eval net $args} msg] {
if ![info exists ::makenet_msg] {
set ::makenet_msg \
"Failed to make some required connections"
}
set sig "Signal: <[lindex $args 0]>:"
set ::makenet_msg "$::makenet_msg\n\n$sig\n$msg"
}
} ;# makenet
# begin------------------------------------------------------------------------
set ::progname "xhc-hb04.tcl"
set ::xhc_hb04_quiet 0
# ::tp is the namespace for [HAL]TWOPASS processing
if { [namespace exists ::tp] && ([::tp::passnumber] == 0) } {
set ::xhc_hb04_quiet 1
puts "$::progname: suppressing messages in twopass pass0"
}
set libtag "LIB:"
set cfg ${libtag}xhc-hb04-layout2.cfg ;# default
if ![info exists ::HAL(HALUI)] {
err_exit "\[HAL\]HALUI is not set"
}
if {[array names ::XHC_HB04_CONFIG] == ""} {
err_exit "Missing stanza: \[XHC_HB04_CONFIG\]"
}
if {[array names ::XHC_HB04_BUTTONS] == ""} {
err_exit "Missing stanza: \[XHC_HB04_BUTTONS\]"
}
foreach name [array names ::XHC_HB04_CONFIG] {
set ::XHC_HB04_CONFIG($name) [string trim $::XHC_HB04_CONFIG($name) "{}"]
}
if [info exists ::XHC_HB04_CONFIG(layout)] {
switch ${::XHC_HB04_CONFIG(layout)} {
1 {set cfg ${libtag}xhc-hb04-layout1.cfg}
2 {set cfg ${libtag}xhc-hb04-layout2.cfg}
default {
set msg "Nonstandard layout:<$::XHC_HB04_CONFIG(layout)>"
set cfg $::XHC_HB04_CONFIG(layout)
set msg "$msg\ntrying: $cfg"
popup_msg "$msg"
# keep going
}
}
}
# .cfg files use same search path as halfiles
set cfg [find_file_in_hallib_path $cfg]
if ![file exists $cfg] {
set msg "Cannot find file: <$cfg>\nCannot configure pendant\n"
set msg "$msg\nContinuing without xhc-hb04"
popup_msg "$msg"
return ;# not an exit
}
# require_pendant==yes: use -x, dont create pins unless connected
# require_pendant==no: create pins if not connected
if ![info exists ::XHC_HB04_CONFIG(require_pendant)] {
set ::XHC_HB04_CONFIG(require_pendant) yes ;# default
}
set dashx -x
switch $::XHC_HB04_CONFIG(require_pendant) {
no {set dashx ""}
}
if [info exists ::XHC_HB04_CONFIG(sequence)] {
set dashs "-s $::XHC_HB04_CONFIG(sequence)"
} else {
set dashs ""
}
set cmd "loadusr -W xhc-hb04 $dashx $dashs -I $cfg -H"
if [catch {eval $cmd} msg] {
set msg "\n$::progname: loadusr xhc-hb04:\n<$msg>\n\n"
set msg "$msg Is it plugged in?\n\n"
set msg "$msg Are permissions correct?\n\n"
set msg "$msg Continuing without xhc-hb04\n"
set msg "$msg \nFailing cmd:\n$cmd"
popup_msg "$msg"
return ;# not an exit
}
if ![info exists ::XHC_HB04_CONFIG(inch_or_mm)] {
set ::XHC_HB04_CONFIG(inch_or_mm) mm
}
switch -glob $::XHC_HB04_CONFIG(inch_or_mm) {
in* {setp xhc-hb04.inch-icon 1}
default {}
}
if ![info exists ::XHC_HB04_CONFIG(jogmode)] {
set ::XHC_HB04_CONFIG(jogmode) normal ;# default
}
set jogmode $::XHC_HB04_CONFIG(jogmode)
switch $jogmode {
normal {}
vnormal {}
default {
set ::XHC_HB04_CONFIG(jogmode) normal
set msg "Unkknown jogmode <$jogmode>"
set msg "$msg Using $::XHC_HB04_CONFIG(jogmode)"
popup_msg "$msg"
}
}
if [info exists ::XHC_HB04_CONFIG(coords)] {
if ![is_uniq $::XHC_HB04_CONFIG(coords)] {
err_exit "coords must be unique, not: <$::XHC_HB04_CONFIG(coords)>"
}
if {[llength $::XHC_HB04_CONFIG(coords)] > 4} {
err_exit "max no.of coords is 4 <$::XHC_HB04_CONFIG(coords)>"
}
} else {
set ::XHC_HB04_CONFIG(coords) {x y z a} ;# default
}
if ![info exists ::XHC_HB04_CONFIG(threadname)] {
set ::XHC_HB04_CONFIG(threadname) "servo-thread" ;# default
}
loadrt xhc_hb04_util names=pendant_util
addf pendant_util $::XHC_HB04_CONFIG(threadname)
# If twopass, do not call procs in pass0 that test pin
# connections since components not yet loaded
if { ![namespace exists ::tp] || ([::tp::passnumber] != 0) } {
connect_pins ;# per ini file items: [XHC_HB04_BUTTONS]buttonname=pin
wheel_setup $::XHC_HB04_CONFIG(jogmode)
# jog wheel per ini file items:
# [XHC_HB04_CONFIG]coords,coefs,scales
}
if [info exists ::makenet_msg] {
popup_msg $::makenet_msg
}
#parray ::XHC_HB04_CONFIG
kitamura_test/hallib/moveoff_external.hal 0000644 0000000 0000000 00000001776 13542571435 017740 0 ustar root root # moveoff_external.hal (for use with moveoff_gui)
# This halfile demonstrates how a connection to
# mv.move-enable
# allows moveoff_gui to interface with other connections that control:
# mv.move-enable
# mv.offset-in-M
# This halfile should follow halfiles which loadrt the moveoff component
#-----------------------------------------------------------------------
# Overall enable for the component:
# 0 ==> external control of mv.move-enable required
setp mv.move-enable 0
# When the mv.move-enable pin is connected to a signal, moveoff_gui
# will provide display but no controls.
# An external app must connect the mv.move-enable pin to control:
net external_enable mv.move-enable
# An external app must connect to the mv.offset-in-M pins to control:
net external_offset_0 mv.offset-in-0
net external_offset_1 mv.offset-in-1
net external_offset_2 mv.offset-in-2
# An external app may optionally connect the mv.backtrack-enable pin
# to manage backtracking:
net external_backtrack_en mv.backtrack-enable
kitamura_test/kitamura_test.xml 0000744 0001750 0001750 00000063414 13571260670 017600 0 ustar linuxcnc linuxcnc 666"in00""in16""in01""in17""in02""in18""in03""in19""in04""in20""in05""in21""in06""in22""in07""in23""in08""in24""in09""in25""in10""in26""in11""in27""in12""in28""in13""in29""in14""in30""in15""in31"6"out00""out08""out01""out09""out02""out10""out3""out11""out4""out12""out5""out13""out6""out14""out7""out15"68"enc0"8"enc1"8"enc2"8"enc3"8"enc4"8"enc5"6"dac0-ena""dac0"0.1HORIZONTAL-1010"dac3-ena""dac3"0.1HORIZONTAL-1010"dac1-ena""dac1"0.1HORIZONTAL-1010"dac4-ena""dac4"0.1HORIZONTAL-1010"dac2-ena""dac2"0.1HORIZONTAL-1010"dac5-ena""dac5"0.1HORIZONTAL-101066"0_out00""0_out24""0_out01""0_out25""0_out02""0_out26""0_out03""0_out27""0_out04""0_out28""0_out05""0_out29""0_out06""0_out30""0_out07""0_out31""0_out08""0_out32""0_out09""0_out33""0_out10""0_out34""0_out11""0_out35""0_out12""0_out36""0_out13""0_out37""0_out14""0_out38""0_out15""0_out39""0_out16""0_out40""0_out17""0_out41""0_out18""0_out42""0_out19""0_out43""0_out20""0_out44""0_out21""0_out45""0_out22""0_out46""0_out23""0_out47"66"1_in00""1_in24""1_in01""1_in25""1_in02""1_in26""1_in03""1_in27""1_in04""1_in28""1_in05""1_in29""1_in06""1_in30""1_in07""1_in31""1_in08""1_in32""1_in09""1_in33""1_in10""1_in34""1_in11""1_in35""1_in12""1_in36""1_in13""1_in37""1_in14""1_in38""1_in15""1_in39""1_in16""1_in40""1_in17""1_in41""1_in18""1_in42""1_in19""1_in43""1_in20""1_in44""1_in21""1_in45""1_in22""1_in46""1_in23""1_in47"66"2_in00""2_in24""2_in01""2_in25""2_in02""2_in26""2_in03""2_in27""2_in04""2_in28""2_in05""2_in29""2_in06""2_in30""2_in07""2_in31""2_in08""2_in32""2_in09""2_in33""2_in10""2_in34""2_in11""2_in35""2_in12""2_in36""2_in13""2_in37""2_in14""2_in38""2_in15""2_in39""2_in16""2_in40""2_in17""2_in41""2_in18""2_in42""2_in19""2_in43""2_in20""2_in44""2_in21""2_in45""2_in22""2_in46""2_in23""2_in47"66"3_out00""3_out24""3_out01""3_out25""3_out02""3_out26""3_out03""3_out27""3_out04""3_out28""3_out05""3_out29""3_out06""3_out30""3_out07""3_out31""3_out08""3_out32""3_out09""3_out33""3_out10""3_out34""3_out11""3_out35""3_out12""3_out36""3_out13""3_out37""3_out14""3_out38""3_out15""3_out39""3_out16""3_out40""3_out17""3_out41""3_out18""3_out42""3_out19""3_out43""3_out20""3_out44""3_out21""3_out45""3_out22""3_out46""3_out23""3_out47"
kitamura_test/kitamura_test 0000755 0001750 0001750 00000000256 13571570747 017007 0 ustar linuxcnc linuxcnc #!/bin/bash
thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
halcmd: loadrt hostmot2
pyvcp_demo "$thisdir"/kitamura_test.xml "$thisdir"/kitamura_test.hal pyvcp
kitamura_test/kitamura_test.hal 0000744 0001750 0001750 00000000504 13571604134 017530 0 ustar linuxcnc linuxcnc loadusr pyvcp -c kitamura_test.xml
loadrt threads name1=tt period1=100000 name2=tt2 period2=1000000000
loadrt hostmot2
loadrt hm2_pci config=" num_encoders=6 num_pwmgens=0 num_stepgens=0"
setp hm2_5i25.0.watchdog.timeout_ns 5000000
addf hm2_7i77.0.read tt
# addf hm2_7i77.0.write thread1
start
loadusr halmeter