tjb1

Untitled

Nov 19th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 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";
  55. pin in bit torch_down "Connect to parport.1.pin-13-in";
  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";
  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. pin out bit vel_status "When the THC thinks we are the requested speed";
  68. pin out bit removing_offset "Pin for testing";
  69.  
  70. // Parameters
  71.  
  72. param rw float correction_vel "The Velocity to move Z to correct";
  73.  
  74. // Global Variables
  75. variable float offset;
  76. variable float last_z_in;
  77.  
  78. function _;
  79.  
  80. ;;
  81.  
  82. #include "rtapi_math.h"
  83.  
  84. FUNCTION(_) {
  85. if(enable){
  86. float min_velocity = requested_vel -(requested_vel*(.8)); //.8 is velocity tolerance, change as needed
  87. if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
  88. else {vel_status = 0;}
  89.  
  90. if(torch_on && arc_ok && vel_status){ // allow correction
  91. if(torch_down){
  92. offset -= correction_vel;
  93. }
  94. if(torch_up){
  95. offset += correction_vel;
  96. }
  97. last_z_in = 0;
  98. }
  99. if(!torch_on){ // remove any offset
  100. float z_diff;
  101. z_diff = z_pos_in - last_z_in;
  102. if(z_diff > 0 && offset != 0){ // torch is moving up
  103. removing_offset = 1;
  104. if(offset > 0){ // positive offset
  105. if(offset > z_diff){ // remove some
  106. offset -= z_diff;
  107. }
  108. else {offset = 0;}
  109. }
  110. if(offset < 0){ // negative offset
  111. if(offset < z_diff){ // remove some
  112. offset += z_diff;
  113. }
  114. else {offset = 0;}
  115. }
  116. }
  117. else {removing_offset = 0;}
  118. last_z_in = z_pos_in;
  119. }
  120. z_pos_out = z_pos_in + offset;
  121. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  122. }
  123. if(!enable){
  124. z_pos_out = z_pos_in;
  125. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  126. }
  127. }
Add Comment
Please, Sign In to add comment