---
 configs/sim/axis.ini             |    4 +-
 configs/sim/core_sim.tcl         |   45 ++++++++++++++++++++++++++++++++++++++
 configs/sim/manualtoolchange.tcl |   13 +++++++++++
 3 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 configs/sim/core_sim.tcl
 create mode 100644 configs/sim/manualtoolchange.tcl

diff --git a/configs/sim/axis.ini b/configs/sim/axis.ini
index b36e2cd..728b4c2 100644
--- a/configs/sim/axis.ini
+++ b/configs/sim/axis.ini
@@ -100,8 +100,8 @@ SERVO_PERIOD =               1000000
 
 # list of hal config files to run through halcmd
 # files are executed in the order in which they appear
-HALFILE =                    core_sim.hal
-HALFILE =                   axis_manualtoolchange.hal
+HALFILE =                    core_sim.tcl
+HALFILE =                   manualtoolchange.tcl
 HALFILE = simulated_home.hal
 #HALFILE = gamepad.hal
 
diff --git a/configs/sim/core_sim.tcl b/configs/sim/core_sim.tcl
new file mode 100644
index 0000000..b928b7c
--- /dev/null
+++ b/configs/sim/core_sim.tcl
@@ -0,0 +1,45 @@
+# core HAL config file for simulation
+
+# first load all the RT modules that will be needed
+# kinematics
+loadrt trivkins
+# 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=$TRAJ(AXES)
+# load differentiators for velocity and accel signals
+loadrt ddt count=[expr {2*$TRAJ(AXES)}]
+# load additional blocks
+loadrt hypot count=2
+loadrt comp count=3
+loadrt or2 count=1
+
+# 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
+for {set i 0} {$i < 6} {incr i} { addf ddt.$i servo-thread }
+addf hypot.0 servo-thread
+addf hypot.1 servo-thread
+
+# Create position, velocity and acceleration signals for each axis
+set ddt 0
+foreach axis {X Y Z A B C U V W} axno {0 1 2 3 4 5 6 7 8} {
+    if {[hal list pin axis.$axno.motor-pos-cmd] == {}} { continue }
+    net ${axis}pos axis.$axno.motor-pos-cmd => axis.$axno.motor-pos-fb \
+                                            => ddt.$ddt.in
+    net ${axis}vel <= ddt.$ddt.out
+    incr ddt
+    net ${axis}vel => ddt.$ddt.in
+    net ${axis}acc <= ddt.$ddt.out
+    incr ddt
+}
+
+# Cartesian 2- and 3-axis velocities
+net XYvel hypot.0.out => hypot.1.in1
+net XYZvel <= hypot.1.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
diff --git a/configs/sim/manualtoolchange.tcl b/configs/sim/manualtoolchange.tcl
new file mode 100644
index 0000000..9049ee8
--- /dev/null
+++ b/configs/sim/manualtoolchange.tcl
@@ -0,0 +1,13 @@
+puts "toolchange setup in tcl"
+puts "mv is $AXIS_0(MAX_VELOCITY)"
+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
+
+
-- 
1.6.2.1.469.gdffc


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to