# Generated by PNCconf # Using LinuxCNC version: 2.9 # If you make changes to this file, they will be # overwritten when you run PNCconf again # Load kinematics module loadrt [KINS]KINEMATICS # Load the kinematics module for coordinate transformation # Load motor control module with specified servo period and joint count loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS # Load motor control module with specified settings # Load the hostmot2 driver loadrt hostmot2 # Load the hostmot2 FPGA interface driver # Load the Mesa 7C80 hardware module with 6 step generators loadrt hm2_rpspi config=" num_encoders=0 num_pwmgens=0 num_stepgens=6" # Configure step generation for the Mesa card # Set watchdog timer to 5 ms setp hm2_7c80.0.watchdog.timeout_ns 5000000 # Configure the watchdog timeout for 5ms # Load PID controllers for each axis loadrt pid names=pid.x,pid.y,pid.y2,pid.z,pid.s # Load PID control loops for X, Y, Y2, Z, and Spindle # Add functions to the servo thread addf hm2_7c80.0.read servo-thread # Read inputs from the Mesa card addf motion-command-handler servo-thread # Handle motion commands addf motion-controller servo-thread # Control motion execution addf pid.x.do-pid-calcs servo-thread # Perform PID calculations for X-axis addf pid.y.do-pid-calcs servo-thread # Perform PID calculations for Y-axis addf pid.y2.do-pid-calcs servo-thread # Perform PID calculations for tandem Y-axis addf pid.z.do-pid-calcs servo-thread # Perform PID calculations for Z-axis addf pid.s.do-pid-calcs servo-thread # Perform PID calculations for the spindle addf hm2_7c80.0.write servo-thread # Write outputs to the Mesa card # Configure DPLL timer setp hm2_7c80.0.dpll.01.timer-us -50 # Adjust the digital phase-locked loop timer # Configure step generator timer setp hm2_7c80.0.stepgen.timer-number 1 # Use timer 1 for step generation # Connect home switches to respective joints net home-x <= hm2_7c80.0.inmux.00.input-00 # X-axis home switch net home-y <= hm2_7c80.0.inmux.00.input-01 # Y-axis home switch net home-y2 <= hm2_7c80.0.inmux.00.input-02 # Tandem Y-axis home switch net home-z <= hm2_7c80.0.inmux.00.input-03 # Z-axis home switch # Connect XYZ probe and tool length offset (TLO) signals net xyz-probe-signal <= hm2_7c80.0.inmux.00.input-06 # XYZ probe signal for surface detection net xyz-probe-signal => motion.probe-input # Link XYZ probe to motion controller net tlo-signal <= hm2_7c80.0.inmux.00.input-04 # Tool Length Offset (TLO) signal net tlo-signal => motion.probe-input # Use the same probe input for TLO # Connect error signal for tool overtravel net tool-error <= hm2_7c80.0.inmux.00.input-05 # Tool overtravel error input net tool-error => iocontrol.0.emc-enable-in # Disable machine on tool overtravel error # Configure PID settings for X-axis setp pid.x.Pgain [JOINT_0]P # Proportional gain for X-axis PID setp pid.x.Igain [JOINT_0]I # Integral gain for X-axis PID setp pid.x.Dgain [JOINT_0]D # Derivative gain for X-axis PID setp pid.x.bias [JOINT_0]BIAS # Bias value for PID control setp pid.x.FF0 [JOINT_0]FF0 # Feedforward term 0 for X-axis setp pid.x.FF1 [JOINT_0]FF1 # Feedforward term 1 for X-axis setp pid.x.FF2 [JOINT_0]FF2 # Feedforward term 2 for X-axis setp pid.x.deadband [JOINT_0]DEADBAND # Deadband for PID control setp pid.x.maxoutput [JOINT_0]MAX_OUTPUT # Maximum output for PID control setp pid.x.error-previous-target true # Use previous target to reduce overshoot setp pid.x.maxerror 0.000500 # Maximum allowable error for PID # Connect signals for X-axis net x-index-enable <=> pid.x.index-enable # Enable index for X-axis net x-enable => pid.x.enable # Enable PID loop for X-axis net x-pos-cmd => pid.x.command # Position command for X-axis net x-pos-fb => pid.x.feedback # Position feedback for X-axis net x-output <= pid.x.output # PID output for X-axis # Configure step generator for X-axis setp hm2_7c80.0.stepgen.00.dirsetup [JOINT_0]DIRSETUP # Setup time for direction change setp hm2_7c80.0.stepgen.00.dirhold [JOINT_0]DIRHOLD # Hold time for direction setp hm2_7c80.0.stepgen.00.steplen [JOINT_0]STEPLEN # Step pulse length setp hm2_7c80.0.stepgen.00.stepspace [JOINT_0]STEPSPACE # Step pulse spacing setp hm2_7c80.0.stepgen.00.position-scale [JOINT_0]STEP_SCALE # Scaling factor for position feedback setp hm2_7c80.0.stepgen.00.step_type 0 # Step type (0 for normal step/dir) setp hm2_7c80.0.stepgen.00.control-type 1 # Control type (1 for position control) setp hm2_7c80.0.stepgen.00.maxaccel [JOINT_0]STEPGEN_MAXACCEL # Maximum acceleration for stepgen setp hm2_7c80.0.stepgen.00.maxvel [JOINT_0]STEPGEN_MAXVEL # Maximum velocity for stepgen # Connect step generator signals for X-axis net x-pos-cmd <= joint.0.motor-pos-cmd # Position command for motor net x-vel-cmd <= joint.0.vel-cmd # Velocity command for motor net x-output <= hm2_7c80.0.stepgen.00.velocity-cmd # Velocity output to stepgen net x-pos-fb <= hm2_7c80.0.stepgen.00.position-fb # Position feedback from stepgen net x-pos-fb => joint.0.motor-pos-fb # Motor position feedback net x-enable <= joint.0.amp-enable-out # Enable signal for motor amplifier net x-enable => hm2_7c80.0.stepgen.00.enable # Enable step generator for X-axis net home-x => joint.0.home-sw-in # Home switch input for X-axis net x-neg-limit => joint.0.neg-lim-sw-in # Negative limit switch input for X-axis net x-pos-limit => joint.0.pos-lim-sw-in # Positive limit switch input for X-axis # Configure PID settings for Y-axis setp pid.y.Pgain [JOINT_1]P # Proportional gain for Y-axis PID setp pid.y.Igain [JOINT_1]I # Integral gain for Y-axis PID setp pid.y.Dgain [JOINT_1]D # Derivative gain for Y-axis PID setp pid.y.bias [JOINT_1]BIAS # Bias value for PID control setp pid.y.FF0 [JOINT_1]FF0 # Feedforward term 0 for Y-axis setp pid.y.FF1 [JOINT_1]FF1 # Feedforward term 1 for Y-axis setp pid.y.FF2 [JOINT_1]FF2 # Feedforward term 2 for Y-axis setp pid.y.deadband [JOINT_1]DEADBAND # Deadband for PID control setp pid.y.maxoutput [JOINT_1]MAX_OUTPUT # Maximum output for PID control setp pid.y.error-previous-target true # Use previous target to reduce overshoot setp pid.y.maxerror 0.000500 # Maximum allowable error for PID # Connect signals for Y-axis net y-index-enable <=> pid.y.index-enable # Enable index for Y-axis net y-enable => pid.y.enable # Enable PID loop for Y-axis net y-pos-cmd => pid.y.command # Position command for Y-axis net y-pos-fb => pid.y.feedback # Position feedback for Y-axis net y-output <= pid.y.output # PID output for Y-axis # Configure step generator for Y-axis setp hm2_7c80.0.stepgen.01.dirsetup [JOINT_1]DIRSETUP # Setup time for direction change setp hm2_7c80.0.stepgen.01.dirhold [JOINT_1]DIRHOLD # Hold time for direction setp hm2_7c80.0.stepgen.01.steplen [JOINT_1]STEPLEN # Step pulse length setp hm2_7c80.0.stepgen.01.stepspace [JOINT_1]STEPSPACE # Step pulse spacing setp hm2_7c80.0.stepgen.01.position-scale [JOINT_1]STEP_SCALE # Scaling factor for position feedback setp hm2_7c80.0.stepgen.01.step_type 0 # Step type (0 for normal step/dir) setp hm2_7c80.0.stepgen.01.control-type 1 # Control type (1 for position control) setp hm2_7c80.0.stepgen.01.maxaccel [JOINT_1]STEPGEN_MAXACCEL # Maximum acceleration for stepgen setp hm2_7c80.0.stepgen.01.maxvel [JOINT_1]STEPGEN_MAXVEL # Maximum velocity for stepgen # Connect step generator signals for Y-axis net y-pos-cmd <= joint.1.motor-pos-cmd # Position command for motor net y-vel-cmd <= joint.1.vel-cmd # Velocity command for motor net y-output <= hm2_7c80.0.stepgen.01.velocity-cmd # Velocity output to stepgen net y-pos-fb <= hm2_7c80.0.stepgen.01.position-fb # Position feedback from stepgen net y-pos-fb => joint.1.motor-pos-fb # Motor position feedback net y-enable <= joint.1.amp-enable-out # Enable signal for motor amplifier net y-enable => hm2_7c80.0.stepgen.01.enable # Enable step generator for Y-axis net home-y => joint.1.home-sw-in # Home switch input for Y-axis net y-neg-limit => joint.1.neg-lim-sw-in # Negative limit switch input for Y-axis net y-pos-limit => joint.1.pos-lim-sw-in # Positive limit switch input for Y-axis # Configure PID settings for tandem Y2-axis setp pid.y2.Pgain [JOINT_2]P # Proportional gain for tandem Y-axis PID setp pid.y2.Igain [JOINT_2]I # Integral gain for tandem Y-axis PID setp pid.y2.Dgain [JOINT_2]D # Derivative gain for tandem Y-axis PID setp pid.y2.bias [JOINT_2]BIAS # Bias value for PID control setp pid.y2.FF0 [JOINT_2]FF0 # Feedforward term 0 for tandem Y-axis setp pid.y2.FF1 [JOINT_2]FF1 # Feedforward term 1 for tandem Y-axis setp pid.y2.FF2 [JOINT_2]FF2 # Feedforward term 2 for tandem Y-axis setp pid.y2.deadband [JOINT_2]DEADBAND # Deadband for PID control setp pid.y2.maxoutput [JOINT_2]MAX_OUTPUT # Maximum output for PID control setp pid.y2.error-previous-target true # Use previous target to reduce overshoot setp pid.y2.maxerror 0.000500 # Maximum allowable error for PID # Connect signals for tandem Y2-axis net y2-index-enable <=> pid.y2.index-enable # Enable index for tandem Y-axis net y2-enable => pid.y2.enable # Enable PID loop for tandem Y-axis net y2-pos-cmd => pid.y2.command # Position command for tandem Y-axis net y2-pos-fb => pid.y2.feedback # Position feedback for tandem Y-axis net y2-output <= pid.y2.output # PID output for tandem Y-axis # Configure step generator for tandem Y2-axis setp hm2_7c80.0.stepgen.02.dirsetup [JOINT_2]DIRSETUP # Setup time for direction change setp hm2_7c80.0.stepgen.02.dirhold [JOINT_2]DIRHOLD # Hold time for direction setp hm2_7c80.0.stepgen.02.steplen [JOINT_2]STEPLEN # Step pulse length setp hm2_7c80.0.stepgen.02.stepspace [JOINT_2]STEPSPACE # Step pulse spacing setp hm2_7c80.0.stepgen.02.position-scale [JOINT_2]STEP_SCALE # Scaling factor for position feedback setp hm2_7c80.0.stepgen.02.step_type 0 # Step type (0 for normal step/dir) setp hm2_7c80.0.stepgen.02.control-type 1 # Control type (1 for position control) setp hm2_7c80.0.stepgen.02.maxaccel [JOINT_2]STEPGEN_MAXACCEL # Maximum acceleration for stepgen setp hm2_7c80.0.stepgen.02.maxvel [JOINT_2]STEPGEN_MAXVEL # Maximum velocity for stepgen # Connect step generator signals for tandem Y2-axis net y2-pos-cmd <= joint.2.motor-pos-cmd # Position command for motor net y2-vel-cmd <= joint.2.vel-cmd # Velocity command for motor net y2-output <= hm2_7c80.0.stepgen.02.velocity-cmd # Velocity output to stepgen net y2-pos-fb <= hm2_7c80.0.stepgen.02.position-fb # Position feedback from stepgen net y2-pos-fb => joint.2.motor-pos-fb # Motor position feedback net y2-enable <= joint.2.amp-enable-out # Enable signal for motor amplifier net y2-enable => hm2_7c80.0.stepgen.02.enable # Enable step generator for tandem Y-axis net home-y2 => joint.2.home-sw-in # Home switch input for tandem Y-axis net y2-neg-limit => joint.2.neg-lim-sw-in # Negative limit switch input for tandem Y-axis net y2-pos-limit => joint.2.pos-lim-sw-in # Positive limit switch input for tandem Y-axis # Configure PID settings for Z-axis setp pid.z.Pgain [JOINT_3]P # Proportional gain for Z-axis PID setp pid.z.Igain [JOINT_3]I # Integral gain for Z-axis PID setp pid.z.Dgain [JOINT_3]D # Derivative gain for Z-axis PID setp pid.z.bias [JOINT_3]BIAS # Bias value for PID control setp pid.z.FF0 [JOINT_3]FF0 # Feedforward term 0 for Z-axis setp pid.z.FF1 [JOINT_3]FF1 # Feedforward term 1 for Z-axis setp pid.z.FF2 [JOINT_3]FF2 # Feedforward term 2 for Z-axis setp pid.z.deadband [JOINT_3]DEADBAND # Deadband for PID control setp pid.z.maxoutput [JOINT_3]MAX_OUTPUT # Maximum output for PID control setp pid.z.error-previous-target true # Use previous target to reduce overshoot setp pid.z.maxerror 0.000500 # Maximum allowable error for PID # Connect signals for Z-axis net z-index-enable <=> pid.z.index-enable # Enable index for Z-axis net z-enable => pid.z.enable # Enable PID loop for Z-axis # Configure spindle signals net spindle-cw => motion.spindle-forward # Spindle clockwise rotation net spindle-ccw => motion.spindle-reverse # Spindle counter-clockwise rotation net spindle-enable => motion.spindle-on # Enable spindle # Connect additional I/O signals, coolant control, and other functionalities # Connect traditional estop input net estop-in <= hm2_7c80.0.inmux.00.input-11 # Traditional estop button input net estop-in => iocontrol.0.emc-enable-in # Connect to LinuxCNC enable input # Connect alarm outputs from closed-loop steppers net x-alarm <= hm2_7c80.0.inmux.00.input-07 # Alarm output for X-axis stepper net y-alarm <= hm2_7c80.0.inmux.00.input-08 # Alarm output for Y-axis stepper net y2-alarm <= hm2_7c80.0.inmux.00.input-09 # Alarm output for tandem Y-axis stepper net z-alarm <= hm2_7c80.0.inmux.00.input-10 # Alarm output for Z-axis stepper # Connect relay outputs from Mesa card net relay-0 => hm2_7c80.0.gpio.000.out # Relay 0 control output net relay-1 => hm2_7c80.0.gpio.001.out # Relay 1 control output net relay-2 => hm2_7c80.0.gpio.002.out # Relay 2 control output net relay-3 => hm2_7c80.0.gpio.003.out # Relay 3 control output net relay-4 => hm2_7c80.0.gpio.004.out # Relay 4 control output net relay-5 => hm2_7c80.0.gpio.005.out # Relay 5 control output net relay-6 => hm2_7c80.0.gpio.006.out # Relay 6 control output net relay-7 => hm2_7c80.0.gpio.007.out # Relay 7 control output # Load manual tool change handler loadusr -W hal_manualtoolchange # Load manual tool change utility net tool-change-request iocontrol.0.tool-change => hal_manualtoolchange.change # Tool change request net tool-change-confirmed iocontrol.0.tool-changed <= hal_manualtoolchange.changed # Tool change confirmed net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number # Tool number net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared # Tool preparation # End of HAL configuration