Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - component thcud "Torch Height Control Up/Down Input";
 - to install open a terminal and cd to where the file is and use the following command
 - sudo comp --install thcud.comp
 - description
 - """
 - Torch Height Control
 - This THC takes either an up or a down input from a THC
 - If enabled and torch is on and X + Y velocity is within tolerance of set speed
 - allow the THC to offset the Z axis as needed to maintain voltage.
 - If enabled and torch is off and the Z axis is moving up remove any correction
 - at a rate not to exceed the rate of movement of the Z axis.
 - If enabled and torch is off and there is no correction
 - pass the Z position and feed back untouched.
 - If not enabled pass the Z position and feed back untouched.
 - Physical Connections typical
 - paraport.0.pin-12-in <= THC controller Plasma Up
 - paraport.0.pin-13-in <= THC controller Plasma Down
 - parport.0.pin-15-in <= Plasma Torch Arc Ok Signal
 - parport.0.pin-16-out => Plasma Torch Start Arc Contacts
 - HAL Plasma Connections
 - thc.torch-up <= paraport.0.pin-12-in
 - thc.torch-down <= paraport.0.pin-13-in
 - motion.spindle-on => parport.0.pin-16-out (start the arc)
 - thc.arc-ok <= motion.digital-in-00 <= parport.0.pin-15-in (arc ok signal)
 - HAL Motion Connections
 - thc.requested-vel <= motion.requested-vel
 - thc.current-vel <= motion.current-vel
 - """;
 - author "John Thornton";
 - license "GPL";
 - option singleton yes;
 - // Input Pins
 - pin in bit torch_up "Connect to paraport.0.pin-12-in";//may need changed
 - pin in bit torch_down "Connect to paraport.0.pin-13-in";//may need changed
 - pin in float current_vel "Connect to motion.current-vel";
 - pin in float requested_vel "Connect to motion.requested-vel";
 - pin in bit torch_on "Connect to motion.spindle-on";
 - pin in bit arc_ok "Arc Ok from Plasma Torch";//may need changed
 - pin in bit enable "Enable the THC, if not enabled Z position is passed through";
 - pin in float z_pos_in "Z Motor Position Command in from axis.n.motor-pos-cmd";
 - // Output Pins
 - pin out float z_pos_out "Z Motor Position Command Out";
 - pin out float z_fb_out "Z Position Feedback to Axis";
 - // Parameters
 - param rw float correction_vel "The Velocity to move Z to correct";
 - // Global Variables
 - variable float offset;
 - variable float last_z_in;
 - function _;
 - ;;
 - #include "rtapi_math.h"
 - FUNCTION(_) {
 - if(enable){
 - float min_velocity = requested_vel -(requested_vel*(.8)); //.8 is velocity tolerance, change as needed
 - if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
 - else {vel_status =0;}
 - if(torch_on && arc_ok && vel_status){ // allow correction
 - if(torch_down){
 - offset -= correction_vel;
 - }
 - if(torch_up){
 - offset += correction_vel;
 - }
 - last_z_in = 0;
 - }
 - if(!torch_on){ // remove any offset
 - float z_diff;
 - z_diff = z_pos_in - last_z_in;
 - if(z_diff > 0 && offset != 0){ // torch is moving up
 - removing_offset = 1;
 - if(offset > 0){ // positive offset
 - if(offset > z_diff){ // remove some
 - offset -= z_diff;
 - }
 - else {offset = 0;}
 - }
 - if(offset < 0){ // negative offset
 - if(offset < z_diff){ // remove some
 - offset += z_diff;
 - }
 - else {offset = 0;}
 - }
 - }
 - else {removing_offset = 0;}
 - last_z_in = z_pos_in;
 - }
 - z_pos_out = z_pos_in + offset;
 - z_fb_out = z_pos_in; // keep axis motor position fb from being confused
 - }
 - if(!enable){
 - z_pos_out = z_pos_in;
 - z_fb_out = z_pos_in; // keep axis motor position fb from being confused
 - }
 - }
 - Items need added to HAL file
 - # Torch Height Control
 - loadrt thcud
 - addf thcud servo-thread
 - # position command and feedback
 - # hijack position command and feed through thc
 - net emcmot.02.pos-cmd thcud.z-pos-in <= axis.2.motor-pos-cmd
 - net thc-pos-cmd thcud.z-pos-out => hm2_[HOSTMOT2](BOARD).0.stepgen.02.position-cmd
 - net motor.02.pos-fb axis.2.motor-pos-fb <= thcud.z-fb-out
 - Place these two files here - PROGRAM_PREFIX = /home/tyler/linuxcnc/nc_files
 - or add this line to ini file and create the directory "m_code_files" at that location
 - [RS274NGC]
 - PARAMETER_FILE = linuxcnc.var
 - ----> USER_M_PATH = /home/tyler/linuxcnc/m_code_files
 - Save below as "M101" and place in /home/tyler/linuxcnc/nc_files
 - #!/bin/bash
 - # file to activate THC - M101
 - halcmd setp thcud.enable True
 - exit 0
 - Save below as "M102" and place in /home/tyler/linuxcnc/nc_files
 - #!/bin/bash
 - # file to deactivate THC - M102
 - halcmd setp thcud.enable False
 - exit 0
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment