Advertisement
Guest User

Untitled

a guest
Feb 26th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. component thc "Torch Height Control";
  2.  
  3. description
  4. """
  5. Torch Height Control
  6. Mesa THC > Encoder > LinuxCNC THC component
  7.  
  8. The Mesa THC sends a frequency based on the voltage detected to the encoder.
  9. The velocity from the encoder is converted to volts with the velocity scale
  10. parameter inside the THC component.
  11.  
  12. The THCAD card sends a frequency at 0 volts so the scale offset parameter is
  13. used to zero the calculated voltage.
  14.  
  15. Component Functions
  16. If enabled and torch is on and X + Y velocity is within tolerance of set speed
  17. allow the THC to offset the Z axis as needed to maintain voltage.
  18.  
  19. If enabled and torch is off and the Z axis is moving up remove any correction
  20. at a rate not to exceed the rate of movement of the Z axis.
  21.  
  22. If enabled and torch is off and there is no correction
  23. pass the Z position and feed back untouched.
  24.  
  25. If not enabled pass the Z position and feed back untouched.
  26.  
  27. Physical Connections
  28. Plasma Torch Arc Voltage Signal => 6 x 487k 1% resistors => THC Arc Voltage In
  29. THC Frequency Signal => Encoder #0, pin A (Input)
  30. Plasma Torch Arc OK Signal => input pin
  31. output pin => Plasma Torch Start Arc Contacts
  32.  
  33. HAL Plasma Connections
  34. encoder.nn.velocity => thc.encoder-vel (tip voltage)
  35. motion.spindle-on => output pin (start the arc)
  36. thc.arc-ok <= motion.digital-in-00 <= input pin (arc ok signal)
  37.  
  38. HAL Motion Connections
  39. thc.requested-vel <= motion.requested-vel
  40. thc.current-vel <= motion.current-vel
  41.  
  42. """;
  43.  
  44. author "John Thornton";
  45.  
  46. license "GPLv2 or greater";
  47.  
  48. option singleton yes;
  49.  
  50. // Input Pins
  51. pin in float encoder_vel "Connect to hm2_5i20.0.encoder.00.velocity";
  52. pin in float current_vel "Connect to motion.current-vel";
  53. pin in float requested_vel "Connect to motion.requested-vel";
  54. pin in float volts_requested "Tip Volts current_vel >= min_velocityequested (SP)";
  55. pin in float vel_tol "Velocity Tolerance (Corner Lock)";
  56. pin in bit torch_on "Connect to motion.spindle-on";
  57. pin in bit arc_ok "Arc OK from Plasma Torch";
  58. pin in bit enable "Enable the THC, if not enabled Z position is passed through";
  59. pin in float z_pos_in "Z Motor Position Command in from axis.n.motor-pos-cmd";
  60.  
  61. // Output Pins
  62. pin out float z_pos_out "Z Motor Position Command Out";
  63. pin out float z_fb_out "Z Position Feedback to Axis";
  64. pin out float volts "The Calculated Volts";
  65. pin out bit vel_status "When the THC thinks we are at requested speed";
  66.  
  67. // Parameters
  68. param rw float vel_scale "The scale to convert the Velocity signal to Volts";
  69. param rw float scale_offset "The offset of the velocity input at 0 volts";
  70. param rw float velocity_tol "The deviation percent from planned velocity, 80% = .8";
  71. param rw float voltage_tol "The deviation of Tip Voltage before correction takes place";
  72. param rw float correction_tol "Proportional offset, (volts_requested - volts)*thisnumber";
  73.  
  74. // Global Variables
  75. variable float offset;
  76. variable float correction_vel;//Changed from parameter
  77. variable float last_z_in;
  78.  
  79. function _;
  80.  
  81. ;;
  82.  
  83. #include "rtapi_math.h"
  84.  
  85. FUNCTION(_) {
  86. // convert encoder velocity to volts
  87. volts = (encoder_vel - scale_offset) * vel_scale;
  88. correction_vel = fabs((volts_requested - volts) * correction_tol);//Proportional offset based on voltage
  89. if(volts < 0){volts = 0;} // make sure volts is not negative
  90.  
  91. if(enable){
  92. float min_velocity = requested_vel -(requested_vel*velocity_tol);
  93. if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
  94. else {vel_status =0;}
  95.  
  96. if(torch_on && arc_ok && vel_status){ // allow correction
  97. if((volts - voltage_tol) > volts_requested){
  98. offset -= correction_vel;
  99. }
  100. if((volts + voltage_tol) < volts_requested){
  101. offset += correction_vel;
  102. }
  103. last_z_in = 0;
  104. }
  105. if(!torch_on){ // remove any offset
  106. float z_diff;
  107. z_diff = z_pos_in - last_z_in;
  108. if(z_diff > 0 && offset != 0){ // torch is moving up
  109. if(offset > 0){ // positive offset
  110. if(offset > z_diff){ // remove some
  111. offset -= z_diff;
  112. }
  113. else {offset = 0;}
  114. }
  115. if(offset < 0){ // negative offset
  116. if(offset < z_diff){ // remove some
  117. offset += z_diff;
  118. }
  119. else {offset = 0;}
  120. }
  121. }
  122. last_z_in = z_pos_in;
  123. }
  124. z_pos_out = z_pos_in + offset;
  125. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  126. }
  127. if(!enable){
  128. z_pos_out = z_pos_in;
  129. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement