Hi,
I am trying to make a torch height controller for my plasma cnc. I am measuring the plasma arc voltage through a 50:1 voltage divider I have installed in my plasma cutter. I used divider from this site: https://tamarisktechnicals.com/pages/CheapTHC.html
My divider uses a 100k and 2k resistor, and 2.2mH inductors on the output wires.
When I read arc voltage with my multimeter I get a steady reading of 2.06v on flat metal. With the values of my resistors, this would be around 103.9 volts in reality, which is very close to my plasma cutters spec for arc voltage of 102 volts. So I am happy the divider is working properly.
On my Arduino torch height controller I have an uno reading voltage from divider on A0 pin. I have a 5.1 Zener between A0 and ground incase of voltage spikes. I have a Microchip MCP1541 as an external voltage ref connected to vref pin, with 0.1uf cap on input and 1uf cap on output of MCP1541.
The controller switches three changeover relays when arc voltage is between a certain range, and takes control of Enable, STEP and dir pins of my z axis DRV8825 driver. The controller will then raise and lower z axis according to a set voltage.
This all works on the bench with a variable voltage supply simulating arc voltage. Problem is when I connect it all upto my cnc and plasma cutter. The voltage is wildly jumping all over the place, but I still get a steady reading from my multimeter.
I thought it had something to do with my torch height controller being connected to the same 12v supply as the cnc controller, so I connected it to an external battery. This helped a bit, but it is still not usable. I added a small delay in the code to try and get it to slow down, but it acts as though the delay is not there. Plus the operation of a few buttons I added to adjust set voltage, works, but it goes really fast as if there is no delay, so its hard to tell if it has been set if you know what I mean. Again on the bench it all runs smoothly.
Here is my code. I know it is probably not the best:
#include <TM1637Display.h>
#include <EEPROM.h>
const int CLK = 2; //Set the CLK pin connection to the display
const int DIO = 3; //Set the DIO pin connection to the display
TM1637Display display(CLK, DIO); //set up the 4-Digit Display.
float input_voltage = 0.0;
float temp = 0.0;
float r1 = 99900.0;
float r2 = 1980.0;
float setVoltage = 102.0;
int eeAddress = 0;
int Enable = 7;
int STEP = 8;
int dir = 9;
int relay1 = 4;
int relay2 = 5;
int relay3 = 6;
int mainSwitch = 13;
int Up = 10;
int Down = 11;
bool startDelay = false;
void setup() {
Serial.begin(9600);
display.setBrightness(0x0a); //set the diplay to maximum brightness
analogReference(EXTERNAL); // use AREF for reference voltage
pinMode(mainSwitch, INPUT);
pinMode(Up, INPUT);
pinMode(Down, INPUT);
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(Enable, OUTPUT);
pinMode(STEP, OUTPUT);
pinMode(dir, OUTPUT);
digitalWrite(Enable, HIGH);
digitalWrite(STEP, LOW);
digitalWrite(dir, LOW);
EEPROM.get(eeAddress, setVoltage);
}
void loop() {
int analog_value = analogRead(A0);
delay(2);
temp = (analog_value * 4.06) / 1024.0;
input_voltage = temp / (r2/(r1+r2));
Serial.print("v= ");
Serial.println(input_voltage);
display.showNumberDec(input_voltage);
if(digitalRead(Up) == LOW){
setVoltage++;
EEPROM.put(eeAddress, setVoltage);
display.showNumberDec(setVoltage);
delay(1000);
}
if(digitalRead(Down) == LOW){
setVoltage--;
EEPROM.put(eeAddress, setVoltage);
display.showNumberDec(setVoltage);
delay(1000);
}
if(digitalRead(mainSwitch) == LOW){
if(input_voltage >= 90 && input_voltage <=120){
Serial.println("ARC OK");
if(startDelay == false){
delay(1500);
startDelay = true;
}
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(Enable, LOW);
if(input_voltage <= setVoltage - 1){
digitalWrite(dir, HIGH);
Serial.println("Up");
for(int i=0;i<200;i++){
digitalWrite(STEP, HIGH);
delayMicroseconds(100);
digitalWrite(STEP, LOW);
delayMicroseconds(100);
}
}
else if(input_voltage >= setVoltage + 1){
digitalWrite(dir, LOW);
Serial.println("Down");
for(int i=0;i<200;i++){
digitalWrite(STEP, HIGH);
delayMicroseconds(100);
digitalWrite(STEP, LOW);
delayMicroseconds(100);
}
}
}
else{
Serial.println("Arc bad");
digitalWrite(Enable, HIGH);
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
startDelay = false;
}
}
else{
digitalWrite(relay1, LOW);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
startDelay = false;
}
delay(100);
}
Can anyone give me any pointers? I think this will work if only I could stabilise the voltage readings.
Thanks.