Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Battery Spot Welder Timer
- This sketch will use an arduino to send a pulse through an SSR or SSC to weld tabs onto a battery
- A push button switch, LED Display, SSC or SSR, 5V source, Potentiometer, arduino type board will be needed
- Even Though this or similiar sketch is probably available online, I want to create it myself so I learn and
- get practice using it.
- The Potentiometer will be used to set the pulse length. The LED will be used to display the length of pulse
- Ryan C. Lash modified by zeph with an i2c lc
- 25 June 2018
- Melbourne, Florida
- */
- /*First part of code sets up potentiometer. Pot needs to be hooked up to 5V and ground board. and middle pin
- goes to A0 as code is written.
- The next part of the code is for the LED readout to show how long the pulse will be. I will probably skip this part
- until I physically begin to install the arduino onto the welder, and use the serial log to test the code as best I can
- The last part of the code is to send a timed pulse to the SSR to send the welding current to do the weld.
- */
- const int trigger = 2;
- //The button or trigger to fire the welder will be hooked up to digital pin number 2
- //The pin number 2 will have a 10k Ohm resistor that pulls pin high when trigger is pressed
- //Need to double check trigger wiring
- const int SSC = 8;
- const int SSCLED = 13;
- //This is the digital pin that the Solid State Relay will be conected to.
- //High is true or Fire and Low is false or off
- #include <LCD_I2C.h>
- LCD_I2C lcd(0x27);
- void setup() {
- lcd.begin(); // If you are using more I2C devices using the Wire library use lcd.begin(false)
- // this stop the library(LCD_I2C) from calling Wire.begin()
- lcd.backlight();
- pinMode(trigger, INPUT);
- pinMode(SSC, OUTPUT);
- //boot sequence
- lcd.setCursor(0, 0);
- lcd.print(" THE NERDLING");
- lcd.setCursor(0, 1);
- lcd.print(" SPOT WELDER");
- //test status led
- digitalWrite(SSCLED, HIGH);
- delay(2000);
- digitalWrite(SSCLED, LOW);
- }
- void loop() {
- int potValue = analogRead(A2); //reads value of analog pin0, 0 is low 1023 is fullt
- float pulseTime = float(potValue) / 1023;
- //this calculates pulse time in terms of fraction of a second
- //need to verify no problems with variable types int and float
- //This range is way shorter and way longer than it needs to be will edit code during testing
- //Read the input pin:
- int fireTrigger = digitalRead(trigger);
- if (fireTrigger == 1) {
- digitalWrite(SSC, HIGH);
- digitalWrite(SSCLED, HIGH);
- //shows status on screen
- lcd.setCursor(0, 1);
- lcd.print("Triggered ");
- delay(pulseTime * 1000); //Edited on forum (06/28/2018) fixed mistake: Multiply rather than divide
- digitalWrite(SSC, LOW);
- digitalWrite(SSCLED, LOW);
- delay(2000);
- //This puts a delay to prevent a second pulse and gives time for wires to cool
- }
- else {
- digitalWrite(SSC, LOW);
- }
- // print out the value you read:
- lcd.setCursor(0, 0);
- lcd.print("Pulse Time=");
- lcd.print(pulseTime);
- lcd.print("S");
- //lcd.println(potValue);
- lcd.setCursor(0, 1);
- lcd.print("Ready ");
- delay(150); // delay in between reads for stability
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement