Spot Welder

I am new to the Arduino thingy. Once i checked out a few projects, really impressed with the product. Always thought when it comes to micro-controllers i thought the programming part was all machine language and was not something for an average person. I understand the whole programming part and curious learn to even more. those said so, please bear with me.

So i wanted to do a sketch to control the pulse of a Spot welder via a SSR that i had made from parts from a microwave over. here is what i plan to do

  • Add a tactile switch to start the below
  • first pulse that would last 10milliseconds
  • Second pulse that would last 15milliseconds
  • Stop

So below is what i think it should be, can't try the same out as am waiting for my arduino to be delivered.

int Relay = 10;

void setup() {
  pinMode (Relay, OUTPUT);
  
}

void loop() {
  digitalWrite(Relay, HIGH);
  delay(8);
  digitalWrite(Relay, LOW);
  delay(450);
  digitalWrite(Relay, HIGH);
  delay(10);
  digitalWrite(Relay, LOW);
  delay(3000);
}

So latter i wish to add a potentiometer to adjust the delay-off time of the SSR. So here again am guessing the below would accomplish it.

int Relay = 10;
int PreWeld = A0;
int Weld = A1;
int PreDelay = 0;
int WeldDelay = 0;

void setup() {
  pinMode (Relay, OUTPUT);
  digitalWrite(Relay,HIGH);
}

void loop() {
  PreDelay = analogRead(PreWeld);
  WeldDelay = analogRead(Weld);
  digitalWrite(Relay, HIGH);
  delay(PreWeld);
  digitalWrite(Relay, LOW);
  delay(450);
  digitalWrite(Relay, HIGH);
  delay(Weld);
  digitalWrite(Relay, LOW);
  delay(3000);
}

Could somebody please help me here. Latter am hoping to add a display to show the time value of PreWeld and Weld if its not hard to do.

Do you really want such a slow response to your potentiometer?

The way the program is written at the moment there is a delay of 3.5 (or more) seconds between each reading of the pots. Is that acceptable ?

AWOL: Do you really want such a slow response to your potentiometer?

Ahhhh ! i was hoping that delay would be for the SSR to stay on AKA Delay-OFF. So that potentiometer was to adjust that timing. Yes ! these weld happen for very short periods actually in milliseconds. The current during those short periods are 1000Amps.

UKHeliBob: The way the program is written at the moment there is a delay of 3.5 (or more) seconds between each reading of the pots. Is that acceptable ?

So the whole process works like this

First a preweld for 5ms then a pause for 450ms Second Weld(the actual weld) for 10ms

Again all at 1000Amps. These are used to weld Nickel strips on 18650 Cells.

anishkgt: So the whole process works like this

First a preweld for 5ms then a pause for 450ms Second Weld(the actual weld) for 10ms

Again all at 1000Amps. These are used to weld Nickel strips on 18650 Cells.

Well, no. The "whole process" is:

listen for a button press when the button is pressed, do a weld

You are concentrating on the "do a weld" process, but often, much of a sketch is the framework surrounding the core bit that you actually need getting done.

"analogRead" always returns a value from 0-1024. You then have to do a little arithmetic to convert that into an actual number of milliseconds to use. Happily, this is such a common job that the arduino programming environment has a specific function to do it for you.

See https://www.arduino.cc/en/Reference/Map.

Other things you will need to know to make all this happen is:

To read a switch, the pin needs to be "pulled up" or "pulled down". If this isn't done, then when the switch is open the pin will float, and you'll get a random value off it. The usual thing is to pull the switch up, and wire the switch so that when it is closed, it shorts to the chassis (ground). The arduino has internal pullup resistors to do this job - just use pinmode(pin, INPUT_PULLUP); Thus, you do the weld when the pin is LOW.

When using analogRead, the chip compares the voltage on the pin to Vcc and converts that to a 10-bit number (0-1023) . To wire up a pot to an analog pin, hook one side of the pot to 0, the other side to 5v (Vcc is usually 5v), and the center tap to the analog pin.

void setup() {
  pinMode (buttonPin, INPUT_PULLUP);
  pinMode (relayPin, OUTPUT);
}

void loop() {
  if(digitalRead(buttonPin == LOW) {
    do_a_weld();
  }
}

void do_a_weld() {
  // read the potentimeter values
  // convert them to milliseconds
  // go through the weld routine
}

Now, this will just do a weld over and over if the button is held down (and it will start the next weld immediately after a weld is finished). If you want to require that the button be released before a subsequent weld is done, then that's more code. If you want to be able to cancel the weld at any time by releasing the button, that's more code again. If you want to require that the button must be held down for at least half a second, and that there must be a two-second pause where the button has been released after the completion of the last weld … you begin to see what mean about most of a sketch is framework surrounding the important bit you actually need.

So in short there is more to it than it seems. Well i guess i'll have to some more digging into.

In the second example loop() you have:

PreDelay = analogRead(PreWeld); WeldDelay = analogRead(Weld); digitalWrite(Relay, HIGH); ** delay(PreWeld);** digitalWrite(Relay, LOW); delay(450); digitalWrite(Relay, HIGH); delay(Weld);

See that you should delay(PreDelay) - the value you read as analog input not delay(PreWeld) . that is a constant input pin number. The same applies for WeldDelay / Weld:

PreDelay = analogRead(PreWeld); WeldDelay = analogRead(Weld); digitalWrite(Relay, HIGH); delay(PreDelay); digitalWrite(Relay, LOW); delay(450); digitalWrite(Relay, HIGH); delay(WeldDelay);

Also if you use a microwave oven transformer, its output is 50/60Hz AC frequency, with a period of 16.7-20ms.

A 5ms preweld pulse gives unpredictable results since it's much shorter than the AC wave period.

I think for such a simple welder a single adjustable 100-2000ms pulse should do.

Thanks blimp. will have to slowly learn the stuff and complete it with trial and error. First i need to get my hands on the arduino.

Could somebody direct to a tutorial that i could maybe go through that is relate to my query here, that way i could learn the stuff.

PaulMurrayCbr: Well, no. The "whole process" is:

listen for a button press when the button is pressed, do a weld.........

I get what you say. So i will just start off with just without the pot for now and learn through trial and error. So if i were to use my first code it would just loop continuously. welding and pausing........So here is what i learned so far (Please ignore the pins used, just randomly chose one as i do not have the Arduino yet.) The button part of the code was something that i borrowed from the button example within Arduino. I hear understand that is not the ideal way to code a switch and there is something like a debounce that should be used to get the accurate state of a button. for learning from error, that is how i understand most of what i do. :)

const int Relay = 2;
const int BtnPin = 3;

int BtnState = 0;

void setup() {
  pinMode (Relay, OUTPUT);
  pinMode (BtnPin, INPUT);
  digitalWrite(Relay,HIGH);
}

void loop() {
 if (BtnState == HIGH)
    {
  digitalWrite(Relay, HIGH); // Preweld for 5ms
  delay(5);
  digitalWrite(Relay, LOW); // Pause before weld at 450ms
  delay(450);
  digitalWrite(Relay, HIGH); // Weld for 13ms
  delay(13);
    } 
      else 
    {
      digitalWrite(Relay, LOW);
    }
}

Hi anishkgt ,

Did you ever manage to get the tab welder going ? I am trying to build one and was wondering if the code was usable ?

Thanks

not really. in the process.