Go Down

Topic: help with code (battery tab spot welder) (Read 16949 times) previous topic - next topic

Henry_Best


So i started over and while its not perfect it does work and it works pretty well.
Code: [Select]

void loop(){
  // read the state of the pedal switch value:
  pedalState = digitalRead(pedalPin);

  // check if the pedal switch is pressed.
  // if it is, the pedalState is HIGH:
  if (pedalState == HIGH) {
    delay (500);
    // delays button for 500ms to give you time to release foot pedal
    // turn LED on:   
    digitalWrite(relayPin, HIGH);
    delay (333);
    // sets relay to high for 333ms
  }
  else {
    // turn Relay off:
    digitalWrite(relayPin, LOW);
  }
}
But what if your operator doesn't take his foot off the pedal before 500 + 333 millis have elapsed? The loop will start again and your relay will pull in again.
Take out
Code: [Select]
}
  else {
The end of your code should be:
Code: [Select]
  delay (333);  // sets relay to high for 333ms
  digitalWrite(relayPin, LOW);  // turn Relay off
  while(pedalState == HIGH); //Do nothing until pedal released
  }
}

01sensei

lets say you do get two (real) farad caps. Most are not anywhere close to what they say they are you also need low esr. then the next problem is you will need wore the 12v to charge li-ion tab welding needs around 16v. now lets say we did get 2 real farad and they have low esr now we got to run them parallel and use mosfets. A thriodsistor wont really work reason being once they open they dont close till there empty. so that brings use to the use of mosfets (heavy duty ones) and some decent bus bars. then once we have this we need to make a circuit that fires once but doesnt make a weld it only cleans off contaminants the ms after it fires the secondary charge which makes the physical weld. now we have a dual pulse cd welder. Yes you can weld in one pulse but you wont beable to weld li-ion batterys with 12v. you could at 16v. but if you have invested in caps you might want a dual pulse. Also just a not most car caps are crappy caps there are some that are great like the rockford fosgate 1 farad caps. but for me i got a great deal on some 120,000uf low esr caps. now mine are 10v caps but if i make two banks of ten in parallel then wire them in series i will still have a low enough esr and now 20v cap bank...   running caps in series doubles you voltage but also doubles your esr and decresses the total size in half so 20 120k uf caps run in two banks in series gives me. 120000 x 20 = 2400000   2400000/1000000 = 2.4 so we got a total of 2.4 farads not we got to devide 2.4/2 = 1.2   so my total is now only 1.2 farads at 20v and 1 real farad is enough to weld li-ion. think i did that correct...

01sensei

Henry_best

you my friend seen what i wanted all along that safety measure and since i know nothing about coding i hadnt got that far but now that i just read that code you put up it all makes sense. thank you i will add it to my code and see how it works. it would be much safer for a operator to use that way and since my buddys will most likely use it to rebuild there drill batterys it whould make it almost idiot proof. lol

01sensei

Henry_best
  that code will compile but its not working when the pedal button is held down the relay pin still will go HIGH. theres something still missing.

PeterH

If you only want one timed pulse output each time a switch is closed, have you considered just using a 555 hardware timer? It would be much simpler and cheaper to implement and probably a lot more robust than putting a microcontroller in such a noisy environment.

01sensei

I've thought of a triple nickle setup but if i remember right heat can cause a 555 timer to not be precise. Also i got the arduino to play around with and learn with it so ill stick to it... I could always add noise filters to my circuit. also i have moved alittle forward and etched out a solo arduino board its got a header on it to program it i guess i made it just so one of my arduinos isnt tied up with a project. on a side not fedex office found out that there glossy lazer paper isnt suppose to be used in there printers. so their new paper sucks for toner transfer.(note to self Buy a lazer printer) anyways the solo board works so im happy. Now just to figure out the code so if the pedal button is held down longer it wont turn on the relay till after the pedal is relased.

                                                 Thanks 01sensei

Henry_Best


Henry_best
  that code will compile but its not working when the pedal button is held down the relay pin still will go HIGH. theres something still missing.

Yes, but only for 333mS and only once. If that's not the case, post your code again.

01sensei

Henry_Best heres the code now its entirely possible i messed the code up but i feel that i did it right....

Code: [Select]
// set pin numbers:
const int pedalPin = 2;     // the number of the pedal switch pin
const int relayPin =  9;      // the number of the Relay pin

// variables will change:
int pedalState = 0;         // variable for reading the pedal switch status

void setup() {
  // initialize the Relay pin as an output:
  pinMode(relayPin, OUTPUT);     
  // initialize the pedal switch pin as an input:
  pinMode(pedalPin, INPUT);     
}

void loop(){
  // read the state of the pedal switch value:
  pedalState = digitalRead(pedalPin);

  // check if the pedal switch is pressed.
  // if it is, the pedalState is HIGH:
  if (pedalState == HIGH) {
    delay (500);
    // delays button for 500ms to give you time to release foot pedal
    // turn LED on:   
    digitalWrite(relayPin, HIGH);
    delay (333);
    // sets relay to high for 333ms
  }
  else {
   
    delay (333);  // sets relay to high for 333ms
  digitalWrite(relayPin, LOW);  // turn Relay off
  while(pedalState == HIGH); //Do nothing until pedal released
  }
}

PaulS

Quote
while(pedalState == HIGH); //Do nothing until pedal released

If you looked at the state change detection example, as has been suggested, you'd see that this is unnecessary.

You can detect when the switch BECOMES pressed, rather than IS pressed. Obviously (to me, anyway), a switch can no BECOME pressed again until after is BECOMES released.
The art of getting good answers lies in asking good questions.

Henry_Best


Henry_Best heres the code now its entirely possible i messed the code up but i feel that i did it right....

Try this:
Code: [Select]
// set pin numbers:
const int pedalPin = 2;     // the number of the pedal switch pin
const int relayPin =  9;      // the number of the Relay pin

// variables will change:
int pedalState = 0;         // variable for reading the pedal switch status

void setup() {
  // initialize the Relay pin as an output:
  pinMode(relayPin, OUTPUT);     
  // initialize the pedal switch pin as an input:
  pinMode(pedalPin, INPUT);     
}

void loop(){
  // read the state of the pedal switch value:
  pedalState = digitalRead(pedalPin);

  // check if the pedal switch is pressed.
  // if it is, the pedalState is HIGH:
  if (pedalState == HIGH) {
    digitalWrite(relayPin, HIGH);  // turn LED on
    delay (333);      // sets relay to high for 333ms
    digitalWrite(relayPin, LOW);  // 333ms now elapsed so turn Relay off
    while(digitalRead(pedalPin)==HIGH); //Keep reading the state of the pedal
                                      //and do nothing until pedal released
  }
}

01sensei

still not working its still going when the button is held down

01sensei

henry nevermind that works perfect i was waiting for it to go high after i released and now it does it instantly and doesnt loop while holding the pedal down. this will work great

Docedison

Thank You Henry_Best for all your work
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

01sensei

Yes Henry_Best A Big THANK YOU   and i understand how the code works wish i could of grasped it earlier

Henry_Best


Thank You Henry_Best for all your work

"Experienced old Whitebeard with a Full head of Hair..."
That could apply to me too, Doc, although my hair is receding slightly and we may be experienced in different things  ;)

Go Up