Advertisement
Guest User

Untitled

a guest
Oct 25th, 2020
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. /*Battery Spot Welder Timer
  2. This sketch will use an arduino to send a pulse through an SSR or SSC to weld tabs onto a battery
  3. A push button switch, LED Display, SSC or SSR, 5V source, Potentiometer, arduino type board will be needed
  4. Even Though this or similiar sketch is probably available online, I want to create it myself so I learn and
  5. get practice using it.
  6.  
  7. The Potentiometer will be used to set the pulse length. The LED will be used to display the length of pulse
  8.  
  9.  
  10. Ryan C. Lash modified by zeph with an i2c lc
  11. 25 June 2018
  12. Melbourne, Florida
  13.  
  14. */
  15.  
  16. /*First part of code sets up potentiometer. Pot needs to be hooked up to 5V and ground board. and middle pin
  17. goes to A0 as code is written.
  18.  
  19. 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
  20. until I physically begin to install the arduino onto the welder, and use the serial log to test the code as best I can
  21.  
  22. The last part of the code is to send a timed pulse to the SSR to send the welding current to do the weld.
  23.  
  24.  
  25. */
  26.  
  27.  
  28. const int trigger = 2;
  29. //The button or trigger to fire the welder will be hooked up to digital pin number 2
  30. //The pin number 2 will have a 10k Ohm resistor that pulls pin high when trigger is pressed
  31. //Need to double check trigger wiring
  32. const int SSC = 8;
  33. const int SSCLED = 13;
  34. //This is the digital pin that the Solid State Relay will be conected to.
  35. //High is true or Fire and Low is false or off
  36. #include <LCD_I2C.h>
  37.  
  38. LCD_I2C lcd(0x27);
  39. void setup() {
  40. lcd.begin(); // If you are using more I2C devices using the Wire library use lcd.begin(false)
  41. // this stop the library(LCD_I2C) from calling Wire.begin()
  42. lcd.backlight();
  43.  
  44. pinMode(trigger, INPUT);
  45. pinMode(SSC, OUTPUT);
  46.  
  47.  
  48. //boot sequence
  49. lcd.setCursor(0, 0);
  50. lcd.print(" THE NERDLING");
  51. lcd.setCursor(0, 1);
  52. lcd.print(" SPOT WELDER");
  53.  
  54.  
  55. //test status led
  56. digitalWrite(SSCLED, HIGH);
  57. delay(2000);
  58. digitalWrite(SSCLED, LOW);
  59. }
  60.  
  61. void loop() {
  62.  
  63. int potValue = analogRead(A2); //reads value of analog pin0, 0 is low 1023 is fullt
  64. float pulseTime = float(potValue) / 1023;
  65.  
  66. //this calculates pulse time in terms of fraction of a second
  67. //need to verify no problems with variable types int and float
  68. //This range is way shorter and way longer than it needs to be will edit code during testing
  69.  
  70. //Read the input pin:
  71. int fireTrigger = digitalRead(trigger);
  72. if (fireTrigger == 1) {
  73. digitalWrite(SSC, HIGH);
  74. digitalWrite(SSCLED, HIGH);
  75.  
  76.  
  77. //shows status on screen
  78. lcd.setCursor(0, 1);
  79. lcd.print("Triggered ");
  80.  
  81. delay(pulseTime * 1000); //Edited on forum (06/28/2018) fixed mistake: Multiply rather than divide
  82.  
  83. digitalWrite(SSC, LOW);
  84. digitalWrite(SSCLED, LOW);
  85.  
  86. delay(2000);
  87. //This puts a delay to prevent a second pulse and gives time for wires to cool
  88. }
  89. else {
  90. digitalWrite(SSC, LOW);
  91. }
  92.  
  93. // print out the value you read:
  94. lcd.setCursor(0, 0);
  95. lcd.print("Pulse Time=");
  96. lcd.print(pulseTime);
  97. lcd.print("S");
  98. //lcd.println(potValue);
  99.  
  100. lcd.setCursor(0, 1);
  101. lcd.print("Ready ");
  102.  
  103. delay(150); // delay in between reads for stability
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement