'In THC Mode, with Side Entry DISABLED, the Z axis should: '1. If a program is not running, then the THC should not affect the Z position. Otherwise, obey the following rules. '2. Before the first cut, Z should move to a safe Z position, as specified in a2gantry.ini as [PLASMA] SAFE_Z_IN_MACHINE_COORDS = -0.1 '3. When a “spindle on” command is issued (M03): '1. issue a feedhold to prevent X and Y movement. '2. Lower the Z axis until the float switch is triggered '3. then move up until the float switch is released '4. then move up by the “Gap Distance” specified in the GUI '5. Trigger the Arc to fire (set the GPIO pin) '6. wait for the Arc OK GPIO pin to turn on, or time-out after “Arc OK Timeout” as specified in the GUI '7. if the Arc OK Timeout has expired before an ARC OK signal, then restart this firing sequence '8. while Arc OK is set, turn off the feedhold so X and Y can move as normal '9. if the Move Up GPIO is set, Z move up at the VEL_LIMIT_THC_ACTIVE speed (specified in a2gantry.ini [PLASMA] section) '10. if the Move Down GPIO is set, Z move down at the VEL_LIMIT_THC_ACTIVE speed (specified in a2gantry.ini [PLASMA] section) 'but stop if the float switch triggers '11. if CHL (Corner Height Lock) mode is enabled, ignore the Move Up and Move Down pins when the X, Y velocity is below a threshold. 'The idea is that the X and Y 'velocity will go down when going around a tight corner. In this instance, we don’t want the torch tip to dive, 'as we assume the X, Y velocity will increase in just a moment, after the corner is done. '4. After the M05 command to turn off the plasma arc (“spindle”) move up by the Travel Offset as specified in the GUI. 'This is the safe-z height to move after the material has been located once by a arc firing sequence with the float switch. '5. When the program exits, return to the last commanded Z height. This is either the Z height that was set before the program 'started, or the last G00 or G01 commanded Z height from within the program. Note that “G00 Z??” in a program will not do anything right away 'while THC is active, but it will set the Z height the axis will move to after the program ends. 'If Side Entry is ENABLED, then the sequence is a little different. '1. For the machine to find the location of the top of the material, the program must issue a M130 command to probe the material location. 'This will cause the THC controller to move down until the float switch triggers, then move up to the safe-Z travel distance. '2. The program can then move to the cut start position, which is not actually over any material (it is expecting to fire the arc 'over air, then move in from the side). '3. A M03 can now be issued as normal. Instead of probing, the THC controller will move the Z axis to the last probed height '(from the M130), and fire the arc. '4. Instead of waiting for an arc ok, the controller will immediately allow X and Y movement. Move UP and Move Down commands 'will be ignored until the Arc OK becomes true (presumably because the torch moved over some material and started cutting). 'thcflag=persist.UserData[0]; //motion flag 0 or 1 '//P=(double)persist.UserData[1]/1000; //proportion 'gn=(double)persist.UserData[2]; //gain this will make the jog speed proportional to the positon error '// if the arc voltage is off by one volt then 1 * gn = speed '//d=(double)persist.UserData[3]/1000; //derivitive 'sp=(double)persist.UserData[4]/10; //set point //units here are in arc volts x 10 like 1265 which is 126.5 'db=(double)persist.UserData[5]/10; //deadband //units here are in arc volts x 10 'sf=(double)persist.UserData[6]/10000; // scale factor to get adc units to arc volts 'sk=(double)persist.UserData[7]/1000; //soak time in ms so divided by 'mx=(double)persist.UserData[8]; //max z speed in cps 'mn=(double)persist.UserData[9]; //min z speed in cps ********************initialize kflop****************************** 'axis A ADC mode used for THC "DisableAxis4" "InputMode4=2" 'adc "OutputMode4=0" 'NO_OUTPUT_MODE 0 "InputGain04=1" '- will reverse count "InputChan04=0" 'plasma arc voltage on adc0 ' "InputChan04=1" 'for testing using adc1 ultrasonic "P4=.0001" 'proportional gain "D4=0" 'derivitive gain "I4=0" 'integral gain "Jerk4=5000000" "Accel4=4000" "FFAccel4=0" "FFVel4=0" "MaxFollowingError4=2000" "Maxoutput4=5" "MaxI4=2000" ' "deadband4=0" ' "deadbandgain4=1" "IIR4 0=0 0 1 0 0" "IIR4 1=0 0 1 0 0" "IIR4 2=0 0 1 0 0" **********This is the C program the gets run when THC is needed*************** #include "KMotionDef.h" main() { double mx; double mn; double wt; double pv; float speed; int arc_ok; int thcflag; int dflag; int i; int diveval; int ch4mult; dflag=0; ch4mult=5000; double vx,vy,speed; persist.UserData[6]=2; for (;;) { WaitNextTimeSlice(); // execute loop once per time slice (2 servo ticks) //printf("ch4 error = %f\n ",ch4->Output*5000); speed =sqrtf(ch0->last_vel * ch0->last_vel + ch2->last_vel * ch2->last_vel); // current vector speed persist.UserData[7]=ch4->Output*ch4mult; //using this for testing in vb thcflag=persist.UserData[10]; //motion flag mx=(double)persist.UserData[1]; //max voltage in adc units mn=(double)persist.UserData[2]; //min voltage diveval=persist.UserData[3]; //unitless anti dive compare wt=Time_sec()+.001; //ms pv=0; i=0; while (Time_sec()Dest = persist.UserData[4]; //height setpoint in adc units //if (pv>mx || pvOutput*ch4mult; // tie the input of ch3 to the output of ch4 // Change Encoder loop's commanded destination based on error output of arc voltage Height ch3->Dest += ch4->Output*ch4mult; //ultrasonic sensor //ch3->Dest -= ch4->Output*ch4mult; //plasma arc //*if (pv>mx) if(ch4->Output*ch4mult<-diveval || !arc_ok) //anti dive //error quickly exceeded the limit { DisableAxis(3); persist.UserData[6]=1; //thc inactive due to antidive VB dflag=1; } else { if (dflag==1) { EnableAxis(3); dflag=0; persist.UserData[6]=2; //thc active to VB } } } else { persist.UserData[6]=0; //thc active to VB } } }