How to steady voltage measurement.

Seedler:
You've lost me there :slight_smile:

Well, you write -V which could imply a negative voltage; such as a +5V and a -5V. If a -5V was applied to a Arduino as ground reference and some voltage above 0V, say a +1V, was applied as an analog input that would exceed the safe operating range of the Arduino Analog input (5 Volt unit) pin. So, I reasoned that you'd not supply a -V to the Arduino to use as a Common Voltage Reference or 0 Volts and, therefor, you, should, mean Circuit Common from the machine.

+5V
0V
-5V

0V and -V are different things and to supply a negative voltage (-V) to an Adruino5 Volt unit as a common reference, is a different conversation.

TomGeorge:
Hi,
Thanks for the pics, but can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom.... :slight_smile:

Sorry about the mess, but I think that's it all

Between plasma cutter and Arduino is a few metres of wire

Seedler, DMM are usually averaging voltage. The output of plasma cutter is anything but steady DC voltage.

If you do need some sort of RMS DC value then you need to take averages as suggested before or create a filter system that will allow a smooth reading. I don't quite understand what you need exactly.

Your plasma arc voltage is different based on thickness, strike and the mode it's in. What you're experiencing is likely in the strike mode where it needs to establish an arc.

if you rectified the reading and steadied it with caps you could get a version of average voltage out... Doe that help?

Hi,
Ops cicuit;

What do you mean by, "Clamp Coil" and "Torch Coil"?

How have you got the potential divider connected to the torch and clamp?

Thanks.. Tom... :slight_smile:

wolframore:
Seedler, DMM are usually averaging voltage. The output of plasma cutter is anything but steady DC voltage.

If you do need some sort of RMS DC value then you need to take averages as suggested before or create a filter system that will allow a smooth reading. I don't quite understand what you need exactly.

Your plasma arc voltage is different based on thickness, strike and the mode it's in. What you're experiencing is likely in the strike mode where it needs to establish an arc.

if you rectified the reading and steadied it with caps you could get a version of average voltage out... Doe that help?

Thing is, the voltage is all over the place before I even switch plasma cutter on. I will definitely employ some sort of running average to code. Can you recommend a filter setup?

TomGeorge:
What do you mean by, "Clamp Coil" and "Torch Coil"?

How have you got the potential divider connected to the torch and clamp?

Thanks.. Tom... :slight_smile:

Look at the pictures I attached earlier. I should have said transformers. The divider is connected before the high frequency circuitry.

This site explains it:
https://tamarisktechnicals.com/pages/CheapTHC.html

Ok I added a smoothing sketch to my code, and an RC low pass filter between my divider and analog pin.

Code:

#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.

const int numReadings = 10;
int analog_value[numReadings];  // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

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);

  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    analog_value[thisReading] = 0;
  }
  
  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() {
  // subtract the last reading:
  total = total - analog_value[readIndex];
  // read from the sensor:
  analog_value[readIndex] = analogRead(A0);
  delay(10);
  // add the reading to the total:
  total = total + analog_value[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }
  // calculate the average:
  average = total / numReadings;
  
  temp = (average * 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;
  }
}

I now seem to be getting a steady reading in the range I was expecting. I believe this was mainly as a result of the low pass filter.

The program seems to crash if I take more than 10 samples of the smoothing code. Any ideas? Plus it takes a second or two for the voltage to ramp up from zero to 102v with the smoothing code. Any way to make this happen faster?

z axis is going the wrong direction. That will be easily fixed :). May have to speed its movement up too.

The biggest problem I've seen though is that every other attempt the Arduino cnc controller crashes at plasma startup. I know this is a concern with plasma cutters, but it has never crashed on me before while cutting. Even with the long wire run from my plasma divider to thc controller, it worked fine and never crashed. The only difference now is the low pass filter. What issues would it cause?

Despite these problems, it was operating the z axis and trying to steady its height. I believe this will work if I can iron these faults out.

Thanks.

delay(1500);

Think about what is happening here. You seem to have this delay so that the arc can settle for 1.5 seconds before beginning to control it. But your 10 measurements are now 1.5 seconds old. You then move the stepper based on that old average.

You need to keep looping. If there is a condition of "arc good" then also record the time at which that first became true. Some time after that you may set a new condition of "control active" or whatever. But keep loop() going and keep taking regular measurements for the averager.

MorganS:
Think about what is happening here. You seem to have this delay so that the arc can settle for 1.5 seconds before beginning to control it. But your 10 measurements are now 1.5 seconds old. You then move the stepper based on that old average.

You need to keep looping. If there is a condition of "arc good" then also record the time at which that first became true. Some time after that you may set a new condition of "control active" or whatever. But keep loop() going and keep taking regular measurements for the averager.

This delay only happens once through the loop at start of cut. Yes it is to allow arc to settle, and to allow cnc controller to make final moves. I don't think it will have much of an impact on the average voltage, or explain the slow ramp up of the voltage. I could be wrong though :). sup[pose a delay using Millis could be used.

I've had a similar problem making measurements in an engine compartment (for data acquisition). This was especially true for thermocouple measurements.

I tried (as a test) taking a large group of readings as fast as out A/D converter would go and averaging them. Poor results.

I then switched to a delta-sigma type A/D and that did the trick. It seems the long integrations time of the delta-sigma (about 12.5 ms) was enough to "average out the noise". It didn't matter for me but for you the delay might be shorter than current average ckt.

There are a number of external boards on eBay for use with the Arduino that use this type of converter.

Hope this helps.

Seedler said he had an RC filter. (That would be the first place I would look for the "second or two" problem.)

I understand the need to let the arc settle. But you are using the measurement from before it settled, 1.5 seconds late. Worse, you continue using it because of the low pass filter.

That is the beauty of Delta-Sigma conversion, you can remove the RC or possibly leave it but with a very high cutoff frequency to attenuate any RF.

The Delta-Sigma converter actually integrates the signal over the full sample time (in this case 125 ms). By doing so any noise is "integrated out"**

If you use this board ADS1115 A/D at the slowest sample rate of 8 samples per second, you will get an average over 125 ms with a delay of 125 ms.

I have found them to be far superior to the higher speed A/D conversions except of course where high sample speed is required for some reason.

** Not a technically correct term but descriptive.