All pastes #160574 Raw Edit

Lerneaen Hydra

public text v1 · immutable
#160574 ·published 2006-09-04 14:10 UTC
rendered paste body
<core_stepper.hal, relatively unchanged>

# core HAL config file for steppers

# first load the core 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 traj_period_nsec=[EMCMOT]TRAJ_PERIOD key=[EMCMOT]SHMEM_KEY
# stepper module, three step generators, all three using step/dir
loadrt stepgen step_type=2,2,2

# 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
newsig Xpos-cmd float
linksp Xpos-cmd <= axis.0.motor-pos-cmd
linksp Xpos-cmd => stepgen.0.position-cmd
newsig Ypos-cmd float
linksp Ypos-cmd <= axis.1.motor-pos-cmd
linksp Ypos-cmd => stepgen.1.position-cmd
newsig Zpos-cmd float
linksp Zpos-cmd <= axis.2.motor-pos-cmd
linksp Zpos-cmd => stepgen.2.position-cmd

# connect position feedback from step generators
# to motion module
newsig Xpos-fb float
linksp Xpos-fb <= stepgen.0.position-fb
linksp Xpos-fb => axis.0.motor-pos-fb
newsig Ypos-fb float
linksp Ypos-fb <= stepgen.1.position-fb
linksp Ypos-fb => axis.1.motor-pos-fb
newsig Zpos-fb float
linksp Zpos-fb <= stepgen.2.position-fb
linksp Zpos-fb => axis.2.motor-pos-fb

# connect enable signals for step generators
newsig Xen bit
linksp Xen <= axis.0.amp-enable-out
linksp Xen => stepgen.0.enable
newsig Yen bit
linksp Yen <= axis.1.amp-enable-out
linksp Yen => stepgen.1.enable
newsig Zen bit
linksp Zen <= axis.2.amp-enable-out
linksp Zen => stepgen.2.enable


# connect signals to step pulse generator outputs
newsig Xphase-A bit
newsig Xphase-B bit
newsig Yphase-A bit
newsig Yphase-B bit
newsig Zphase-A bit
newsig Zphase-B bit
linkps stepgen.0.phase-A  Xphase-A
linkps stepgen.0.phase-B  Xphase-B
linkps stepgen.1.phase-A  Yphase-A
linkps stepgen.1.phase-B  Yphase-B
linkps stepgen.2.phase-A  Zphase-A
linkps stepgen.2.phase-B  Zphase-B

# set stepgen module scaling - get values from ini file
setp stepgen.0.position-scale [AXIS_0]INPUT_SCALE
setp stepgen.1.position-scale [AXIS_1]INPUT_SCALE
setp stepgen.2.position-scale [AXIS_2]INPUT_SCALE

# set stepgen module velocity limits - get values from ini file
setp stepgen.0.maxvel [AXIS_0]STEPGEN_MAXVEL
setp stepgen.1.maxvel [AXIS_1]STEPGEN_MAXVEL
setp stepgen.2.maxvel [AXIS_2]STEPGEN_MAXVEL

# set stepgen module accel limits - get values from ini file
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL

# load realtime portion of scope, just to have it handy
loadrt scope_rt









<control_box.hal, stuff that has to do with my external control box>

######################################
# HAL code for external control box##
######################################

######################################
# estop ##############################
######################################

# create a pin and loopback for estop
linkpp parport.1.pin-15-in iocontrol.0.emc-enable-in

######################################
# spindle ###########################
######################################
#input
linkpp parport.1.pin-12-in halui.spindle.start
linkpp parport.1.pin-11-in halui.spindle.stop

#output
# create a signal for "spindle on"
newsig spindle_on bit

# connect it to the iocontroller
linksp spindle_on motion.spindle-on
# connect it to a physical pin
linksp spindle_on parport.0.pin-04-out

######################################
# threading ##########################
######################################

# counting the spindle encoder in software
loadrt counter num_chan=1
loadrt blocks not=1

#add RT functions to base and servo thread
# update counter counter
addf counter.update-counters    base-thread
addf not.0			servo-thread
# capture spindle positions
addf counter.capture-position	servo-thread


#set pullup pin high
newsig pullup_pin bit
sets pullup_pin 1
linksp pullup_pin parport.0.pin-01-out

# spindle encoder
# connect encoder signals to encoder counter
newsig spindle-phase-A bit
newsig spindle-phase-Z bit
linksp spindle-phase-A => counter.0.phase-A
linksp spindle-phase-Z => counter.0.phase-Z

linkps parport.0.pin-10-in => spindle-phase-A
linkps parport.0.pin-11-in => spindle-phase-Z

# (that way thread pitches can be straightforward,
#  a 20 tpi thread would multiply the encoder output
#  by 1/20, etc)
setp counter.0.position-scale 100

# encoder reset control
# this signal is driven by the motion
# controller, TRUE for synced motion, FALSE the rest of
# the time.
#
# hook up motion controller's sync output
newsig spindle-sync bit
linkps motion.spindle-sync => spindle-sync
# needs to be inverted to connect to index enable
newsig spindle-index-en bit
linksp spindle-sync	=> not.0.in
linkps not.0.out	=> spindle-index-en
linksp spindle-index-en	=> counter.0.index-enable
# counting the spindle encoder in software
# report our revolution count to the motion controller
newsig spindle-pos float
linkps counter.0.position => spindle-pos
linksp spindle-pos => motion.spindle-revs



######################################
# feed/jogwheels #####################
######################################

# add 3 encoder counter modules
loadrt encoder num_chan=3

#signals to connect the encoders to parport
newsig encA1 bit
newsig encB1 bit
newsig encA2 bit
newsig encB2 bit
newsig encA3 bit
newsig encB3 bit

linksp encA1 parport.1.pin-05-in
linksp encB1 parport.1.pin-06-in
linksp encA2 parport.1.pin-04-in
linksp encB2 parport.1.pin-03-in
linksp encA3 parport.1.pin-08-in
linksp encB3 parport.1.pin-07-in

linksp encA1 encoder.0.phase-A
linksp encB1 encoder.0.phase-B
linksp encA2 encoder.1.phase-A
linksp encB2 encoder.1.phase-B
linksp encA3 encoder.2.phase-A
linksp encB3 encoder.2.phase-B

	#jogwheel stuff
#make this your counts/unit
setp encoder.0.position-scale 1
setp encoder.1.position-scale 1

addf encoder.update-counters    base-thread 
addf encoder.capture-position	servo-thread 

#next connect the output from the encoder counters to motion jog X
newsig jogwheel-pos1 s32
linkps encoder.0.counts => jogwheel-pos1
linksp jogwheel-pos1 => axis.0.jog-counts

newsig jogwheel-pos2 s32
linkps encoder.1.counts => jogwheel-pos2
linksp jogwheel-pos2 => axis.2.jog-counts

#next enable the jogwheel jogging
newsig enablejog bit
linksp enablejog => axis.0.jog-enable
linksp enablejog => axis.2.jog-enable

#set it to 1
sets enablejog 1

newsig jogscale float
sets jogscale 0.05
setp encoder.0.x4-mode 1
setp encoder.1.x4-mode 1
linksp Xphase-A parport.0.pin-02-out
linksp jogscale => axis.0.jog-scale
linksp jogscale => axis.2.jog-scale

	#feedwheel stuff

setp encoder.2.x4-mode 1

newsig scale float
sets scale 0.05
linksp scale halui.feed-override.scale

linkpp halui.feed-override.counts encoder.2.counts





<lathe_mm.ini, relatively unchanged stepper_mm.ini file>

# EMC controller parameters for generic controller. Make these what you need
# for your system.

# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.

# Settings with a + at the front of the comment are likely needed to get 
# changed by the user.
# Settings with a - at the front are highly unneeded to be changed
###############################################################################
# General section 
###############################################################################
[EMC]

#- Version of this INI file
VERSION =               $Revision: 1.6 $

#+ Name of machine, for use with display, etc.
MACHINE =               EMC-HAL-LATHE-STEP-MM

#- Name of NML file to use, default is emc.nml
NML_FILE =              emc.nml

#+ Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
 DEBUG =                0x00000001
# DEBUG =               0x00000007
# DEBUG =               0x7FFFFFFF

###############################################################################
# Sections for display options 
###############################################################################
[DISPLAY]

#+ Name of display program, e.g., xemc
 DISPLAY =              axis 
                         # axis is an external interface, check http://axis.unpy.net/

# DISPLAY =              usrmot
# DISPLAY =              mini
# DISPLAY = 		tkemc
# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME =            0.200

#- Path to help file
HELP_FILE =             doc/help.txt

#- Initial display setting for position, RELATIVE or MACHINE
POSITION_OFFSET =       RELATIVE

#- Initial display setting for position, COMMANDED or ACTUAL
POSITION_FEEDBACK =     ACTUAL

#+ Highest value that will be allowed for feed override, 1.0 = 100%
MAX_FEED_OVERRIDE =     1.5

#- Prefix to be used
PROGRAM_PREFIX =        /home/cnc-lathe/Desktop/programs/

#- Introductory graphic
INTRO_GRAPHIC =         emc2.gif
INTRO_TIME =            3

#- Machine hardare
LATHE =                 YES


###############################################################################
# Task controller section 
###############################################################################
[TASK]

#- Name of task controller program, e.g., bridgeporttask
TASK =                  milltask
# TASK =                minimilltask

#- Cycle time, in seconds, that task controller will sleep between polls
CYCLE_TIME =            0.010

###############################################################################
# Part program interpreter section 
###############################################################################
[RS274NGC]

#- File containing interpreter variables
PARAMETER_FILE =        stepper.var

###############################################################################
# Motion control section 
###############################################################################
[EMCMOT]

#- Name of the motion controller to use (only one exists for nontrivkins)
EMCMOT =              motmod

#- Key for real OS shared memory, e.g., for simulated motion
SHMEM_KEY =             111

#- Timeout for comm to emcmot, in seconds
COMM_TIMEOUT =          1.0

#- Interval between tries to emcmot, in seconds
COMM_WAIT =             0.010

#+ Base task period, in nanosecs - this is the fastest thread in the machine
BASE_PERIOD =                20000
#- Servo task period, in nanosecs - will be rounded to an int multiple of BASE_PERIOD
SERVO_PERIOD =               1000000
#- Trajectory Planner task period, in nanosecs - will be rounded to an
#   integer multiple of SERVO_PERIOD
TRAJ_PERIOD =                10000000

###############################################################################
# Hardware Abstraction Layer section
###############################################################################
[HAL]

# Start halui
HALUI =                      halui

# The run script first uses halcmd to execute any HALFILE
# files, and then to execute any individual HALCMD commands.
#

# list of hal config files to run through halcmd
#+ files are executed in the order in which they appear
HALFILE =                    core_stepper.hal
#HALFILE =                    xylotex_pinout.hal
HALFILE =                    standard_pinout.hal
HALFILE =                    control_box.hal

#- list of halcmd commands to execute
# commands are executed in the order in which they appear
#HALCMD =                    save neta

###############################################################################
# Trajectory planner section
###############################################################################
[TRAJ]
#+ machine specific settings
AXES =                  3
# COORDINATES =         X Y Z R P W
COORDINATES =           X Y Z
HOME =                  0 0 0
LINEAR_UNITS =          1.0
ANGULAR_UNITS =         1.0
CYCLE_TIME =            0.010
DEFAULT_VELOCITY =      3
MAX_VELOCITY =          10
DEFAULT_ACCELERATION =  50
MAX_ACCELERATION =      100
PROBE_INDEX =           0
PROBE_POLARITY =        1

###############################################################################
# Axes sections
###############################################################################

#+ First axis
[AXIS_0]

TYPE =                          LINEAR
UNITS =                         1.0
HOME =                          0.000
MAX_VELOCITY =                  10
# NOTE:  the step generator module applies its own limits to
# acceleration and velocity.  We have discovered that it needs
# to have a little "headroom" over the accel by the trajectory
# planner, otherwise it can fall slightly behind during accel
# and later overshoot as it catches up.  In the long term we
# hope to come up with a clean fix for this problem.  In the
# meantime, please set STEPGEN_MAXACCEL below to a few percent
# higher than the regular acceleration limit MAX_ACCELERATION
MAX_ACCELERATION =              100
STEPGEN_MAXVEL =                11.5
STEPGEN_MAXACCEL =              120.0
BACKLASH = 0.000
CYCLE_TIME =                    0.001000
INPUT_SCALE =                   72    0
OUTPUT_SCALE = 1.000 0.000
MIN_LIMIT =                     -1000.0
MAX_LIMIT =                     1000.0
FERROR = 1.270
MIN_FERROR = 0.254
HOME_OFFSET =                    0.0
HOME_SEARCH_VEL =                0.0
HOME_LATCH_VEL =                 0.0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO

#+ Second axis
[AXIS_1]

TYPE =                          LINEAR
UNITS =                         1
HOME =                          0.000
MAX_VELOCITY =                  10
MAX_ACCELERATION =              100
STEPGEN_MAXVEL =                11.5
STEPGEN_MAXACCEL =              120.0
BACKLASH = 0.000
CYCLE_TIME =                    0.001000
INPUT_SCALE =                   72    0
OUTPUT_SCALE = 1.000 0.000
MIN_LIMIT =                     -1000.0
MAX_LIMIT =                     1000.0
FERROR = 1.270
MIN_FERROR = 0.254
HOME_OFFSET =                    0.0
HOME_SEARCH_VEL =                0.0
HOME_LATCH_VEL =                 0.0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO

#+ Third axis
[AXIS_2]

TYPE =                          LINEAR
UNITS =                         1
HOME =                          0.0
MAX_VELOCITY =                  10
MAX_ACCELERATION =              100
STEPGEN_MAXVEL =                11.5
STEPGEN_MAXACCEL =              120
BACKLASH = 0.000
CYCLE_TIME =                    0.001000
INPUT_SCALE =                   72    0
OUTPUT_SCALE = 1.000 0.000
MIN_LIMIT =                     -1000.0
MAX_LIMIT =                     1000.0
FERROR = 1.270
MIN_FERROR = 0.254
HOME_OFFSET =                    0.0
HOME_SEARCH_VEL =                0.0
HOME_LATCH_VEL =                 0.0
HOME_USE_INDEX =                 NO
HOME_IGNORE_LIMITS =             NO

###############################################################################
# section for main IO controller parameters 
###############################################################################
[EMCIO]

#- Name of IO controller program, e.g., io
EMCIO = 		io

#- cycle time, in seconds
CYCLE_TIME =            0.100

#- tool table file
TOOL_TABLE =            stepper.tbl