Advertisement
tjb1

Untitled

Nov 16th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. component thcud "Torch Height Control Up/Down Input";
  2.  
  3.  
  4.  
  5. description
  6. """
  7. to install open a terminal and cd to where the file is and use the following command
  8.  
  9. sudo comp --install thcud.comp
  10.  
  11. Torch Height Control
  12. This THC takes either an up or a down input from a THC
  13.  
  14. If enabled and torch is on and X + Y velocity is within tolerance of set speed
  15. allow the THC to offset the Z axis as needed to maintain voltage.
  16.  
  17. If enabled and torch is off and the Z axis is moving up remove any correction
  18. at a rate not to exceed the rate of movement of the Z axis.
  19.  
  20. If enabled and torch is off and there is no correction
  21. pass the Z position and feed back untouched.
  22.  
  23. If not enabled pass the Z position and feed back untouched.
  24.  
  25. Physical Connections typical
  26. parport.1.pin-12-in <= THC controller Plasma Up
  27. parport.1.pin-13-in <= THC controller Plasma Down
  28. parport.0.pin-12-in-not <= Plasma Torch Arc Ok Signal
  29. parport.0.pin-17-out => Plasma Torch Start Arc Contacts
  30.  
  31. HAL Plasma Connections
  32. thcud.torch-up <= parport.1.pin-12-in
  33. thcud.torch-down <= parport.1.pin-13-in
  34. motion.spindle-on => parport.0.pin-17-out (start the arc)
  35. thcud.arc-ok <= motion.digital-in-00 <= parport.0.pin-12-in-not (arc ok signal)
  36.  
  37. HAL Motion Connections
  38. thcud.requested-vel <= motion.requested-vel
  39. thcud.current-vel <= motion.current-vel
  40.  
  41. """;
  42.  
  43. author "John Thornton";
  44.  
  45. license "GPL";
  46.  
  47. option singleton yes;
  48.  
  49.  
  50.  
  51.  
  52.  
  53. // Input Pins
  54. pin in bit torch_up "Connect to parport.1.pin-12-in";//may need changed
  55. pin in bit torch_down "Connect to parport.1.pin-13-in";//may need changed
  56. pin in float current_vel "Connect to motion.current-vel";
  57. pin in float requested_vel "Connect to motion.requested-vel";
  58.  
  59. pin in bit torch_on "Connect to motion.spindle-on";
  60. pin in bit arc_ok "Arc Ok from Plasma Torch";//may need changed
  61. pin in bit enable "Enable the THC, if not enabled Z position is passed through";
  62. pin in float z_pos_in "Z Motor Position Command in from axis.n.motor-pos-cmd";
  63.  
  64. // Output Pins
  65. pin out float z_pos_out "Z Motor Position Command Out";
  66. pin out float z_fb_out "Z Position Feedback to Axis";
  67.  
  68.  
  69. // Parameters
  70.  
  71. param rw float correction_vel "The Velocity to move Z to correct";
  72.  
  73. // Global Variables
  74. variable float offset;
  75. variable float last_z_in;
  76.  
  77. function _;
  78.  
  79. ;;
  80.  
  81. #include "rtapi_math.h"
  82.  
  83. FUNCTION(_) {
  84. if(enable){
  85. float min_velocity = requested_vel -(requested_vel*(.8)); //.8 is velocity tolerance, change as needed
  86. if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
  87. else {vel_status =0;}
  88.  
  89. if(torch_on && arc_ok && vel_status){ // allow correction
  90. if(torch_down){
  91. offset -= correction_vel;
  92. }
  93. if(torch_up){
  94. offset += correction_vel;
  95. }
  96. last_z_in = 0;
  97. }
  98. if(!torch_on){ // remove any offset
  99. float z_diff;
  100. z_diff = z_pos_in - last_z_in;
  101. if(z_diff > 0 && offset != 0){ // torch is moving up
  102. removing_offset = 1;
  103. if(offset > 0){ // positive offset
  104. if(offset > z_diff){ // remove some
  105. offset -= z_diff;
  106. }
  107. else {offset = 0;}
  108. }
  109. if(offset < 0){ // negative offset
  110. if(offset < z_diff){ // remove some
  111. offset += z_diff;
  112. }
  113. else {offset = 0;}
  114. }
  115. }
  116. else {removing_offset = 0;}
  117. last_z_in = z_pos_in;
  118. }
  119. z_pos_out = z_pos_in + offset;
  120. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  121. }
  122. if(!enable){
  123. z_pos_out = z_pos_in;
  124. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  125. }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement