I am doing heating control project to control 2 boilers.
It is coming together well.
I would like to have a boost button as an input (pin6 LOW) and it to start a 90min timer and have this result to use in some if statement.
Which way should I approach this????
what have you tried so far ?
post your current sketch and we can give you pointers.
as for boilers, here in the US, one must be liscensed to operate one as an explosin will cause multiple deaths.
Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.
Put your sketch between the code tags [code]Paste your sketch here[/code]
code so far
[#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// Arduino 1-Wire Address Finder
DeviceAddress stovepipeThermometer = { 0x28, 0x19, 0x86, 0x3B, 0x07, 0x00, 0x00, 0x22 };
DeviceAddress cylinderThermometer = { 0x28, 0xD6, 0xD1, 0x50, 0x07, 0x00, 0x00, 0x59 };
const int in3 = 3;
const int in4 = 4;
const int in5 = 5;
const int in6 = 6;
const int in7 = 7;
int inp3 = 0;
int inp4 = 0;
int inp5 = 0;
int inp6 = 0;
int inp7 = 0;
const float heaton = 25;
const float heatoff = 22;
void setup()
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(stovepipeThermometer, 10);
sensors.setResolution(cylinderThermometer, 10);
// pin 2 one-wire bus
// downstairs stat pin 3
pinMode(in3, INPUT_PULLUP);
// upstairs stat pin 4
pinMode(in4, INPUT_PULLUP);
// attic stat pin 5
pinMode(in5, INPUT_PULLUP);
// 90 min oil boost pin 6
pinMode(in6, INPUT_PULLUP);
// oil auto/off pin 7
pinMode(in7, INPUT_PULLUP);
// oil boiler pin 8
pinMode(8, OUTPUT);
// stove pump pin 9
pinMode(9, OUTPUT);
// downstairs pump pin 10
pinMode(10, OUTPUT);
// upstairs pump pin 11
pinMode(11, OUTPUT);
// attic pump pin 12
pinMode(12, OUTPUT);
// cylinder pump pin 13
pinMode(13, OUTPUT);
// downstairs stat pin 3
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);
}
}
void loop(void)
{
delay(1000);
Serial.print("Getting temperatures...\n\r");
sensors.requestTemperatures();
inp3 = digitalRead(in3);
inp4 = digitalRead(in4);
inp5 = digitalRead(in5);
inp6 = digitalRead(in6);
inp7 = digitalRead(in7);
float tempstove = sensors.getTempC(stovepipeThermometer);
float tempcyl = sensors.getTempC(cylinderThermometer);
if
if (((tempstove-3) > tempcyl && tempcyl < 55) || (tempstove > heaton && inp3 == LOW)|| (tempstove > heaton && inp4 == LOW))
digitalWrite(9, HIGH);
if (((tempstove-2) < tempcyl) && (tempstove <heatoff && inp3 == LOW || inp3 ==HIGH)&& (tempstove < heatoff && inp4 == LOW || inp4 ==HIGH))
digitalWrite(9, LOW);
//downstairs pump control
if (tempstove > heaton && inp3 == LOW) || (inp3 == LOW && inp7 == LOW)
digitalWrite(10, HIGH);
if (tempstove < heatoff || inp3 == HIGH)
digitalWrite(10, LOW);
//upstairs pump control
if (tempstove > heaton && inp4 == LOW)
digitalWrite(11, HIGH);
if (tempstove < heatoff || inp4 == HIGH)
digitalWrite(11, LOW);
Serial.print("Stove temp. is: ");
printTemperature(stovepipeThermometer);
Serial.print("\n\r");
Serial.print("Cylinder temp. is: ");
printTemperature(cylinderThermometer);
Serial.print("\n\r");
}]
Are you familiar with creating timing using the BWD BlinkWithoutDelay technique?
What is to happen after the 90 minutes?
90 min = 90601000UL milliseconds.
.
I want to read pin 6
inp6 = digitalRead(in6);
from when it gets a LOW, and for 90601000 after I would like a probably float to use in an if statement
if (inp3 == LOW && boosttime) // boosttime is period for 90min after inp6 goes low
digitalWrite(10, HIGH);
First, give your inputs descriptive names. Call it "boostButtonPin" or something other than "inp6".
Second, you need to identify the state change. Your main loop reads all the buttons on every cycle. If you find on one cycle that the button wasn't previously pressed but now it is, you have identified the moment that the button was pressed. To do that, you need a little variable to store the previous information. "boostButtonPrevious" or something like that.
Third, you need to record the time that happened. millis() gives you a very good clock. Record that in another variable such as "boostButtonPressedTime".
Fourth, look at the current time and compare that to the time the button press was detected.
Questions:
- Is there a 'cancel' button that will cut short a boost?
- Is there some minimum period you want to hold the button down, so a short bump won't start the boost?
- Does this boost apply to both boilers or do they each have their own "boost" and "cancel" buttons?
- Are you likely to have any more than two boilers or can you say that there will never be another one (at least for the next 5 years)?
Here is a simple BWD example.
Look at switch #2 controlling a LED on pin 12
You will have to update your delay(1000); to BWD format
//Simple BWD BlinkWithoutDelay examples
//Timer variables used
unsigned long currentMillis;
unsigned long pin13Millis;
unsigned long pin12Millis;
unsigned long SwitchMillis;
//if these are not changed in the sketch, they can be const
unsigned long debounceMillis = 50UL; //50ms
unsigned long ledOnTime = 500UL; //500ms seconds
byte lastSwitchState = HIGH;
byte buttonState = HIGH;
//enable/disable flags
boolean flag13 = true;
boolean flag12 = false;
const byte Switch = 2; //pushed = LOW
//**********************************************************************
void setup()
{
Serial.begin(9600);
digitalWrite(13,LOW);
pinMode(13, OUTPUT);
digitalWrite(12,LOW);
pinMode(12, OUTPUT);
pinMode(Switch, INPUT_PULLUP); //pushed = LOW
} // >>>>>>>>>>>>>> E N D O F s e t u p ( ) <<<<<<<<<<<<<<<<<
void loop()
{
//save the current time
currentMillis = millis();
//*************************************
//Heartbeat LED
//Toggle LED on and off. Helps show if there is blocking code
if (flag13 == true && currentMillis - pin13Millis >= ledOnTime)
{
pin13Millis = millis(); //re-initialize Timer
digitalWrite(13,!digitalRead(13)); //toggle LED condition
}
//*************************************
if (flag12 == true && currentMillis - pin12Millis >= 5*1000UL)
{
//Turn off pin 12
digitalWrite(12,LOW); //Turn off LED
flag12 = false; //disable timing
}
//*************************************
//is it time to check the switches?
if (currentMillis - SwitchMillis >= debounceMillis)
{
//code here runs every debounceMillis ms
SwitchMillis = millis(); //re-initilize Timer
//go and check the switches
checkSwitches();
}
//*********************************
//put other non-blocking stuff here
//*********************************
} // >>>>>>>>>>>>>> E N D O F l o o p ( ) <<<<<<<<<<<<<<<<<
//======================================================================
// F U N C T I O N S
//======================================================================
//****************** c h e c k S w i t c h e s ( ) *********************
//switches are checked every debounceValue milli seconds
//no minimum switch press time is validated with this code (i.e. No glitch filter)
void checkSwitches()
{
//re-usable for all the switches
boolean thisState;
//check if this switch has changed state
thisState = digitalRead(Switch);
if (thisState != lastSwitchState)
{
//update the switch state
lastSwitchState = thisState;
//this switch position has changed so do some stuff
//"LOW condition code"
//has switch gone from HIGH to LOW?
if(thisState == LOW)
{
//Do some LOW switch stuff here
flag12 = true; //allow timing
digitalWrite(12, HIGH); //turn on LED
pin12Millis = millis(); //initialize Timer
}
} //END of Switch code
//*****************************************
// similar code for other switches goes here
//*****************************************
} //END of checkSwitches()
//**********************************************************************
//======================================================================
// E N D O F C O D E
//======================================================================
Thanks for advice lads
Just to answer Morgan questions
Questions:
-
Is there a 'cancel' button that will cut short a boost?
NO -
Is there some minimum period you want to hold the button down, so a short bump won't start the boost?
No -
Does this boost apply to both boilers or do they each have their own "boost" and "cancel" buttons?
1 boiler is solid fuel, so when this is producing heat, the heat will be distrubited to the required zones.
The boost button is for the oil boiler. -
Are you likely to have any more than two boilers or can you say that there will never be another one (at least for the next 5 years)?
No
dave-in-nj:
as for boilers, here in the US, one must be liscensed to operate one as an explosin will cause multiple deaths.
In the UK what we call a "boiler" is what in the US would be called a "furnace".