Here is the Arduino code, its a WIP but its good enough to use at this point.
This code takes 8 values into memory and uses the average of them to calculate the voltage. This is based off 7 volt max out of plasma cutter which goes though a 2000/5000 voltage divider for a max of 5v. The math in the "realVoltage" line takes the 1-1023, converts it back to input voltage, then to the plasma cutter output voltage then finally the arc voltage. The 5000 and 7000 need to be adjusted based on your voltage divider.Code:double values[8]; boolean firstRun=true; double tip=0; double realVoltage=0; int j=0; int led12 = 8; int led13 = 9; void setup(){ Serial.begin(9800); Serial.println("Serial Started w00t"); pinMode(led12, OUTPUT); pinMode(led13, OUTPUT); } void loop(){ tip=analogRead(0); if(tip>80){ // Serial.print("Incoming Voltage is "); // Serial.println(analogRead(0)); if(firstRun){ for(int i=0;i<8;i++){ values[i]=tip; } firstRun=false; } values[j]=tip; tip=0; for(int i=0;i<8;i++){ tip+=values[i]; } tip/=8; realVoltage = ((((tip*(5.0/1023.0))*7000)/5000)*50); //Serial.print("Real voltage: "); Serial.println(realVoltage); if(realVoltage >= 118.5){ digitalWrite(led12, LOW); digitalWrite(led13, HIGH); } else if(realVoltage <= 115.5){ digitalWrite(led12, HIGH); digitalWrite(led13, LOW); } else if(realVoltage <= 118.5 && realVoltage >= 115.5){ digitalWrite(led12, LOW); digitalWrite(led13, LOW); } j++; if(j>=8){ j=0; } } else { digitalWrite(led12, LOW); digitalWrite(led13, LOW); } }
The led pins are names I was using when I was testing the outputs with just leds, change them if you like but they work. Led12 is torch-up, 13 is torch-down. These are high activated inputs, im using a C10 breakout board and have the inputs PULLED LOW on that board. The Arduino is currently powered by my computer and the C10 and Arduino share a ground for the inputs to work. Input is to analog input 0. The serial information can be removed, it was used for testing and I am still using it to verify voltages.
The input to the Arduino is filtered based on my earlier testing. I am using 1660k worth of resistor and a 1uF capacitor. The wiring is as follow...
The filter was based off some "extensive" testing...below is just two of the graphs I made using different filters and number of values in average.Code:Voltage Divider Output -> 1660k resistors -> One leg of Capacitor -> Same leg of Capacitor -> Arduino Analog Input Other leg of Capacitor -> Arduino Ground
The first one compares the unfiltered input to an input filtered with 1k resistor and 1uF cap, both of these use 15 values for the average.
http://sphotos-b.xx.fbcdn.net/hphoto...17269642_o.jpg
The next is the best I could get with filters, both use 1660 resistors and 1uF caps, the red is storing 8 values, the other 7. I believe the voltage offset and erratic behavior at the end of the red one is due to consumables wearing out. I did quite a bit of testing and torch firing today.
http://sphotos-b.xx.fbcdn.net/hphoto...70837243_o.jpg
Not sure why I cant direct post images anymore but I have uploaded them to the thread also.
I will post my HAL file, INI file, and the comp file once I get a chance to get them all together and post exactly what needs done.