Dynamic control of the cutting height of a CNC plasma torch ,aka THC

With decades of electrical experience and miliseconds of programming experience I am looking to use a LEONARDO to control the cutting height of a plasma torch as the torch moves when cutting a steel plate. I am looking for help to get started programming.

Existing hardware:
Plasma cutting torch that is moved in X, Y, Z directions controlled by MACH3 software and XP Windows computer. The plasma torch is mounted on a mechanical gantry CNC plate cutting table that is used to cut plate steel. The system currently functions with manual setting of the Z position. The Z axis motor is current used to manually adjust the height of the cutting torch for best cutting results using keyboard up down keys. The Z axis has two remote inputs ( up and down) control capability that is currently not connected.

Existing control input signals for LEONARDO input:

Control input 1 - Digital output from the system to activate the automatic up and down control of the Z axis by Arduino.

Control input 2 - 0 to 5 volt DC analogue signal developed by the plasma torch as measured from ground(0 volts) to plasma torch tip. The source voltage is about 100 VDC that is divided by resistor network to reduce the voltage to a usable 0 to 5 v.

Objective:

When the plasma torch cuts on an uneven steel surface or the plate that is being cut is not level the torch to cutting surface distance will vary that causes poor cutting quality or a collision with the steel that is being cut.

As the distance of the torch from the steel that is being cut increases the voltage between the steel and the torch will increase as the plasma will transit a greater air gap, and the voltage will decrease as this distance or air gap decreases. The optimum distance to work is about 1mm to 2 mm depending on the type and thickness of steel being cut. When the torch in not cutting the input voltage will be 0 volts and when the torch is operating and cutting at a great distance from the steel say about 5mm the voltage input will be about 4.5V.

The objective is:
When control input 1 is high/on; provide a digital "UP" output signal when the analogue input 2 voltage is below 2.4 volts to raise the torch (Z axis up) until the input 2 voltage is greater than 2.4 volts.

When control input 1 is high/on; provide a digital "DOWN" output signal when the analogue input 2 voltage is greater than 2.6 volts to lower the torch (Z axis down) until the input 2 voltage is less than 2.6 volts.

Other related
I will test and record analogue input voltage fluctuations when cutting steel under optimal cutting conditions based on a manual torch height setup when cutting a perfectly flat and level steel sample to get base line analogue input voltage for refernce. The analogue input values stated above in objective are currently somewhat arbitrary as I am not sure exactly what I will find when I test for base line input voltage and expect to adjust those values in the Arduino sketch accordingly. I will also install a poteniometer (variable resistor) on the analogue input to manually bias the torch position up or down to suit fine adjustments for cutting different types and thickness of steel.

The operation of the above plasma CNC machine without Torch Height Control can be seen at the following link:

Any help writing the Arduino sketch or referral to a similar design would be appreciated.

I use a Powermax 45 and have voltage and height control on my table.

I am curious, What kine of Plasma machine you are using

EVERLAST 80S

Is there a particular reason why you have chosen a Leonardo? (Just curious).

IIRC there was another extensive Thread about this subject in the last year or so. It might be worth Googling to find it.

That's about the extent of my knowledge of the subject :slight_smile:

...R

It appears that the Leonardo has more than enough I/O and is small and cheap and was in stock a 10 minute drive away. I got it to flash the on-board LED with the example sketch "BLINK" and I modified the blink on off rate. I was about to design/build a discrete solid state component control system when it occurred to me to check out micro controls and it would't hurt me to learn programming in C/C++.

DDyode:
It appears that the Leonardo has more than enough I/O and is small and cheap and was in stock a 10 minute drive away.

Perfectly good reason.

Just be aware that it uses a different mechanism for communication with the PC compared to an Uno and that can sometimes cause a problem uploading a program. Sometimes I get an error but it usually works the second time I try without changing anything.

...R

Are you trying to simulate a keypress here? Or do you want a digital up or down signal to persist while you're outside the desired range?

If the latter, try this:

const byte ArcVoltagePin=A2;
const byte UpPin=2;
const byte DownPin=3;
const byte BoardVoltage=5;
const int LowLimit=2.4/BoardVoltage*1024;
const int HighLimit=2.6/BoardVoltage*1024;

void setup() 
{
Serial.begin(115200);
Serial.println ("Arc controller");
Serial.print("Low limit: ");
Serial.println(LowLimit);
Serial.print("High limit: ");
Serial.println(HighLimit);
pinMode(UpPin,OUTPUT);
pinMode(DownPin,OUTPUT);
}

void loop() 
{
int ArcVoltage=analogRead(ArcVoltagePin);
if(ArcVoltage<LowLimit)
  {
  digitalWrite(UpPin,HIGH);
  }
else  
  {
  digitalWrite(UpPin,LOW);
  }
if(ArcVoltage>HighLimit)
  {
  digitalWrite(DownPin,HIGH);
  }
else
  {
  digitalWrite(DownPin,LOW);
  }
}

I'm wondering whether there's a need for some kind of delay to let the system move the head.

wildbill:
Are you trying to simulate a keypress here? Or do you want a digital up or down signal to persist while you're outside the desired range?

If the latter, try this:

I'm wondering whether there's a need for some kind of delay to let the system move the head.

Thank you so much wildbill

Ya, I'm wanting want a digital up or down signal to persist while I'm outside the desired range?

Just fyi there are 3 sources intended for up down Z axis motion, the keyboard UP/DOWN keys for manual control and setup, the computer software(MACH3) will instruct Z axis UP/DOWN when moving X,Y between cuts on a large sheet of steel that may not be perfectly flat(Arduimo height sensing is off then) and dynamic "Arduino" height sensing system with hardwired inputs into the computer parallel port.

RE -'I'm wondering whether there's a need for some kind of delay" - You are either a mind reader or you've had some exposure or experience with plasma torch height controls before. Yes delay of movement is a topic that I didn't want to complicate may first post on this subject with.

Three options for delay of movement are:

Design a simple RC network with adjustable values (rotary switch to select different capacitor and resistor time constants) allows easy UP/DN adjustment even while cutting.

Program the Arduino to respond to two more analogue inputs from potentiometers that could provide separate UP and DOWN delay of Z axis movement.

Do nothing and see how it goes, cuz most discussion on antidive (delayed movement) of Z axis is centered around cutting through an existing cut, not sure I would create a Gcode to cut a part that would do that, but never say never.

But for now I'm gonna just get the height thingy to work.

Again wildbill Thank you so much for getting me started, I've avoided learning coding for a long time much to my disadvantage.

BR
Ddyod

1 Like

The code below for THC with additional features added to the code wildbill kindly provided works fine with one exception, as a result of the additional features. The OUTPUT PINS#2 UP and PIN#3 DOWN stay latched HIGH (in their last state) after either INPUT PINS#6 or #4 or both go low after performing an up down function.

The intent is to adjust the height of the torch with output pins 2 and 3 (up/down)when digital input pins 6 and 4 are HIGH and the analogue input voltage on pin A2 is between a safe level of 2.3 and 2.7 volts (the dead band is 2.4 to 2.6 volts, no height adjustment required). When testing on a Leonardo board it all works but if the down pin #3 is high when input pins 6 and 4 go LOW (at end of cut) PIN #3 stays HIGH until I push the reset button (or remove the power)and then everything resets to LOW as it should. I can't manually reset this when the machine comes to the end of a cut and I don't want the Z axis height to be adjusted when it's not cutting as there is no reference voltage for the A2 input to read.

This Leonardo board was tested using leds on the outputs and a 20 k Potentiometer connected to the boards 5V/gnd to create the 2.3 to 2.7 reference voltage. Inputs pins 4 and 6 are wired to board ground through 33k resistors to damp magnetic noise, the 4 leds draw 20ma each.

Any suggestions on how to get output PIN 2 and 3 to go low per above would be appreciated.

BR
Ddyode

const byte ArcVoltagePin=A2; //in
const byte UpPin=2; //out
const byte DownPin=3; //out
const byte PlasmaRunningPin=4; //in
const byte StartPlasmaOutPin=5; //out
const byte StartPlasmaInPin=6; //in
const byte ArcOKPin=7; //out

const byte BoardVoltage=5;
const int SafeLowLimit=2.3/BoardVoltage*1024;
const int SafeHighLimit=2.7/BoardVoltage*1024;
const int RunLowLimit=2.4/BoardVoltage*1024;
const int RunHighLimit=2.6/BoardVoltage*1024;
int StartPlasmaIn;
int StartPlasmaOut;
int PlasmaRunning;

void setup() {
  Serial.begin(115200);
  Serial.println ("Arc controller");
  pinMode(UpPin,OUTPUT);
  pinMode(DownPin,OUTPUT);
  pinMode(ArcOKPin,OUTPUT);
  pinMode(StartPlasmaOutPin,OUTPUT);
}


void loop() {

// Waiting for command from Mach to turn on plasma, and then telling plasma to start, and wait for Arc-OK from plasma 

while(1) {

  StartPlasmaIn = digitalRead(StartPlasmaInPin);
  if(StartPlasmaIn == HIGH) {
    digitalWrite(StartPlasmaOutPin,HIGH);
    PlasmaRunning = digitalRead(PlasmaRunningPin);
    if(PlasmaRunning == HIGH) { 
      break;
    } 
  } else {
    digitalWrite(StartPlasmaOutPin,LOW);
  }
}


// verify plasma is running, set hight to be between running limits, and then tell Mach to start running

while(1) {
  PlasmaRunning = digitalRead(PlasmaRunningPin);
  if(PlasmaRunning == HIGH) {
    int ArcVoltage = analogRead(ArcVoltagePin);
    if(ArcVoltage < RunLowLimit) {
      digitalWrite(UpPin,HIGH);
      } else {
      digitalWrite(UpPin,LOW);
      }
    if(ArcVoltage > RunHighLimit) {
      digitalWrite(DownPin,HIGH);
      } else {
      digitalWrite(DownPin,LOW);
      }
    if((ArcVoltage >= RunLowLimit) && (ArcVoltage <= RunHighLimit)) {
      digitalWrite(ArcOKPin,HIGH);
      break;
    }
  } else {
    digitalWrite(ArcOKPin,LOW);
    digitalWrite(StartPlasmaOutPin,LOW);
    break;
  }
}



//check that mach says to keep going. If not - shut down everything. If keep going, check plasma is still working, if so, check safety limits. If outside safety, shut down. Otherwise, adjust height if necessary.

while(1) {
  StartPlasmaIn = digitalRead(StartPlasmaInPin);
  if(StartPlasmaIn == HIGH) {
    PlasmaRunning = digitalRead(PlasmaRunningPin);
    if(PlasmaRunning == HIGH) {
      int ArcVoltage = analogRead(ArcVoltagePin);
      if((ArcVoltage > SafeHighLimit) || (ArcVoltage < SafeLowLimit)) {
        digitalWrite(ArcOKPin,LOW);
        digitalWrite(StartPlasmaOutPin,LOW);
        break;
      }
      if(ArcVoltage < RunLowLimit) {
        digitalWrite(UpPin,HIGH);
        } else {
        digitalWrite(UpPin,LOW);
        }
      if(ArcVoltage > RunHighLimit) {
        digitalWrite(DownPin,HIGH);
        } else {
        digitalWrite(DownPin,LOW);
        }
      } else {
        digitalWrite(ArcOKPin,LOW);
        digitalWrite(StartPlasmaOutPin,LOW);
        break;        
      }
  } else {
    digitalWrite(ArcOKPin,LOW);
    digitalWrite(StartPlasmaOutPin,LOW);
    break;
    }
}

}
const byte ArcVoltagePin = A2; //in
const byte UpPin = 2; //out
const byte DownPin = 3; //out
const byte PlasmaRunningPin = 4; //in
const byte StartPlasmaOutPin = 5; //out
const byte StartPlasmaInPin = 6; //in
const byte ArcOKPin = 7; //out

const byte BoardVoltage = 5;
const int SafeLowLimit = 2.3 / BoardVoltage * 1024;
const int SafeHighLimit = 2.7 / BoardVoltage * 1024;
const int RunLowLimit = 2.4 / BoardVoltage * 1024;
const int RunHighLimit = 2.6 / BoardVoltage * 1024;
int StartPlasmaIn;
int StartPlasmaOut;
int PlasmaRunning;

void setup()
{
  Serial.begin(115200);
  Serial.println ("Arc controller");
  pinMode(UpPin, OUTPUT);
  pinMode(DownPin, OUTPUT);
  pinMode(ArcOKPin, OUTPUT);
  pinMode(StartPlasmaOutPin, OUTPUT);
}

void ManageArc( int ArcVoltage)
{
  if (ArcVoltage < RunLowLimit)
  {
    digitalWrite(UpPin, HIGH);
  }
  else
  {
    digitalWrite(UpPin, LOW);
  }
  if (ArcVoltage > RunHighLimit)
  {
    digitalWrite(DownPin, HIGH);
  }
  else
  {
    digitalWrite(DownPin, LOW);
  }
}

void Stop()
{
  digitalWrite(StartPlasmaOutPin, LOW);
  digitalWrite(ArcOKPin, LOW);
  digitalWrite(UpPin, LOW);
  digitalWrite(DownPin, LOW);
}

void loop()
{
  // Waiting for command from Mach to turn on plasma, and then telling plasma to start, and wait for Arc-OK from plasma

  while (1)
  {
    StartPlasmaIn = digitalRead(StartPlasmaInPin);
    if (StartPlasmaIn == HIGH)
    {
      digitalWrite(StartPlasmaOutPin, HIGH);
      PlasmaRunning = digitalRead(PlasmaRunningPin);
      if (PlasmaRunning == HIGH)
      {
        break;
      }
    }
    else
    {
      Stop();
    }
  }


  // verify plasma is running, set height to be between running limits, and then tell Mach to start running

  while (1)
  {
    PlasmaRunning = digitalRead(PlasmaRunningPin);
    if (PlasmaRunning == HIGH)
    {
      int ArcVoltage = analogRead(ArcVoltagePin);
      ManageArc(ArcVoltage);
      if ((ArcVoltage >= RunLowLimit) && (ArcVoltage <= RunHighLimit))
      {
        digitalWrite(ArcOKPin, HIGH);
        break;
      }
    }
    else
    {
      Stop();
      break;
    }
  }

  //check that mach says to keep going. If not - shut down everything. If keep going, check plasma is still working, if so, check safety limits. If outside safety, shut down. Otherwise, adjust height if necessary.

  while (1)
  {
    StartPlasmaIn = digitalRead(StartPlasmaInPin);
    if (StartPlasmaIn == HIGH)
    {
      PlasmaRunning = digitalRead(PlasmaRunningPin);
      if (PlasmaRunning == HIGH)
      {
        int ArcVoltage = analogRead(ArcVoltagePin);
        if ((ArcVoltage > SafeHighLimit) || (ArcVoltage < SafeLowLimit))
        {
          Stop();
          break;
        }
        ManageArc(ArcVoltage);
      }
      else
      {
        Stop();
        break;
      }
    }
    else
    {
      Stop();
      break;
    }
  }
}

Many Thanks wildbill I'll test this today!
BR
Ddyod

Thanks again wildbill,

I've tested the code/board with every input permutation, works fine! I will try to understand the code revision you made and put that in my knowledge basket.

Although the test I've done is on the bench and I haven't tested on my CNC plasma machine I anticipate with no special component interconnections the system will work as intended.

For those wishing to use this for other CNC Plasma cutting THC the following is the basic system component minimum requirements used in this design.

-Plasma cutting power supply with remote start input and ARC OK output and torch voltage divider to produce about 2.5 volt at desired cutting height. A Potentiometer should be installed on the approx 2.5v torch voltage to fine adjust the height when required for different metals/thicknesses

  • CNC Table with X,Y,Z axis.

-Computer/Software with THC (eg MACH3)

  • Computer with outputs eg (Break Out Board) with Start Plasma output and ARC OK input.

  • Arduino Leonrdo running code copied at end of this message, with run low and high, and safe low and high voltages adjusted to suit the users plasma power supply/electrical noise while cutting.

Thanks again wildbill

BR
Ddyode

const byte ArcVoltagePin = A2; //in
const byte UpPin = 2; //out
const byte DownPin = 3; //out
const byte PlasmaRunningPin = 4; //in
const byte StartPlasmaOutPin = 5; //out
const byte StartPlasmaInPin = 6; //in
const byte ArcOKPin = 7; //out

const byte BoardVoltage = 5;
const int SafeLowLimit = 2.3 / BoardVoltage * 1024;
const int SafeHighLimit = 2.7 / BoardVoltage * 1024;
const int RunLowLimit = 2.4 / BoardVoltage * 1024;
const int RunHighLimit = 2.6 / BoardVoltage * 1024;
int StartPlasmaIn;
int StartPlasmaOut;
int PlasmaRunning;

void setup()
{
Serial.begin(115200);
Serial.println ("Arc controller");
pinMode(UpPin, OUTPUT);
pinMode(DownPin, OUTPUT);
pinMode(ArcOKPin, OUTPUT);
pinMode(StartPlasmaOutPin, OUTPUT);
}

void ManageArc( int ArcVoltage)
{
if (ArcVoltage < RunLowLimit)
{
digitalWrite(UpPin, HIGH);
}
else
{
digitalWrite(UpPin, LOW);
}
if (ArcVoltage > RunHighLimit)
{
digitalWrite(DownPin, HIGH);
}
else
{
digitalWrite(DownPin, LOW);
}
}

void Stop()
{
digitalWrite(StartPlasmaOutPin, LOW);
digitalWrite(ArcOKPin, LOW);
digitalWrite(UpPin, LOW);
digitalWrite(DownPin, LOW);
}

void loop()
{
// Waiting for command from Mach to turn on plasma, and then telling plasma to start, and wait for Arc-OK from plasma

while (1)
{
StartPlasmaIn = digitalRead(StartPlasmaInPin);
if (StartPlasmaIn == HIGH)
{
digitalWrite(StartPlasmaOutPin, HIGH);
PlasmaRunning = digitalRead(PlasmaRunningPin);
if (PlasmaRunning == HIGH)
{
break;
}
}
else
{
Stop();
}
}

// verify plasma is running, set height to be between running limits, and then tell Mach to start running

while (1)
{
PlasmaRunning = digitalRead(PlasmaRunningPin);
if (PlasmaRunning == HIGH)
{
int ArcVoltage = analogRead(ArcVoltagePin);
ManageArc(ArcVoltage);
if ((ArcVoltage >= RunLowLimit) && (ArcVoltage <= RunHighLimit))
{
digitalWrite(ArcOKPin, HIGH);
break;
}
}
else
{
Stop();
break;
}
}

//check that mach says to keep going. If not - shut down everything. If keep going, check plasma is still working, if so, check safety limits. If outside safety, shut down. Otherwise, adjust height if necessary.

while (1)
{
StartPlasmaIn = digitalRead(StartPlasmaInPin);
if (StartPlasmaIn == HIGH)
{
PlasmaRunning = digitalRead(PlasmaRunningPin);
if (PlasmaRunning == HIGH)
{
int ArcVoltage = analogRead(ArcVoltagePin);
if ((ArcVoltage > SafeHighLimit) || (ArcVoltage < SafeLowLimit))
{
Stop();
break;
}
ManageArc(ArcVoltage);
}
else
{
Stop();
break;
}
}
else
{
Stop();
break;
}
}
}

In need of confirmation.

The THC project I am working on requires an interface between an XP windows computer and Arduino Leonardo via printer port and a break out board (BOB). The BOB performs a couple of functions in addition to providing a place to terminate wires and it requires it to be powered by a 12vdc power supply,....as such the inputs on the BOB are normally at 12 vdc until a dry contact is close between input and ground(0 volts), the input switch current is measured at 8.5 ma maximum on the BOB.

Based on Arduino Leonardo data I've read and forum comments I would like the Arduino Leonardo digital I/O outputs to sink the 12 volt inputs on the BOB to interface the Arduino Leonardo outputs to the BOB inputs,...the current measured through a dry contact when switching a single BOB input is 8.5 ma. The total Arduino Leonardo outputs that operate at the same time are; 2 digital outputs set to LOW that will be output sinks at 8.5 ma each, and one digital I/O output set HIGH to operate an opto isolater 4N32 with series resistor to limit the current to 35ma for a total output current from the Arduino of 52 ma. Note the I/O set HIGH will not connect to the BOB, it is the start plasma signal on plasma power supply that needs to be opto isolated.

3 Questions:

Can I power the Arduino Vcc with filtered 12vdc?

Can I sink 12 volt inputs on the BOB with Arduino digital I/O output set LOW.

Can I connect the 0 volt (ground)of Vcc power of the Arduino Leonardo and BOB together? If I do this the voltage present on the BOB inputs will never exceed the Arduino Leonardo power supply (12vdc) if I can common up the 0 volts (grnd) of the Arduino Leonardo and BOB. The BOB and the Arduino power will be common from same source except the BOB will be fed though a diode (11.3 vdc) to insure the input voltage persent on the BOB will never exceed Vcc on the Arduino. The only other connections on the Aduino are two digital inputs connected to external dry relay contacts and a 320 volt analogue voltage divided down/conditioned to 2.4vdc -2.6vdc range vdc that is the subject of much personal consternation and angst and should not be considered in these questions. Note, fyi only: the current design for the analogue input is shown on attached drawing.

Any help re above questions would be much appreciated.

BR
DDyod

I was just searching this very topic and stumbled on your thread. I was thinking about purchasing a pre made THC...

this one actually:

Scared off by the price, I got to thinking if this would be possible using the Arduino stuff I already have (Arduino UNO). Looking at this thread it looks very possible.
I already have a CNC Plasma cutter with an X,Y, & Z axis, running a WinXP PC with Mach 3 software, and equipped with a BOB.

I am a Mechanical Engineer and my coding/programming and even some of my electronics skills are not to the level of many of you guys on here are so please bare with me.
The image you have attached above is of the voltage divider needed to step down the plasma's HV to the 2.4-2.6 Vdc correct? I will need to construct this. I have a Harbor Freight plasma cutter and it does not have the fancy low voltage supply to tap into. I only have the high voltage side to obtain my reading from.

Have you been able to test this out on the actual plasma table yet?

Jonarotz

"The image you have attached above is of the voltage divider needed to step down the plasma's HV to the 2.4-2.6 Vdc correct?"

THAT IS CORRECT..., AND IT PULLS THE VOLTAGE TO A POSITIVE VALUE, ARDUINO CANNOT READ NEGATIVE VALUES. THE TORCH VOLTAGE IS BELOW ZERO (NEGATIVE)

"Have you been able to test this out on the actual plasma table yet?"

YES IT DOES WORK AS DESIGNED VERY WELL - I WOULD SEND A VIDEO OF MACH3 Z AXIS ACTION WHILE MAKING A 5" LONG Y AXIS CUT ON 1/4" STEEL PLATE MOUNTED ON AN ANGLE ON WATER TABLE BUT THE MAX ATTACHMENTS SIZE FOR THIS FORUM IS 1 MEG, THE VIDEO IS 5 MEG.. WORKS GREAT!

ADVICE IN ADVANCE - YOU NEED A REALLY GOOD GROUND SYSTEM FOR: THE METAL YOU CUT, THE BOB, THE ARDUINO, AND THE PLASMA POWER SUPPLY....AND ONLY GROUND AT ONE POINT - "STAR GROUNDING", GOOGLE IT. I WASTED A LOT OF TIME BY NOT DESIGNING A PROPER GROUNDING SYSTEM.

FINAL AS-BUILT PROGRAMMING LISTED BELOW, NOTE "SAFE LIMITS" WERE NOT USED/REQUIRED BUT I LEFT THEM SHOULD I NEED THEM IN THE FUTURE AND I DID NOT RELY ON THE ARDUINO TO SIGNAL "START" PLASMA INPUT NOR DO I ALLOW ADRUINO TO SIGNAL ARC OK TO THE BOB. THE ARDUINO GETS ARC OK AND START SIGNAL TO SIGNAL Z UP/DOWN ONLY. IF YOU DON'T HAVE THESE SIGNALS ON YOUR MACHINE YOU WILL HAVE TO HARDWIRE THESE TWO ARDUINO DIGITAL INPUTS TO 5 VOLTS (HIGH) TO MAKE IT RUN.

const byte ArcVoltagePin = A2; //in
const byte UpPin = 2; //out
const byte DownPin = 3; //out
const byte PlasmaRunningPin = 4; //in
const byte StartPlasmaOutPin = 5; //out
const byte StartPlasmaInPin = 6; //in
const byte ArcOKPin = 7; //out

const byte BoardVoltage = 5;
const int SafeLowLimit = 0.01 / BoardVoltage * 1024;
const int SafeHighLimit = 4.99 / BoardVoltage * 1024;
const int RunLowLimit = 2.49 / BoardVoltage * 1024;
const int RunHighLimit = 2.51 / BoardVoltage * 1024;
int StartPlasmaIn;
int StartPlasmaOut;
int PlasmaRunning;

void setup()
{
  Serial.begin(115200);
  Serial.println ("Arc controller");
  pinMode(UpPin, OUTPUT);
  pinMode(DownPin, OUTPUT);
  pinMode(ArcOKPin, OUTPUT);
  pinMode(StartPlasmaOutPin, OUTPUT);
}

void ManageArc( int ArcVoltage)
{
  if (ArcVoltage < RunLowLimit)
  {
    digitalWrite(DownPin, HIGH);
  }
  else
  {
    digitalWrite(DownPin, LOW);
  }
  if (ArcVoltage > RunHighLimit)
  {
    digitalWrite(UpPin, HIGH);
  }
  else
  {
    digitalWrite(UpPin, LOW);
  }
}

void Stop()
{
  digitalWrite(StartPlasmaOutPin, LOW);
  digitalWrite(ArcOKPin, LOW);
  digitalWrite(UpPin, LOW);
  digitalWrite(DownPin, LOW);
}

void loop()
{
  // Waiting for command from Mach to turn on plasma, and then telling plasma to start, and wait for Arc-OK from plasma

  while (1)
  {
    StartPlasmaIn = digitalRead(StartPlasmaInPin);
    if (StartPlasmaIn == HIGH)
    {
      digitalWrite(StartPlasmaOutPin, HIGH);
      PlasmaRunning = digitalRead(PlasmaRunningPin);
      if (PlasmaRunning == HIGH)
      {
        break;
      }
    }
    else
    {
      Stop();
    }
  }


  // verify plasma is running, set height to be between running limits, and then tell Mach to start running

  while (1)
  {
    PlasmaRunning = digitalRead(PlasmaRunningPin);
    if (PlasmaRunning == HIGH)
    {
      int ArcVoltage = analogRead(ArcVoltagePin);
      ManageArc(ArcVoltage);
      if ((ArcVoltage >= RunLowLimit) && (ArcVoltage <= RunHighLimit))
      {
        digitalWrite(ArcOKPin, HIGH);
        break;
      }
    }
    else
    {
      Stop();
      break;
    }
  }

  //check that mach says to keep going. If not - shut down everything. If keep going, check plasma is still working, if so, check safety limits. If outside safety, shut down. Otherwise, adjust height if necessary.

  while (1)
  {
    StartPlasmaIn = digitalRead(StartPlasmaInPin);
    if (StartPlasmaIn == HIGH)
    {
      PlasmaRunning = digitalRead(PlasmaRunningPin);
      if (PlasmaRunning == HIGH)
      {
        int ArcVoltage = analogRead(ArcVoltagePin);
        if ((ArcVoltage > SafeHighLimit) || (ArcVoltage < SafeLowLimit))
        {
          Stop();
          break;
        }
        ManageArc(ArcVoltage);
      }
      else
      {
        Stop();
        break;
      }
    }
    else
    {
      Stop();
      break;
    }
  }
}

This is great!
Can you email me the video? jonarotz@yahoo.com

Can you provide me any other details on the high voltage divider? What is the value on the zener diodes?

I am going to bench test the code now. Thanks for your help!

I just want to confirm some of the connections with you...

ArcVoltagePin = A2 (0-5vdc signal from HV divider)

Up Pin = 2 (LOW to mach 3, telling torch to lower)

Down Pin = 3 (LOW to mach 3, telling torch to raise)

PlasmaRunningPin = 4 (HIGH in to signal torch is on)

StartPlasmaOutPin = 5 (Ok to leave unhooked)

StartPlasmaInPin = 6 (HIGH in)

ArcOKPin = 7 (Ok to leave unhooked)

Does this sound correct?

1 Like

The zener diodes that I used are 5.1 volt 1N4733

ArcVoltagePin = A2 (0-5vdc signal from HV divider) - YES CORRECT

Up Pin = 2 (LOW to mach 3, telling torch to lower) - YES, WILL DRAG BOB INPUT VOLTAGE LOW TO TELL MACH TO RAISE Z

Down Pin = 3 (LOW to mach 3, telling torch to raise) - YES, WILL DRAG BOB INPUT LOW TO TELL MACH TO LOWER Z

PlasmaRunningPin = 4 (HIGH in to signal torch is on) - YES CORRECT

StartPlasmaOutPin = 5 (Ok to leave unhooked) - YES CORRECT

StartPlasmaInPin = 6 (HIGH in) - YES CORRECT

ArcOKPin = 7 (Ok to leave unhooked) - YES CORRECT

NOTE;

IN MY APPLICATION PINS 2 AND 3 EACH CONNECT TO SEPARATE 1N32 OPTO ISOLATOR ANODES THROUGH 40MA MAX LED ASSEMBLY, THE OPTO OUTPUTS CONNECT TO BOB INPUTS. THE 1N32'S ARE NOT REQUIRED IF BOB INPUT VOLTAGE IS 6 VDC OR LESS. IT'S HANDY TO KNOW WHEN/IF THESE SIGNALS ARE ACTIVE WHEN FIRST TESTING SO LED'S WITH CURRENT LIMITING RESISTORS LINKING ARDUINO OUTPUTS TO 1N32 OPTOS...OR DIRECTLY TO BOB WILL PROVIDE THESE VISUAL SIGNALS, .....BUT ARE NOT REQUIRED TO MAKE IT WORK.

Regards
Ddyod