Plasma CNC Torch Height Controller

I'm afraid I'm still a newbie when it comes to Arduinos. I've done some simple example projects so this is my first undertaking without much guidance.

Background for those who don't know what I'm talking about: I've build a CNC gantry to control a plasma cutter. The one thing my current setup cannot do is control the Z-axis which holds the cutting torch. Most people have the same problem so one solution is to spend hundreds of dollars more on a plug-and-play torch height controller (THC). The premise of the THC is to locate (zero) the work piece, then back the torch off a few millimters to pierce, then back towards the part a smudge to cut. More advanced digital models can measure the voltage between the torch and work piece so if the height of the work piece is uneven, the THC can adjust accordingly. Here's a GIF of a THC which is extremely exaggerated:

THC sketches are out there but they're "out there" for me. I just want to start simple then get advanced.

The procedure is simple. My Mach3 (plasma program) is setup with outputs to another breakout boards in my panel. It's capable of 5V discrete I/O which I've already tested between the Arduino. So, once I tell the program to start cutting, Mach3 will output a signal to start the process (int ready_THC), the Arduino will do it's THC readiness motion, and then the Arduino will output another signal to a relay to trigger the plasma machine to start cutting. Then my plasma cutter has an output to say it has struck an arc (the bright light in the GIF) which Mach3 can see to start motion on the gantry.

Down below is my setup and program. It's a mess.

The Z axis plate traverses up and down on the rails. This plate contacts the upper and lower limit switches. The torch holder has a limit switch on the back side (seen in the next picture) which is always high since the holder is forcing down on the switch. Once the torch contacts the work piece, it will lift off the switch which tells the Arduino "I've found the workpiece". Then, I do some programming to compensate the distance it took to lift the switch and extra compensating to find how far the torch tip needs to be for pierce height and then cut height (I know that'll be a trial and error process on how many times I tell the stepper to step).

int dirpin = 2; //stepper direction: HIGH=DOWN, LOW=UP
int steppin = 3; 
int z_low_ls = 12; //Lower Z-axis limit switch
int z_high_ls = 13; //Upper Z-axis limit switch
int zero_torch = 6; //Zero torch on workpiece. HIGH: no contact with workpiece. LOW: Zero'd torch on workpiece
int ready_thc = 8; //LOW: no signal to start cutting. HIGH: begin cut process
int s_ready_thc = 0; //Condition
int s_zero_torch = 0; //Condition
int s_z_high_ls = 0; //Condition
int s_z_low_ls = 0; //Condition

//Setup the I/O
void setup()

{
pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
pinMode(z_low_ls, INPUT);
pinMode(z_high_ls, INPUT);
pinMode(zero_torch, INPUT);
pinMode(ready_thc, INPUT);
}

//Move the Z-axis down
void move_down()
{
  {
  digitalWrite(dirpin, HIGH);
  digitalWrite(steppin, LOW);
  digitalWrite(steppin, HIGH);
  delayMicroseconds(200);
  }
}

//Move the Z-axis up
void move_up()
{
  {
  digitalWrite(dirpin, LOW);
  digitalWrite(steppin, LOW);
  digitalWrite(steppin, HIGH);
  delayMicroseconds(200);
  }
}

//If Mach3 hasn't sent a "start cut" signal, return the torch to the top "home position"
void home_pos()
{
  s_z_high_ls=digitalRead(z_high_ls);
  if (s_z_high_ls == HIGH)
  {
    move_up();
  }
}

//Once Mach3 gets "start cut" signal, zero the torch to the workpiece
void zero_workpiece()
{
  s_zero_torch=digitalRead(zero_torch);
  if (s_zero_torch == HIGH)
  {
    move_down();
  }
}
/*
void pierce_height()
{
  for (int i=0; i<4000; i++)
  {
    digitalWrite(dirpin, LOW);
    digitalWrite(steppin, LOW);
    digitalWrite(steppin, HIGH);
    delayMicroseconds(500);
  }
}
*/
//Program loop
void loop()
{
  s_ready_thc=digitalRead(ready_thc);
  s_z_high_ls=digitalRead(z_high_ls);
  s_zero_torch=digitalRead(zero_torch);
    if (s_ready_thc == LOW) //If the THC hasn't received a signal from Mach3, go ahead and home by traversing the Z axis to the top until the Z upper limit switch is HIGH
    {
        home_pos();
    }
    while (s_ready_thc != LOW); //If the THC has received a signal from Mach3, start the cut process
    {
        zero_workpiece();
    }
}

The furthest I can get is if there isn't a signal from the Mach3 (ready_THC == LOW), go to home_pos. When I push the z_high_ls as if the Z-axis has reached the top, the stepper does stop but continues if I let go (makes sense to me so far). However, when I set the ready_THC, I don't get a response. The stepper continues to turn.

I just want to take this one step at a time. I've tried switches and boolean but I'm having trouble understanding the nature of the programming loop as to why it's not responding.

Nudges in the right direction would be appreciated. I know my buddy is working on the same thing so I'm willing to bet a bunch of amateur Arduinoists with plasma cutters in need of THC's will appreciate the same thing.

I'm a little confused about the role of the Arduino.

You say that it can send a signal to the "plasma cutter" to start the arc. Then, from what you say, Mach3 starts moving the cutter along the desired path (I assume).

Then you have this description

Once the torch contacts the work piece, it will lift off the switch which tells the Arduino "I've found the workpiece". Then, I do some programming to compensate the distance it took to lift the switch and extra compensating to find how far the torch tip needs to be for pierce height and then cut height (I know that'll be a trial and error process on how many times I tell the stepper to step).

I'm not sure if that is a description of what it actually does now or what you want it to do.

It would help to explain how the arc works.

When you talk about controlling the height of the torch ...

  1. What sort of distances are you talking about?
  2. What is the height measured from?
  3. How can the height be measured? - it seems a hostile environment
  4. How quickly does a height correction need to take place?
  5. Why is it necessary to control the height? - what will happen if you don't control it?

...R

Robin2:
I'm a little confused about the role of the Arduino.

You say that it can send a signal to the "plasma cutter" to start the arc. Then, from what you say, Mach3 starts moving the cutter along the desired path (I assume).

My plasma cutter has an additional port on the back with two sets of wires: one set to start the torch and another set to say there's an arc between the torch and work piece, i.e. it's cutting. The Arduino will connect to a relay to close the first set and the second set goes to my breakout board which is being monitored by the Mach3 software.

Robin2:
Then you have this description
I'm not sure if that is a description of what it actually does now or what you want it to do.

Here's a video of what I'm trying to explain:

The steps are index (zero) the work piece, go to pierce height, start the arc, drop down to cut height, then cut.

Robin2:
It would help to explain how the arc works.

When you talk about controlling the height of the torch ...

  1. What sort of distances are you talking about?
  2. What is the height measured from?
  3. How can the height be measured? - it seems a hostile environment
  4. How quickly does a height correction need to take place?
  5. Why is it necessary to control the height? - what will happen if you don't control it?

...R

  1. Zero height is the index height between the tip of the torch to the work piece (which should be zero once it contacts the part). Pierce height is around a couple millimeters above the work piece, then the plasma cutter will start arc, then the THC lowers to cut height which is about a millimeter above the work piece. There is a table of different pierce/cut heights in the manual which depend on what kind of torch cutter you are using, the material, etc.

  2. From the work piece? Not sure what you're asking there.

  3. It's a 200 step/rev stepper and the thread is X pitch so I can get a ballpark number how many times I need to tell the stepper to step to get my heights.

  4. I'm limited to the stepper's abilities. The pitch of the ACME also limits me. It's slow but I rather have function over speed.

  5. Quality of the cut. It affects your kerf width and how much slag you have on the part. With the correct height and voltage setting, you can achieve clean cuts without any cleanup needed.

Middle cuts in the picture are ideal.

rbmgf7:
2. From the work piece? Not sure what you're asking there.

  1. It's a 200 step/rev stepper and the thread is X pitch so I can get a ballpark number how many times I need to tell the stepper to step to get my heights.

I guess I should have asked how you know when you are at the correct height ?

And I'm also not clear if the height has to be controlled dynamically - or is it just set once for each job?

If you know the height you need and the relationship between stepper steps and millimeters moved the software to move the motor is simple.

...R

Robin2:
I guess I should have asked how you know when you are at the correct height ?

And I'm also not clear if the height has to be controlled dynamically - or is it just set once for each job?

If you know the height you need and the relationship between stepper steps and millimeters moved the software to move the motor is simple.

...R

If you have the ACME pitch and know that it takes 200 pulses to revolve one time, then you can calculate the pulses required to get the height. To double check, you can get thickness gauges between the torch tip and work piece to see you you're right.

Yes, the advanced THC (also called "digital THC's") can adjust dynamically. My plasma cutter is capable of outputting a 0-7V analog signal while the cutter is cutting. If the work piece is uneven or starts to bend due to warping, the analog value will fluctuate and the program can adjust accordingly to the desired range (to be determined by actually cutting and evaluating the work). However, I would just like a simple approach, first: just locate the work piece and go to a pierce height then cut height.

The premise is I can throw in different thickness materials without having to tell it what thickness it is. Also, you can't be certain that the platform is level to the gantry. As it traverses from one corner to the other, it could be off by millimeters. If you're doing numerous cuts along the work piece, you have the torch re-index to get the right pierce and cut height.

If you understand how CNC plasma systems work, what I'm asking is typical. It's just the programming and frugal approach that's making this challenging.

rbmgf7:
If you have the ACME pitch and know that it takes 200 pulses to revolve one time, then you can calculate the pulses required to get the height. To double check, you can get thickness gauges between the torch tip and work piece to see you you're right.

If you know that, then I don't understand what sort of advice you are looking for.

Are you just wondering how to use an Arduino to send pulses to a stepper motor? If so, look at the simple code in this demo.

What stepper motor driver are you using - post a link to the datasheet.

...R

Robin2:
If you know that, then I don't understand what sort of advice you are looking for.

Are you just wondering how to use an Arduino to send pulses to a stepper motor? If so, look at the simple code in this demo.

What stepper motor driver are you using - post a link to the datasheet.

...R

Refer to the paragraphs after my code in my original post.

forget using mach.

use the voltage as the input for the torch height.

forget the leadscrew unless you have a 4tpi thread.

you do need a pierce routine. then, once your voltage settles, thn march moves the table.

control the thc directly with pid on voltage.

use a pot for the setting.you already know the kerf you are looking for.

The furthest I can get is if there isn't a signal from the Mach3 (ready_THC == LOW), go to home_pos. When I push the z_high_ls as if the Z-axis has reached the top, the stepper does stop but continues if I let go (makes sense to me so far). However, when I set the ready_THC, I don't get a response. The stepper continues to turn.

Is this the piece you mean ?

I read a lot of Threads - it is difficult to keep stuff in my head.

   while (s_ready_thc != LOW); //If the THC has received a signal from Mach3, start the cut process
    {
        zero_workpiece();
    }

There does not seem to be any end to this WHILE loop - and it will repeat VERY frequently

200 microsecs seems very short for a stepper pulse. Have you checked that your motor can run that fast without acceleration? Are you using microsteps?

You have digitalRead()s all over the place. I think it would be much easier to see the logic if you just read all the pins in one function and use those values for the remainder of the iteration of loop(). loop() will repeat very quickly (and thus update the values) if the rest of the code is designed properly.

It would be a great help to me (and probably to you) if you would provide an extended explanation of the piece I havd quoted at the top of this Post. Ideally write down the logic step by step with each step on a separate line.

...R

I think what hes getting at is that the torch needs to drop down and hit the material what set the Z Zero then the torch needs to come back up then move back down to the hight that will cut trough the material as there is a spark coming from the cutter to the material.

its the spark gap between the cutter and material that sets the hight of the cutters what will be a certain voltage.

so what needs to happen is the cut drops connects to the material what zeros the Z once that happens the cutter moves up a set amount then drops back down to a cutting hight what will be a gap that has a voltage that stays the same at all times so if the voltage goes up or down then the material is changing heights so if the voltage increases the cutter needs to go up if it reduces the cutter needs to go down.

when the cutter goes back down to cutting hight the arduino will need to send a signal to start motion what can be set in mach3 to a dell time so if it takes 3 seconds from starting to move down to cut hight the machine will start moving at the correct time.

it will just need a verable added for changeing the hight according to the voltage what gets sent back to the arduino

its a electronic floating cutting head

also there is a lot of posts on cnczone and mach3 about this

do it like what dave-in-nj says to do it.

just use the arduino to control the stepper and hight control and get it to send a go signal to mach

it pretty much the same as a laser controller when at set hight and position go

Hello
you can give me the diagram of Torch Height Controller ? .....
and , if i can control stapper motor with PID from voltage of plasma.....

Hi, excuse me, let me invade your space to ask you if you got the THC scheme for plasma cutting, in the forum you asked about making the electronic diagram available, I would like to get it too, please if you have it, could you To pass a copy? I would thank you very much. Email: richard.falcos@gmail.com

once you get going replace digital read/write with direct port access/control

completely forget any delay, you either need to use a non blocking time delay, or better yet an interrupt to fire the step pin, that will leave you with time to read voltages etc.

steppers are sensitive to changes in their pulse periods. if you are not using an acceleration profile of some sort, you might want to start with a minimum period of 1ms and work from there.

you might want to use a lesser period when the plasma is running as you will only want small height changes