Adjustable spot welder timer

Good day all.

I am looking for help and guidance with a project of mine, I am still a total newbie to Arduino coding.

I have built a spot welder / battery tab welder, But at this point in time it is manually controlled via a foot pedal switch, and as such it's very hard to get consistent welds.

I am looking at building a Arduino based timer to try and get more consistent welds.
The Arduino will be used to control a relay to turn on and off the spot welder.
The Relay is a Hongmei JQX-78F rated for 16A 250VAC / 16A 30VDC. I will be using it to switch the 230vac mains side, not the high current side of the spot welder. The spot welder pulls 8amps (1840watts) from the mains at 1st arc then drops off so the relay is rated at double what I will be pulling.

The end goal of the project is to be able to set and adjust the weld time via a Rotary encoder, The weld time would never need to exceed 10 seconds.

I am not really quite sure where I should start.

So I am going to need some kind of menu interface to adjust the timer, I have never done menu's before, and don't really even know where to start looking.

I would be very grateful if someone could point me in the right direction or give me some kind of example code to play with.

Below is the code so far:

/*

 */

#include <Wire.h>                                              // Include Standard Wire Library
#include <LiquidCrystal_I2C.h>                                 // Include I2C LCD Library (https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/LiquidCrystal_V1.2.1.zip)

int encoder_A = 2;                                             // Rotary encoder input A Pin
int encoder_B = 3;                                             // Rotary encoder input B Pin
int encoder_SW = 4;                                            // Rotary encoder Switch input Pin
int trigger_SW = 5;                                            // Foot Pedel Switch input Pin
int outputRelay = 9;                                           // Relay output Pin
int outputBuzzer = 10;                                         // Buzzer output Pin
int LCD_I2C_address = 0x20;                                    // LCD I2C Address
int LCD_I2C_en = 2;                                            // LCD I2C Enable Pin
int LCD_I2C_rw = 1;                                            // LCD I2C Read/Write Pin
int LCD_I2C_rs = 0;                                            // LCD I2C Register Select Pin
int LCD_I2C_d4 = 4;                                            // LCD I2C D4 Data Pin
int LCD_I2C_d5 = 5;                                            // LCD I2C D5 Data Pin
int LCD_I2C_d6 = 6;                                            // LCD I2C D6 Data Pin
int LCD_I2C_d7 = 7;                                            // LCD I2C D7 Data Pin
int LCD_I2C_bl = 3;                                            // 
int CountDown = 1500;                                          // Default time in milliseconds

LiquidCrystal_I2C lcd(LCD_I2C_address, LCD_I2C_en, LCD_I2C_rw, LCD_I2C_rs, LCD_I2C_d4, LCD_I2C_d5, LCD_I2C_d6, LCD_I2C_d7, LCD_I2C_bl, POSITIVE); // 

void setup() {                                                 // Put your setup code here, to run once:
pinMode(encoder_A, INPUT);                                     // Set pin as Input
pinMode(encoder_B, INPUT);                                     // Set pin as Input
pinMode(encoder_SW, INPUT);                                    // Set pin as Input
pinMode(trigger_SW, INPUT);                                    // Set pin as Input
pinMode(outputRelay, OUTPUT);                                  // Set pin as Output
digitalWrite(outputRelay, LOW);                                // Set output as Low
pinMode(outputBuzzer, OUTPUT);                                 // Set pin as Output
digitalWrite(outputBuzzer, LOW);                               // Set output as Low

lcd.begin(16,2);                                               // Initialize the lcd
delay(100);                                                    // Delay
lcd.setCursor(2,0);                                            // Start at character 3 on line 0
lcd.print("Spot Welder");                                      // Print text to lcd display
lcd.setCursor(2,1);                                            // Start at character 3 on line 1
lcd.print("Firmware 0.1");                                     // Print text to lcd display
delay(5000);                                                   // Delay
}

void loop() {                                                  // Put your main code here, to run repeatedly:
lcd.setCursor(0,0);                                            // Start at character 1 on line 0
lcd.print("**System Ready**");                                 // Print text to lcd display
lcd.setCursor(0,1);                                            // Start at character 3 on line 1
lcd.print("  Time: 1.000s  ");                                 // Print text to lcd display
delay(2000);                                                   // Delay
lcd.setCursor(0,0);                                            // Start at character 1 on line 0
lcd.print(" Press and Hold ");                                 // Print text to lcd display
lcd.setCursor(0,1);                                            // Start at character 1 on line 1
lcd.print(" Pedal to Start ");                                 // Print text to lcd display
delay(2000);                                                   // Delay
}

Thanks for your time and advice.

If you are new to the Arduino start with much simpler code. Don't bother with the LCD, the encoder or Wire.h

Look at the Blink Without Delay example sketch to see how to measure time intervals using millis().

Write a short sketch that gives you different times (for lighting an LED) for (say) two switches attached to the Arduino. You can use pieces of stiff wire instead of switches just for testing.

How many different timing options do you want between 0 and 10 seconds?

Is it your plan to use the Arduino to switch the welder current on and off, or just to give you an indication so you can manually operate the welder?

When you know how to manage time intervals write another short sketch that enables you to learn how to get data from the encoder.

And separately write a short sketch to learn how to use the LCD.

Trying to learn all these things at once will just give you spaghetti code and a debugging nightmare.

...R

excellent advise to have each function separate. makes debugging easier.

do you want to start the timing when you press the foot peddle and then have the arduino shut off the welder ?
or do you want the arduino to turn on the welder when you press the peddle and then shut off at your set time?

the other option is to use it as a stop watch. when you press the peddle, it senses the start of power flow and then counts down an beeps. you remove your foot and the process stops.

read up on a relay that you can use a low voltages and high amps. pretty beasty animals.

I suggest you look at 555 hardware timers. It would only need a simple circuit to generate a timed pulse each time you trigger it, with a rotary pot controlling the pulse length.

Thanks for your replies and advice so far.

The idea is to use the arduino to control the spot welder.

This is the process I am looking at,

The user inputs the desired weld time via the rotary encoder, and the time is shown on the LCD.
The user then presses and holds down a foot pedal switch.
The arduino then switches on the spot welder, and starts a countdown of the set time.
Once the set time expires the arduino turns off the spot welder and sounds a tone.
Once the user removes there foot from the pedal switch the system will reset ready to be used again.

If at any point in time the user removes there foot from the pedal switch it will stop the welding process.

Thanks again for your time and advice.

If you display the duration on an LCD then it would be much easier to set it using a potentiometer rather than an encoder. With feedback from the LCD display the user could set the time accurately,

How do you propose that the Arduino will control the welder? Presumably it uses a large current?

...R

once you press your foot on the peddle, you do not need or want to look at the encoder.

you really do not require the encoder, you can use a couple buttons like most clocks use these days.

one forward, one back, hold it and it starts to speed up....

Commenting your code is a laudable thing, especially when they explain the why of what you're doing. These though really don't add anything that you can't tell from just reading the code:

lcd.setCursor(0,1);                                            // Start at character 1 on line 1
lcd.print(" Pedal to Start ");                                 // Print text to lcd display
delay(2000);                                                   // Delay

Hi MadProfessor

Sounds like an interesting project.

As you start to build up the different pieces of the overall solution, and once you have the basics working, there are a couple of other things you may want to add to your requirements.

The user inputs the desired weld time via the rotary encoder, and the time is shown on the LCD.
The user then presses and holds down a foot pedal switch.
The arduino then switches on the spot welder, and starts a countdown of the set time.

During the countdown, should the user be able to alter the duration using the encoder? I would assume "no". So your code needs to ignore their control inputs until the weld is finished.

If at any point in time the user removes there foot from the pedal switch it will stop the welding process.

What if the user gets a cramp in their foot, and releases pressure on the pedal for a moment but then presses down again (maybe without realising they have done it)? Do you want to play safe and cancel the weld when they release the pedal? If so, what happens when they re-apply pressure? You may not want them to start a whole new countdown. So you could build in a "lockout" period. For example ...

If at any point in time the user removes there foot from the pedal switch it will stop the welding process.
Pressing the pedal switch again will be ignored until (e.g.) 2 seconds after the pedal switch was released.

Lastly, when you start to experiment with the foot switch (or piece of wire when testing), you should read up on debounce in the tutorials pages.

Regards

Ray

You need to have a timer (or multiple timers if you want) to

  1. adjust the power integral from ac cross
  2. generate a triac or IGBT pulse
  3. counts number of pulses

Forget the relays.