Advertisement
Guest User

Untitled

a guest
Jun 27th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 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. .br
  29. Plasma Torch Arc Voltage Signal => 6 x 487k 1% resistors => THC Arc Voltage In
  30. .br
  31. THC Frequency Signal => Encoder #0, pin A (Input)
  32. .br
  33. Plasma Torch Arc OK Signal => input pin
  34. .br
  35. output pin => Plasma Torch Start Arc Contacts
  36.  
  37. HAL Plasma Connections
  38. .br
  39. encoder.nn.velocity => thc.encoder-vel (tip voltage)
  40. .br
  41. motion.spindle-on => output pin (start the arc)
  42. .br
  43. thc.arc-ok <= motion.digital-in-00 <= input pin (arc ok signal)
  44.  
  45. HAL Motion Connections
  46. .br
  47. thc.requested-vel <= motion.requested-vel
  48. .br
  49. thc.current-vel <= motion.current-vel
  50.  
  51. """;
  52.  
  53. author "John Thornton";
  54.  
  55. license "GPLv2 or greater";
  56.  
  57. option singleton yes;
  58.  
  59. // Input Pins
  60. pin in float encoder_vel "Connect to hm2_5i20.0.encoder.00.velocity";
  61. pin in float current_vel "Connect to motion.current-vel";
  62. pin in float requested_vel "Connect to motion.requested-vel";
  63. pin in float volts_requested "Tip Volts current_vel >= min_velocity requested";
  64. pin in float vel_tol "Velocity Tolerance (Corner Lock)";
  65. pin in bit torch_on "Connect to motion.spindle-on";
  66. pin in bit arc_ok "Arc OK from Plasma Torch";
  67. pin in bit enable "Enable the THC, if not enabled Z position is passed through";
  68. pin in float z_pos_in "Z Motor Position Command in from axis.n.motor-pos-cmd";
  69.  
  70. // Output Pins
  71. pin out float z_pos_out "Z Motor Position Command Out";
  72. pin out float z_fb_out "Z Position Feedback to Axis";
  73. pin out float volts "The Calculated Volts";
  74. pin out bit vel_status "When the THC thinks we are at requested speed";
  75.  
  76. // Parameters
  77. param rw float vel_scale "The scale to convert the Velocity signal to Volts";
  78. param rw float scale_offset "The offset of the velocity input at 0 volts";
  79. param rw float velocity_tol "The deviation percent from planned velocity";
  80. param rw float voltage_tol "The deviation of Tip Voltage before correction takes place";
  81. param rw float correction_vel "The amount of change in user units per period to move Z to correct";
  82.  
  83. // Global Variables
  84. variable float offset;
  85. variable float last_z_in;
  86.  
  87. function _;
  88.  
  89. ;;
  90.  
  91. #include "rtapi_math.h"
  92.  
  93. FUNCTION(_) {
  94. // convert encoder velocity to volts
  95. volts = (encoder_vel - scale_offset) * vel_scale;
  96. if(volts < 0){volts = 0;} // make sure volts is not negative
  97.  
  98. if(enable){
  99. float min_velocity = requested_vel -(requested_vel*(velocity_tol*0.01));
  100. if(current_vel > 0 && current_vel >= min_velocity){vel_status = 1;}
  101. else {vel_status =0;}
  102.  
  103. if(torch_on && arc_ok && vel_status){ // allow correction
  104. if((volts + voltage_tol) > volts_requested){
  105. offset -= correction_vel;
  106. }
  107. if((volts - voltage_tol) < volts_requested){
  108. offset += correction_vel;
  109. }
  110. last_z_in = 0;
  111. }
  112. if(!torch_on){ // remove any offset
  113. float z_diff;
  114. z_diff = z_pos_in - last_z_in;
  115. if(z_diff > 0 && offset != 0){ // torch is moving up
  116. if(offset > 0){ // positive offset
  117. if(offset > z_diff){ // remove some
  118. offset -= z_diff;
  119. }
  120. else {offset = 0;}
  121. }
  122. if(offset < 0){ // negative offset
  123. if(offset < z_diff){ // remove some
  124. offset += z_diff;
  125. }
  126. else {offset = 0;}
  127. }
  128. }
  129. last_z_in = z_pos_in;
  130. }
  131. z_pos_out = z_pos_in + offset;
  132. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  133. }
  134. if(!enable){
  135. z_pos_out = z_pos_in;
  136. z_fb_out = z_pos_in; // keep axis motor position fb from being confused
  137. }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement