switch state = momentary output

Application:

Pellet Stove with on and off buttons (momentary)

Thermostat with contact open/closed

I need to send the signal via two relays (or other means) to the on/off buttons depending on the t-stat contact state....closed = on button.... open = off button.

I found the 3 connections needed on the stove and tapped in. I didn't ck voltage but it appears to be a momentary ground for each button. I powered up stove and jumped the harness I made it that works.

Now I need to get the Arduino to do it with the t-stat. Also a 20-30 min delay after off command before answering a closed contact on request would be a good idea. (stove cool down).

Then I want to build that into a mini and install it in the stove.

It's looks like it should be pretty simple code and the Arduino looks really cool but by the time I figure it out it will be Spring time. It looks like there are many different methods of code that would do it.

Thanks for the help

Installing it in the stove would somewhat shorten the lifetime of the electronics!

Bu otherwise perfectly feasible - how exactly can we help you?

regards

Allan

I'll prolly attach it the the board that's in there now. But I just opened the book on Arduino cause I couldn't find a cheap (or any) pre-made board to do this. But I actually got this one a while ago to do some cool stuff with led lights on a rc plane. Anyway..I'm not sure which way to go with the code..Switch Case or If Then...or .any of the other ways....trying to learn on the fly. I thought relays would be good so as to isolate from Stove electronics. The stove actually has a Atmel on it with what appears to be a Jtag & a Cat 5 connection but that would be a whole other story. I've looked at sketches for push-button to toggle....just gotta reverse it I guess

I take it your thermostat measures room temperature.

Most gas/oil boilers also have an internal temperature sensor to avoid them overheating - you could do that too with a thermocouple on your stove.

As to the electronics, it shouldn't be too expensive - a psu, arduino, a couple of relays plus their driver devices... if you want a thermocouple input an interface board (SHIELD)

regards

Allan

Nobody interested in getting me started....with a good approach.

I know I need pin assignments for i/o. I assume can use the internal pull-up for the contact close/open in some way, in conjunction with a debounce or delay. Then I need to translate that into 2 momentary outputs to the (2) relays based on input contact state..high or low from the input state.

So how do i do that?

OK .. am I right in saying:

1/ the only connection between your new arduino device and your existing control box will be via two isolated relay contacts.

2/the only input to the arduino is an on/off thermostat and ( of course) some sort of power supply....

Allan.

Sounds like you have three states:

StoveCold
StoveOn
StoveCooling

Then you just have to write the state transitions:

StoveCold:
If (thermostat says WARMER)
TurnStoveOn();
state = StoveOn;

StoveOn:
If (thermostat says COOLER)
Note the cooldown start time.
TurnStoveOff();
state = StoveCooling;

StoveCooling:
if (elapsed cooling time >= 1 hour)
state = StoveCold;

OK except the OP sugests 20-30 min as the timeout.

And in StoveCooling state, if thermostat calls for heat, shouldn't you go to StoveCold...

open to tuning

regards
Allan

allanhurst:
OK except the OP sugests 20-30 min as the timeout.

Oops. You're right.

allanhurst:
And in StoveCooling state, if thermostat calls for heat, shouldn't you go to StoveCold...

I don't think so. From the specification: "Also a 20-30 min delay after off command before answering a closed contact on request would be a good idea. (stove cool down)." It sounds like the whole idea is to keep the stove off for at least 20-30 minutes before it is allowed to start again. Going to StoveCold when the stove is cooling and the thermostat calls for heat would allow the stove to start up seconds after it turned off. There would be no forced minimum cool-down time and no need for the StoveCooling state at all.

OK - open to tuning on test.. we don't know the time constants of the burner or the house.

regards

Allan

well the cool down thing just complicates matters cause the stove will do that on it's own...

I just really need to turn an on / off input (switch)....into two different (2 channel) momentary outputs....like pushing an on and off button.

Thats it

I just need nothing to happen in between the on and off input...do nothing until input state change....then do either / or... and wait...until next change

So the momentary toggle I'm looking for is going to trigger 2 relays 1 for ON..the other for OFF
By trigger..I mean..like a momentary pushbutton.

So when the switch is closed...I need it to toggle relay 1...then

When the switch opens....toggle relay 2......

Just keep track of if the stove is on:

boolean StoveIsOff = true;

void loop() {
    if (digitalInput(THERMOSTST_PIN) == HIGH) {
        // Thermostat calling for heat
        if (StoveIsOff)
            TurnStoveOn();
    } else {
       // Thermostat is NOT calling for heat
        if (!StoveIsOff)  // "if NOT StoveIsOff" means "if stove is on"
            TurnStoveOff();
    }
}

void TurnStoveOn() {
    digitalWrite(STOVE_ON_RELAY_PIN, HIGH);
    StoveIsOff = false;
    delay(500);
    digitalWrite(STOVE_ON_RELAY_PIN, LOW);
}


void TurnStoveOff() {
    digitalWrite(STOVE_OFF_RELAY_PIN, HIGH);
    StoveIsOff = true;
    delay(500);
    digitalWrite(STOVE_OFF_RELAY_PIN, LOW);
}

ahhh Thank You...I'm still not familiar with all the uses of terms....like boolean...and what can follow void.

I had most of it ....the reverse aruments r a little tricky..I'll try again....Thanks

'boolean' is a variable type that can only have the values 0/false/LOW or 1/true/HIGH.

'void' is a variable type that contains no data. When you declare a function you have to specify the type of data it returns. If it does not return a value you use the type 'void'. The compiler knows it's a function because the name is followed by an argument list in parentheses.

Not sure what you mean by "the reverse arguments".

Not really reverse but....if (!StoveIsOff) // "if NOT StoveIsOff" means "if stove is on

I tweaked your sketch to my config...and it worked...Thanks

Actually testing with led's cause I don't have my 5v relay module yet, wondering how the input pins work,
I see the module is powered (vcc pin) so do pins trigger high or low...guess I'll see.

Thanks again
ps. now I'm thinking about adding a temp sensor and add another output choice depending on outside temp....mmmm

Here is the working sketch...Thank You johnwasser ...for the help.

/*  Pellet Stove Bypass Mod..so stove will shut off with remote Thermostat instead of idle.
(Idle = stove will go to a lower then 1 setting but continue to run....not for long :) */


// the setup function runs once when you press reset or power the board
  
const  int CH1 = 8;           // Connect Digital Pin 8 to CH1 on Relay Module for ON command
const  int CH2 = 9;           // Connect Digital Pin 9 to CH2 on Relay Module for OFF command
const  int TStat = 2;     // T-stat input on pin 2 high or low
       int StatState = digitalRead(TStat);
       int CH1state = digitalRead(CH1);
       int CH2state = digitalRead(CH2);

       
void setup() {
  Serial.begin(9600);     // Start serial read
 // while (!Serial);       // Wait for connect
  
  pinMode(CH1,OUTPUT);  // Relay 1 for On command
  pinMode(CH2,OUTPUT);  // Realy 2 for OFF command
  pinMode(TStat,INPUT_PULLUP);    // T-stat open/close contact input
  
}

boolean StoveIsOff = true;

void loop() {
    if (digitalRead(TStat) == HIGH) {
        // Thermostat calling for heat
        if (StoveIsOff)
            TurnStoveOn();
    } else {
       // Thermostat is NOT calling for heat
        if (!StoveIsOff)  // "if NOT StoveIsOff" means "if stove is on"
            TurnStoveOff();
    }
}

void TurnStoveOn() {
    digitalWrite(CH1, HIGH);            //STOVE_ON_RELAY_PIN
    Serial.print ("CH1:  ");
  Serial.println (CH1state );
    StoveIsOff = false;
    delay(500);
    digitalWrite(CH1, LOW);
    Serial.print ("CH1:  ");
  Serial.println (CH1state );
}


void TurnStoveOff() {
    digitalWrite(CH2, HIGH);       //STOVE_OFF_RELAY_PIN
    StoveIsOff = true;
    delay(500);
    digitalWrite(CH2, LOW);
}

As I suspected...the relays trigger ON ..LOW here is the modified version

/*  Pellet Stove Bypass Mod..so stove will shut off with remote Thermostat instead of idle.
(Idle = stove will go to a lower then 1 setting but continue to run....not for long :) */


// the setup function runs once when you press reset or power the board
  
const  int CH1 = 8;           // Connect Digital Pin 8 to CH1 on Relay Module for ON command
const  int CH2 = 9;           // Connect Digital Pin 9 to CH2 on Relay Module for OFF command
const  int TStat = 2;     // T-stat input on pin 2 high or low
       int StatState = digitalRead(TStat);
       int CH1state = digitalRead(CH1);
       int CH2state = digitalRead(CH2);

       
void setup() {
  Serial.begin(9600);     // Start serial read
 // while (!Serial);       // Wait for connect
  
  pinMode(CH1,OUTPUT);  // Relay 1 for On command
  pinMode(CH2,OUTPUT);  // Realy 2 for OFF command
  pinMode(TStat,INPUT_PULLUP);    // T-stat open/close contact input
  digitalWrite(CH1, HIGH);        // <-------added for for relay off state on startup
  digitalWrite(CH2, HIGH);        // <-------added for for relay off state on startup
  
}

boolean StoveIsOff = true;

void loop() {
    if (digitalRead(TStat) == HIGH) { 
        // Thermostat calling for heat
        if (StoveIsOff)
            TurnStoveOn();
    } else {
       // Thermostat is NOT calling for heat
        if (!StoveIsOff)  // "if NOT StoveIsOff" means "if stove is on"
            TurnStoveOff();
    }
}

void TurnStoveOn() {
    digitalWrite(CH1, LOW);            //STOVE_ON_RELAY_PIN  <---changed to low for relay trigger
    Serial.print ("CH1:  ");
  Serial.println (CH1state );
    StoveIsOff = false;
    delay(500);
    digitalWrite(CH1, HIGH);            // Relay rest    <---changed to high for relay reset 
    Serial.print ("CH1:  ");
  Serial.println (CH1state );
}


void TurnStoveOff() {
    digitalWrite(CH2, LOW);       //STOVE_OFF_RELAY_PIN   <---changed to low for relay trigger
    StoveIsOff = true;
    delay(500);
    digitalWrite(CH2, HIGH);      //Relay reset        <---changed to high for relay reset
}