Ok, Started a new project and I have to make a choice on what timers to use and sense a low input from a relay and pulse a relay on.
I need to make 10 circuits of this as a repeat for discharging batteries and recharge for 50 cycles.
The input to trigger the relay is from the discharge circuit already made, when the battery goes to about 6 volts, the relay closes a set of contacts. Originally it does nothing, but I will use this as a trigger.
To start the discharge of the battery, I have a push button. Push the button, an LED comes on and a low ohm resistor is in circuit to discharge the battery.
The sense for when to stop is a Zener and 2 relays. One is a 5 volt relay and the other is a 4.5 volt. The 5 volt drops out first and that is the one to signal to recharge. This will charge/discharge up to 50 times and stop as I said before.
The problem is I will time the charging at guessing how long it is to recharge the battery. Guessing is 3 hours currently (has lead way here).
I have tried elapsemillis with some success. I need to do debounce..
The test circuit code runs for 10 secs when I push the button I have (Acts as relay when done goes LOW)
I show the time and print so I know where I'm at in the program
I release the button as quick as I can and when I see the LED lite
I have now got myself in a loop and even this is so small, I now have myself confused.
Code I have started.. no debounce and it still has issues.
And if you have suggestions for 10 circuits or anything, tell me.. I will learn.
Wayne
I need to make 10 circuits of this as a repeat for discharging batteries and recharge for 50 cycles.
The input to trigger the relay is from the discharge circuit already made, when the battery goes to about 6 volts, the relay closes a set of contacts. Originally it does nothing, but I will use this as a trigger.
To start the discharge of the battery, I have a push button. Push the button, an LED comes on and a low ohm resistor is in circuit to discharge the battery.
The sense for when to stop is a Zener and 2 relays. One is a 5 volt relay and the other is a 4.5 volt. The 5 volt drops out first and that is the one to signal to recharge. This will charge/discharge up to 50 times and stop as I said before.
The problem is I will time the charging at guessing how long it is to recharge the battery. Guessing is 3 hours currently (has lead way here).
I have tried elapsemillis with some success. I need to do debounce..
The test circuit code runs for 10 secs when I push the button I have (Acts as relay when done goes LOW)
I show the time and print so I know where I'm at in the program
I release the button as quick as I can and when I see the LED lite
I have now got myself in a loop and even this is so small, I now have myself confused.
Code I have started.. no debounce and it still has issues.
Code:
const int ledPin = 13;
int hour = 1000; // 3600000 milliseconds in an hour
int state = HIGH;
elapsedMillis battery1;
elapsedMillis battery2;
elapsedMillis battery3;
elapsedMillis relaypulse;
//long hour = 3600000; // 3600000 milliseconds in an hour
int battery1in = 1;
int battery2in = 2;
int battery3in = 3;
int battery1pass;
int battery1count;
// delay in milliseconds between blinks of the LED
// unsigned int interval = 60 x 60 x1;
// the setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
}
// the loop() methor runs over and over again,
// as long as the board has power
void loop()
{
if (digitalRead(0) == LOW && battery1pass == 0 && battery1count < 10) // start led high after low on input 0 (operate relay)
{
battery1 = 0; // reset timer to 0
battery1pass = 1; // set condition
digitalWrite(ledPin, LOW);
}
if (digitalRead(0) == LOW && battery1 > 10000 && battery1count < 10) // while low on input 0 and secs pass led goes low (turn off relay)
{
//relaypulse=0;
digitalWrite(ledPin, LOW); Serial.print(relaypulse); Serial.println(" Time has Passed");
if (relaypulse > 500 + battery1)
{
digitalWrite(ledPin, HIGH); Serial.println("Pulse Relay");
relaypulse = 0; battery1 = 0;
}
battery1 = 0;
}
if (digitalRead(0) == HIGH && battery1pass == 1 && battery1count < 10) // immediately return conditions for input 0 to normal and increase count by 1
{
battery1count = battery1count + 1;delayMicroseconds(100);
digitalWrite(ledPin, LOW); Serial.print("Battery 1 count = "); Serial.println(battery1count);
battery1pass = 0;
}
}
And if you have suggestions for 10 circuits or anything, tell me.. I will learn.
Wayne