For those of you who downloed the THC.GUI.V1.0.0.tft firmware file it was missing a settings few pages... my bad... I've uploaded the new one THC.GUI.V1.0.1.tft please grab that and reflash your displays. Thanks to the members of the community that pointed this out to me!
Arduino based THC that reads plasma cutter voltage and send Up and Down signals to Plasma Torch Actuator to adjust voltage to target value.
Aim is to create a low cost and easy to use Torch Height Controller with off the shelf parts, simple easy to read code and as little electronics tinkering as possible. This is a standalone type of THC so it requires an actuator to move the torch independent of the CNC machines controller. If you interface this THC with your CNC Machine please post how you did it!
The unknown we are trying to solve for here is the Torch Height from the Workpiece measurement. It's important for a plasma arc to be stable and be a set height from the workpiece to be cut. The main reason for this is the plasma arc will cut a bevel on the side walls if the height is not set right or crash into the workpiece... This is because the plasma arc is not like a laser with straight edges but more like an egg. Making the problem worse is the fact the metal can warp and contort when a hot plasma arc cuts into it. Using the Arc Voltage is a good way to estimate the distance to the workpiece from the torch head.
The proportional correlation is the longer the arc the higher the voltage. So, we can measure the plasma voltage and feed that into a PID Algorithm to calculate the torch height to change the voltage to a setpoint. It is unwise to measure the Arc Voltage Directly off the plasma torch because the levels there can be deadly. Most CNC ready Plasma Cutters on the market have 50:1 - 16:1 arc voltage dividers built right into the machine. If yours doesn't have this then you will need to do surgery and add a voltage divider circuit to your plasma cutter... Check the Technical Specs of your plasma cutter: Don't Die.
The User Interface is a Nextion standalone HMI Screen that can adjust most setting and Save tro EEPROM without update Arduino Code. The beauty of use this screen is it handles all the heavy UI events leaving the arduino free to calulate as fast as possible. The Arduino talks with the Nextion Screen via Serial Connection and updates all values. As the user triggers events on the nextion screen the they are reported to the Arduino borad for processing and any calulations needed.
Nextion’s microSD slot is primarily used to upload a TFT project file. Not all microSD cards are made for use with embedded devices especially newer microSD cards made for cameras, etc. Class 10 HC 8GB to 32GB cards have had good success.
Ensure
If microSD upload is unsuccessful
Follow these steps to upload your sketch:
This code is designed to run as fast as possible. It uses a while() loop to focus on Calulations and movements when voltage input is over the threshold.
// the loop function runs over and over again forever
void loop()
{
THCNex.NextionListen();
Input = map(analogRead(PLASMA_INPUT_PIN),0,1023,0,25000)+CalibrationOffset; //reads plasma arc voltage and convert to millivolt
process(); //This is the main method of the application it calulates position and move steps if Input Voltage is over threshold.
if(CurrentPageNumber <= 6 || CurrentPageNumber == 11){report();}
}
void process() //Calculates position and move steps
{
oldDelay = micros();
while(Input > (threshold+CalibrationOffset)) //Only move if cutting by checking for voltage above a threshold level
{
if(micros()-oldDelay >= arcStabilizeDelay) //wait for arc to stabilize tipically 100-300ms
{
Input = map(analogRead(PLASMA_INPUT_PIN),0,1023,0,25000)+CalibrationOffset; //get new plasma arc voltage and convert to millivolts
currentGap = abs(SetPoint-Input); //distance away from setpoint
if (currentGap < gap) {THCPID.setCoefficients(Kp, Ki, Kd, Hz);} //we're close to setpoint, use conservative tuning parameters
else {THCPID.setCoefficients(aggKp, aggKi, aggKd, Hz);} //we're far from setpoint, use aggressive tuning parameters
if (SetPoint > Input)
{
targetInput = Input - SetPoint + SetPoint;
output = THCPID.step(SetPoint, targetInput);
pos = pos + output;
}
else
{
targetInput = SetPoint - Input + SetPoint;
output = THCPID.step(SetPoint, targetInput);
pos = pos - output;
}
//Validate move is within range
if(pos >= maxPos){pos = maxPos;}
if(pos <= minPos){pos = minPos;}
//do move
stepper.moveTo(pos);
while(stepper.distanceToGo() != 0){stepper.run();}
report(); //report plasma voltage and position
//format();
}
}
}