All pastes #138639 Raw Edit

Lerneaen Hydra

public unlisted text v1 · immutable
#138639 ·published 2006-08-19 10:55 UTC
rendered paste body
######################################
# 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
# 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