#$Id: bridgeportS2I2.hal,v 1.7 2010/01/17 21:17:28 zephyr Exp $ # components # # Load I_O_status indicator panel. #loadusr -Wn I_O_status pyvcp -g 100x500+924+150 -c I_O_status I_O_status.xml loadusr -W hal_input -K keyboard 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 num_joints=[TRAJ]AXES loadrt pid num_chan=3 loadrt and2 names=u1,u2,u3,u4,u5,u6 loadrt oneshot names=os1 loadrt debounce cfg=4,6 loadrt not names=invert1,invert2,invert3,invert4,invert5 loadrt timedelay names=tdly1,tdly2 loadrt hostmot2 loadrt hm2_pci config="firmware=hm2/5i20/SVST8_4.BIT num_encoders=4 num_pwmgens=3 num_stepgens=0" addf hm2_5i20.0.pet_watchdog servo-thread addf hm2_5i20.0.read servo-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 addf u1 servo-thread addf u2 servo-thread addf u3 servo-thread addf u4 servo-thread addf u5 servo-thread addf u6 servo-thread addf os1 servo-thread addf invert1 servo-thread addf invert2 servo-thread addf invert3 servo-thread addf invert4 servo-thread addf tdly1 servo-thread addf tdly2 servo-thread addf debounce.0 servo-thread addf debounce.1 servo-thread addf hm2_5i20.0.write servo-thread ######################################################################## # # Encoder inputs # set the encoder scales setp hm2_5i20.0.encoder.00.scale [AXIS_0]INPUT_SCALE setp hm2_5i20.0.encoder.01.scale [AXIS_1]INPUT_SCALE setp hm2_5i20.0.encoder.02.scale [AXIS_2]INPUT_SCALE ######################################################################## # # PID controller seection # # create three position feedback signals and connect the encoder outputs to the PID inputs and contoller position inputs # net Xpos-fb <= hm2_5i20.0.encoder.00.position => pid.0.feedback => axis.0.motor-pos-fb net Ypos-fb <= hm2_5i20.0.encoder.01.position => pid.1.feedback => axis.1.motor-pos-fb net Zpos-fb <= hm2_5i20.0.encoder.02.position => pid.2.feedback => axis.2.motor-pos-fb # # position command signals net Xpos-cmd axis.0.motor-pos-cmd => pid.0.command net Ypos-cmd axis.1.motor-pos-cmd => pid.1.command net Zpos-cmd axis.2.motor-pos-cmd => pid.2.command # axis enable signals net X_RELEASE axis.0.amp-enable-out => pid.0.enable => hm2_5i20.0.pwmgen.00.enable net Y_RELEASE axis.1.amp-enable-out => pid.1.enable => hm2_5i20.0.pwmgen.01.enable net Z_RELEASE axis.2.amp-enable-out => pid.2.enable => hm2_5i20.0.pwmgen.02.enable # connect output signals to output of PID loops net PWM_X <= pid.0.output => hm2_5i20.0.pwmgen.00.value net PWM_Y <= pid.1.output => hm2_5i20.0.pwmgen.01.value net PWM_Z <= pid.2.output => hm2_5i20.0.pwmgen.02.value # set PID loop output limits to +/-1.00 setp pid.0.maxoutput [AXIS_0]MAX_VELOCITY setp pid.1.maxoutput [AXIS_1]MAX_VELOCITY setp pid.2.maxoutput [AXIS_2]MAX_VELOCITY # set PID loop gains from inifile # the values below come from the ini setp pid.0.Pgain [AXIS_0]P setp pid.0.Igain [AXIS_0]I setp pid.0.Dgain [AXIS_0]D setp pid.0.bias [AXIS_0]BIAS setp pid.0.FF0 [AXIS_0]FF0 setp pid.0.FF1 [AXIS_0]FF1 setp pid.0.FF2 [AXIS_0]FF2 setp pid.0.deadband [AXIS_0]DEADBAND setp pid.1.Pgain [AXIS_1]P setp pid.1.Igain [AXIS_1]I setp pid.1.Dgain [AXIS_1]D setp pid.1.bias [AXIS_1]BIAS setp pid.1.FF0 [AXIS_1]FF0 setp pid.1.FF1 [AXIS_1]FF1 setp pid.1.FF2 [AXIS_1]FF2 setp pid.1.deadband [AXIS_1]DEADBAND setp pid.2.Pgain [AXIS_2]P setp pid.2.Igain [AXIS_2]I setp pid.2.Dgain [AXIS_2]D setp pid.2.bias [AXIS_2]BIAS setp pid.2.FF0 [AXIS_2]FF0 setp pid.2.FF1 [AXIS_2]FF1 setp pid.2.FF2 [AXIS_2]FF2 setp pid.2.deadband [AXIS_2]DEADBAND ########################################################################## # # Setup PWMs on Mesa Card # # set pwm frequency to the max setp hm2_5i20.0.pwmgen.pwm_frequency 193000 setp hm2_5i20.0.pwmgen.00.output-type 1 setp hm2_5i20.0.pwmgen.00.scale 10 setp hm2_5i20.0.pwmgen.01.scale 10 setp hm2_5i20.0.pwmgen.02.scale 10 # # ############################################################################## # # Home Switches and Index Pulse Section # # home switch inputs net X_home_switch_P => axis.0.home-sw-in net Y_home_switch_P => axis.1.home-sw-in net Z_home_switch_P => axis.2.home-sw-in # # #hook the index enables to the axis objects net X_index axis.0.index-enable hm2_5i20.0.encoder.00.index-enable net Y_index axis.1.index-enable hm2_5i20.0.encoder.01.index-enable net Z_index axis.2.index-enable hm2_5i20.0.encoder.02.index-enable # ################################################################################ # # Joy Stick Inputs - see bridgeportS2I2postgui.hal for debounced Joystick connections # setp debounce.1.delay 50 net X_Joy_P => debounce.1.0.in net X_Joy_N => debounce.1.1.in net Y_Joy_P => debounce.1.2.in net Y_Joy_N => debounce.1.3.in net Z_Joy_P => debounce.1.4.in net Z_Joy_N => debounce.1.5.in # note: Joy_Rapid button in the center of joystick is connected in bridgeportS2I2postgui.hal # # ################################################################################ # # Pulse Encoder Input # # connect hand wheel encoder to all 3 axis # net JogWheelCounts axis.0.jog-counts axis.1.jog-counts axis.2.jog-counts hm2_5i20.0.encoder.03.count # ################################################################################ # # Start and Stop buttons # External Stop and Start buttons will pause and restart motion if # programm is running. Otherwise Start will start program if in manual mode. # # hm2_5i20.0.gpio.049.in_not----[ debounce.0.1 ]----------------->I_O_status.led_49 # (CycleStart ) | ________ # |--| AND | # | u4 |---->halui.program.resume # halui.program.is-paused---------------------------|________| (ProgResume) # (ProgIsPaused) # # hm2_5i20.0.gpio.053.in_not----[ debounce.0.2 ]----------------->I_O_status.led_53 # (CycleStop ) | ________ # | |INVERT | # |--| invert2|----| # | |________| | # --------------------------------| | # | | # | ---------------------| # | | ________ # | |----| AND | # | | u3 |--->halui.program.pause # | halui.program.is-running-----|________| (ProgPause) # | (ProgIsRunning) # | # | ________ # |----------------------------------| AND | # | u5 |---->halui.program.resume # halui.program.is-idle-- --------------------------|________| (ProgResume) # (ProgIsIdle) setp debounce.0.delay 15 net Cycle_Start debounce.0.1.in net Cycle_Stop debounce.0.2.in net Cycle_StartDb debounce.0.1.out => u4.in0 net Cycle_StopDb debounce.0.2.out => invert2.in net Cycle_StopDbNot invert2.out => u3.in0 net ProgPause u3.out => halui.program.pause net ProgResume u4.out => halui.program.resume net ProgIsRunning halui.program.is-running => u3.in1 net ProgIsPaused halui.program.is-paused => u4.in1 net ProgIsIdle halui.program.is-idle => u5.in1 net Cycle_StartDb => u5.in0 net ProgRun u5.out => halui.program.run # ################################################################################ # # Machine ON DC interlock logic # # If EMC Estop is active then DC_INTERLOCK(10 CR) drops out and # spindle(3CR, 3MF, 4MF) and Servo Feed Contactor(5FC) Drops out. # see bridgeport schematic. net 24_volts => u2.in1 net EstopActive halui.estop.is-activated => invert3.in net EstopActiveNot invert3.out => u2.in0 net DC_INTERLOCK <= u2.out # ################################################################################ # # Estop Input # # If the 120V estop is pressed the 24V and FeedContactor will drop out # The servos will have resistive brakes applied and spindle will stop # # The FeedContactor droping out is used to activate the EMC2 estop input # When the machine is powered on the FeedContactor is not automatically # enabled. There is an external button and circuit. So a one # shot is used to activae estop only when the FeedContactor goes from # on to off # # # hm2_5i20.0.gpio.051.in_not---------------------------I_O_status.led_51 # (EstopAndFeedEnable) | # | _________ # | | | # |--[ debounce.0.0 ]---| os1 |----halui.estop.active # | one shot| (Estop) # | falling | # | 1 Sec | # |_________| # # setp os1.falling TRUE setp os1.rising FALSE newsig os1Time float sets os1Time 1 net os1Time => os1.width #net EstopAndFeedEnable => I_O_status.led_51 net EstopAndFeedEnable => debounce.0.0.in net EstopAndFeedEnableDb debounce.0.0.out => os1.in net Estop os1.out => halui.estop.activate # # create a signal for the estop loopback -- remove for external # net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in # ################################################################################ # # Manual - Auto Relay output # net ModeIsManual halui.mode.is-manual => invert1.in net ModeIsManualNot <= invert1.out # # ################################################################################ # # Spindle Start and Stop Logic # FucntionVerify is derived from external bridgeport relay logic: # (SpindleRunning(1CR) AND SpindleStop(15CR) ) OR SpindleStop(16CR)) # # motion.spindle-on---------------------------------------------->hm2_gpio067 # (MotionSpindleOn) | ________ # |-------[ tdly1 ]---| AND | # \ | u1 |---->motion.spindle-at-speed # hm2_gpio063 --------|-------[ tdly2 ]--|________| (SpindleAtSpeed) # (FunctionVerify) / # | ________ # |-----[ invert4 ]---| AND | # | u6 |---->hm2_gpio069 # halui.mode-is-manual-----[ invert1 ]-----|________| (SpindleStop) # (ModeIsManual) # # # setp tdly1.on-delay 0.5 setp tdly1.off-delay 0 setp tdly2.on-delay 4 setp tdly2.off-delay 0.03 net MotionSpindleOn motion.spindle-on => tdly1.in => invert4.in net MotionSpindleOnNot invert4.out => u6.in0 net MotionSpindleOnDly tdly1.out => u1.in0 net SpindleStop <= u6.out net ModeIsManualNot u6.in1 net FunctionVerify => tdly2.in net FunctionVerifyDb tdly2.out => u1.in1 net SpindleAtSpeed u1.out => motion.spindle-at-speed ########################################################################### # # GPIO Section # # Set the I/O for the relays as outputs setp hm2_5i20.0.gpio.064.is_output TRUE setp hm2_5i20.0.gpio.065.is_output TRUE setp hm2_5i20.0.gpio.066.is_output TRUE setp hm2_5i20.0.gpio.067.is_output TRUE setp hm2_5i20.0.gpio.068.is_output TRUE setp hm2_5i20.0.gpio.069.is_output TRUE setp hm2_5i20.0.gpio.070.is_output TRUE setp hm2_5i20.0.gpio.071.is_output TRUE # setp hm2_5i20.0.gpio.064.invert_output TRUE setp hm2_5i20.0.gpio.065.invert_output TRUE setp hm2_5i20.0.gpio.066.invert_output TRUE setp hm2_5i20.0.gpio.067.invert_output TRUE setp hm2_5i20.0.gpio.068.invert_output TRUE setp hm2_5i20.0.gpio.069.invert_output TRUE setp hm2_5i20.0.gpio.070.invert_output TRUE setp hm2_5i20.0.gpio.071.invert_output TRUE # # GPIO Input assignments # net X_home_switch_P <= hm2_5i20.0.gpio.048.in_not net Cycle_Start <= hm2_5i20.0.gpio.049.in_not net Y_home_switch_P <= hm2_5i20.0.gpio.050.in_not net EstopAndFeedEnable <= hm2_5i20.0.gpio.051.in_not net Z_home_switch_P <= hm2_5i20.0.gpio.052.in_not net Cycle_Stop <= hm2_5i20.0.gpio.053.in_not net Z_Joy_N <= hm2_5i20.0.gpio.054.in_not net X_Joy_P <= hm2_5i20.0.gpio.055.in_not net Z_Joy_P <= hm2_5i20.0.gpio.056.in_not net X_Joy_N <= hm2_5i20.0.gpio.057.in_not net Joy_Rapid <= hm2_5i20.0.gpio.058.in_not net Y_Joy_P <= hm2_5i20.0.gpio.059.in_not # net SPARE_INPUT <= hm2_5i20.0.gpio.060.in_not net Y_Joy_N <= hm2_5i20.0.gpio.061.in_not net 24_volts <= hm2_5i20.0.gpio.062.in_not net FunctionVerify <= hm2_5i20.0.gpio.063.in_not # # GPIO Output assignments # net DC_INTERLOCK => hm2_5i20.0.gpio.064.out net ModeIsManualNot => hm2_5i20.0.gpio.065.out net X_RELEASE => hm2_5i20.0.gpio.066.out net MotionSpindleOn => hm2_5i20.0.gpio.067.out net Y_RELEASE => hm2_5i20.0.gpio.068.out net SpindleStop => hm2_5i20.0.gpio.069.out net Z_RELEASE => hm2_5i20.0.gpio.070.out # net SPARE_OUTPUT => hm2_5i20.0.gpio.071.out # ####################################################################### # # PYVCP Panel Section # This panel displays the Status of all GPIO inputs # # #net X_home_switch_P => I_O_status.led_48 #net Cycle_Start => I_O_status.led_49 #net Y_home_switch_P => I_O_status.led_50 #net EstopAndFeedEnable => I_O_status.led_51 #net Z_home_switch_P => I_O_status.led_52 #net Cycle_Stop => I_O_status.led_53 #net Z_Joy_N => I_O_status.led_54 #net X_Joy_P => I_O_status.led_55 #net Z_Joy_P => I_O_status.led_56 #net X_Joy_N => I_O_status.led_57 #net Joy_Rapid => I_O_status.led_58 #net Y_Joy_P => I_O_status.led_59 # net SPARE => I_O_status.led_60 #net Y_Joy_N => I_O_status.led_61 #net 24_volts => I_O_status.led_62 #net FunctionVerify => I_O_status.led_63 #$Log: bridgeportS2I2.hal,v $ #Revision 1.7 2010/01/17 21:17:28 zephyr #*** empty log message *** # #Revision 1.6 2010/01/14 23:38:53 zephyr #*** empty log message *** # #Revision 1.5 2010/01/13 03:24:23 zephyr #made it look nicer. # #Revision 1.4 2010/01/12 03:13:15 zephyr #*** empty log message *** # #Revision 1.3 2009/10/26 02:38:34 zephyr #joy stick hooked up # #Revision 1.2 2009/10/23 00:26:58 zephyr #*** empty log message *** # #Revision 1.1 2009/09/26 02:02:00 zephyr #Initial revision #