Figure I try this here sine the Arduino section isn't getting much attention.

Trying to create a simple THC using an Arduino. I've seen the one program that's out there but it's definitely "out there".

Here's my setup:





Here's the code:

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();
}
}
If there isn't a signal to start the cut, then the program will jog the z axis to the top until there is a signal to start cutting. However, I can get it to jog to the top, stop when the contact switch is closed but I can't get it to exit out if I set the signal to start cut.

I want to keep it simple at first then expand into the digital phase using the voltage readout.

I have a Powermax 45 so I can use the start cut and arc OK signals between the Arduino and my Mach3 breakout board.

I'm still relatively new to Ardunios. This is my first leap beyond the example sketches.