Advertisement
Guest User

Untitled

a guest
Nov 16th, 2012
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. component thcud "Torch Height Control Up/Down Input";
  2.  
  3. to install open a terminal and cd to where the file is and use the following command
  4.  
  5. sudo comp --install thcud.comp
  6.  
  7. description
  8. """
  9. Torch Height Control
  10. This THC takes either an up or a down input from a THC
  11.  
  12. If enabled and torch is on and X + Y velocity is within tolerance of set speed
  13. allow the THC to offset the Z axis as needed to maintain voltage.
  14.  
  15. If enabled and torch is off and the Z axis is moving up remove any correction
  16. at a rate not to exceed the rate of movement of the Z axis.
  17.  
  18. If enabled and torch is off and there is no correction
  19. pass the Z position and feed back untouched.
  20.  
  21. If not enabled pass the Z position and feed back untouched.
  22.  
  23. Physical Connections typical
  24. paraport.0.pin-12-in <= THC controller Plasma Up
  25. paraport.0.pin-13-in <= THC controller Plasma Down
  26. parport.0.pin-15-in <= Plasma Torch Arc Ok Signal
  27. parport.0.pin-16-out => Plasma Torch Start Arc Contacts
  28.  
  29. HAL Plasma Connections
  30. thc.torch-up <= paraport.0.pin-12-in
  31. thc.torch-down <= paraport.0.pin-13-in
  32. motion.spindle-on => parport.0.pin-16-out (start the arc)
  33. thc.arc-ok <= motion.digital-in-00 <= parport.0.pin-15-in (arc ok signal)
  34.  
  35. HAL Motion Connections
  36. thc.requested-vel <= motion.requested-vel
  37. thc.current-vel <= motion.current-vel
  38.  
  39. """;
  40.  
  41. author "John Thornton";
  42.  
  43. license "GPL";
  44.  
  45. option singleton yes;
  46.  
  47.  
  48.  
  49.  
  50.  
  51. // Input Pins
  52. pin in bit torch_up "Connect to paraport.0.pin-12-in";//may need changed
  53. pin in bit torch_down "Connect to paraport.0.pin-13-in";//may need changed
  54. pin in float current_vel "Connect to motion.current-vel";
  55. pin in float requested_vel "Connect to motion.requested-vel";
  56.  
  57. pin in bit torch_on "Connect to motion.spindle-on";
  58. pin in bit arc_ok "Arc Ok from Plasma Torch";//may need changed
  59. pin in bit enable "Enable the THC, if not enabled Z position is passed through";
  60. pin in float z_pos_in "Z Motor Position Command in from axis.n.motor-pos-cmd";
  61.  
  62. // Output Pins
  63. pin out float z_pos_out "Z Motor Position Command Out";
  64. pin out float z_fb_out "Z Position Feedback to Axis";
  65.  
  66.  
  67. // Parameters
  68.  
  69. param rw float correction_vel "The Velocity to move Z to correct";
  70.  
  71. // Global Variables
  72. variable float offset;
  73. variable float last_z_in;
  74.  
  75. function _;
  76.  
  77. ;;
  78.  
  79. #include "rtapi_math.h"
  80.  
  81. FUNCTION(_) {
  82. if(enable){
  83. float min_velocity = requested_vel -(requested_vel*(.8)); //.8 is velocity tolerance, change as needed
  84. if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
  85. else {vel_status =0;}
  86.  
  87. if(torch_on && arc_ok && vel_status){ // allow correction
  88. if(torch_down){
  89. offset -= correction_vel;
  90. }
  91. if(torch_up){
  92. offset += correction_vel;
  93. }
  94. last_z_in = 0;
  95. }
  96. if(!torch_on){ // remove any offset
  97. float z_diff;
  98. z_diff = z_pos_in - last_z_in;
  99. if(z_diff > 0 && offset != 0){ // torch is moving up
  100. removing_offset = 1;
  101. if(offset > 0){ // positive offset
  102. if(offset > z_diff){ // remove some
  103. offset -= z_diff;
  104. }
  105. else {offset = 0;}
  106. }
  107. if(offset < 0){ // negative offset
  108. if(offset < z_diff){ // remove some
  109. offset += z_diff;
  110. }
  111. else {offset = 0;}
  112. }
  113. }
  114. else {removing_offset = 0;}
  115. last_z_in = z_pos_in;
  116. }
  117. z_pos_out = z_pos_in + offset;
  118. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  119. }
  120. if(!enable){
  121. z_pos_out = z_pos_in;
  122. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  123. }
  124. }
  125.  
  126.  
  127.  
  128.  
  129. Items need added to HAL file
  130.  
  131. # Torch Height Control
  132. loadrt thcud
  133. addf thcud servo-thread
  134.  
  135. # position command and feedback
  136. # hijack position command and feed through thc
  137. net emcmot.02.pos-cmd thcud.z-pos-in <= axis.2.motor-pos-cmd
  138. net thc-pos-cmd thcud.z-pos-out => hm2_[HOSTMOT2](BOARD).0.stepgen.02.position-cmd
  139. net motor.02.pos-fb axis.2.motor-pos-fb <= thcud.z-fb-out
  140.  
  141.  
  142. Place these two files here - PROGRAM_PREFIX = /home/tyler/linuxcnc/nc_files
  143. or add this line to ini file and create the directory "m_code_files" at that location
  144. [RS274NGC]
  145. PARAMETER_FILE = linuxcnc.var
  146. ----> USER_M_PATH = /home/tyler/linuxcnc/m_code_files
  147.  
  148. Save below as "M101" and place in /home/tyler/linuxcnc/nc_files
  149. #!/bin/bash
  150. # file to activate THC - M101
  151. halcmd setp thcud.enable True
  152. exit 0
  153.  
  154. Save below as "M102" and place in /home/tyler/linuxcnc/nc_files
  155. #!/bin/bash
  156. # file to deactivate THC - M102
  157. halcmd setp thcud.enable False
  158. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement