Re: Ensten bygger styrning till pelletsbrännare
Postat: 24 december 2013, 08:41:41
johano har du så korta start-stoppcykler att det inte hinner glöda färdigt innan nästa start ?
Svenskt forum för elektroniksnack.
https://elektronikforumet.com/forum/
Nej, risken är om det blir ett kort strömavbrott under uppstarten, då kommer brännaren starta om och glatt skicka på en ny startdos på den som redan ligger där och glöder....Bittämjaren skrev:johano har du så korta start-stoppcykler att det inte hinner glöda färdigt innan nästa start ?
eller använda temperatursensor för att veta om det redan glöder?
Kod: Markera allt
lcd.print(F("Min fina text här));
Kod: Markera allt
#include <MemoryFree.h>
#include <Time.h> // For the clock
#include <DS1307RTC.h> // For the RTC
#include <Wire.h> // For serial communication
#include <LiquidCrystal_I2C.h> // For running thel i2c LCD
// Declare variables
// Set pin numbers
byte skruvPin = 12; //Set pin for feeder
byte heaterPin = 10; //Set pin for heater
byte callingForHeat = 7; //Set pin for listening on boiler calling for heat
int flameInput = A0; //Analog pin for flame
// Set other variables
int flameVisible;
int calling;
boolean FOn;
int k;
time_t t = now();
long timePlusFiveSec = 5;
long timePlusOneSec = 1;
long timePlusThirtySec = 30;
long timePlusTenSec = 10;
long timePlusTwentySec = 20;
long timePlusThreehundredSec = 300;
long timePlusThirteenSec = 13;
long timePlusNineSec = 9;
int filledPellets = 0;
int flameThreshold = 500;
int choosenEffect = 2;
int counter = 1;
int flameValue = 1;
// Other settings
LiquidCrystal_I2C lcd(0x27,20,4);
void setup()
{
// Initiate some hardware
lcd.init();
lcd.backlight();
Wire.begin();
Serial.begin(9600);
pinMode(skruvPin, OUTPUT);
pinMode(callingForHeat, INPUT);
pinMode(heaterPin, OUTPUT);
setSyncProvider(RTC.get);
}
void loop()
// Things that starts right away
// Check current boiler status
{
FOn=getFlameStatus(); // Get flame status bool (on or off)/(True or False)
k=CheckBoilerStatus(); // Get the status from boiler int 0-3
lcd.setCursor(0,1); // Debug
lcd.print(k); // Debug
switch (k) { // Act on boiler status
case 0: // 0 Boiler needs to be started
break;
case 1: // 1 Boiler should run with set effect mode
runBoiler(1);
break;
case 2:
blowOut();
break;
case 3:
fillPellets();
break;
}
}
int CheckBoilerStatus() // Checking boiler status and set it as an int 0-3
/*
Controls the status of the boiler
0 = Boiler is hot enough, no need to start, flame is out
1 = Boiler has flame and wants more heat, run pellet feed and fan
2 = Boiler has flame but is hot enough, run fan until flame is out
3 = Boiler has no flame and is not hot enough, start from beginning with feeding pellet and start heating
*/
{
FOn = getFlameStatus();
calling = digitalRead(callingForHeat);
if ((FOn == 1) && (calling == 1))
{
return 1;
}
else if ((FOn == 1) && (calling == 0))
{
return 2;
}
else if ((FOn == 0) && (calling == 1))
{
return 3;
}
else
{
return 0;
}
}
int getFlameStatus() {
int avgFlame;
for (int i = 1; i < 51; i++) {
avgFlame = analogRead(flameInput)+avgFlame;
}
flameValue = avgFlame / 50;
if (flameValue < flameThreshold)
{
return false;
}
else if (flameValue >= flameThreshold)
{
return true;
}
}
void fillPellets() {
if (filledPellets == 0)
{
t=now();
timePlusThirtySec = t + 2;
// Serial.println(t);
// Serial.println(timePlusThirtySec);
while (t < timePlusThirtySec){
t = now();
lcd.setCursor(0,0);
lcd.print(timePlusThirtySec - t);
lcd.print(F(" "));
digitalWrite(skruvPin, HIGH);
lcd.print(F("Feeding ... "));
}
filledPellets = 1;
digitalWrite(skruvPin, LOW);
lcd.setCursor(0,0);
lcd.print(F("Feeding, done!"));
ignitePellets();
}
else{
}
}
void ignitePellets() {
lcd.setCursor(0,1);
lcd.print(F("Ignites pellets "));
lcd.print(CheckBoilerStatus());
for (int c = 1; c < 11; c++) {
lcd.setCursor(0,0);
lcd.print(F("Igniting, try no: "));
lcd.print(c);
lcd.setCursor(0,3);
lcd.print(CheckBoilerStatus());
digitalWrite(heaterPin, HIGH);
Serial.println(F("HeaterPin High"));
t = now();
timePlusTenSec = t + 1;
while (t < timePlusTenSec) {
t = now();
lcd.setCursor(0,1);
lcd.print(F("Fan high "));
//Run fan at high speed
}
t = now();
timePlusTenSec = t + 1;
while (t < timePlusTenSec) {
t = now();
lcd.setCursor(0,1);
lcd.print(F("Fan low "));
//Run fan at low speed
lcd.setCursor(0,1);
lcd.print(counter);
}
CheckBoilerStatus();
if (CheckBoilerStatus() == 1)
{
lcd.setCursor(0,1);
lcd.print(F("Choosen effect: "));
lcd.print(choosenEffect);
runBoiler(choosenEffect);
}
}
digitalWrite(heaterPin, LOW);
lcd.setCursor(0,0);
counter = CheckBoilerStatus();
lcd.print(counter);
Serial.print(counter);
delay(10000);
if (counter == 3)
{
larmStop(1);
}
}
void runBoiler(int effect) {
digitalWrite(heaterPin, LOW);
time_t q = now();
int effectValue;
switch (effect)
{
case 1:
timePlusTwentySec = q + 20;
while (q < timePlusTwentySec)
{
lcd.setCursor(0,3);
lcd.print(F("Feeds in: "));
lcd.print(timePlusTwentySec - q);
lcd.print(F(" "));
q = now();
};
digitalWrite(skruvPin, HIGH);
delay(1000);
digitalWrite(skruvPin, LOW);
CheckBoilerStatus();
break;
case 2:
timePlusThirteenSec = q + 13;
while (q < timePlusThirteenSec)
{
lcd.setCursor(0,3);
lcd.print(F("Feeds in: "));
lcd.print(timePlusThirteenSec - q);
lcd.print(F(" "));
q = now();
};
digitalWrite(skruvPin, HIGH);
delay(1000);
digitalWrite(skruvPin, LOW);
CheckBoilerStatus();
break;
case 3:
timePlusNineSec = q + 9;
while (q < timePlusNineSec)
{
lcd.setCursor(0,3);
lcd.print(F("Feeds in: "));
lcd.print(timePlusNineSec - q);
lcd.print(F(" "));
q = now();
};
digitalWrite(skruvPin, HIGH);
delay(1000);
digitalWrite(skruvPin, LOW);
CheckBoilerStatus();
break;
case 4:
effectValue = 4;
break;
case 5:
effectValue = 5;
break;
case 6:
effectValue = 6;
break;
case 7:
effectValue = 7;
break;
case 0:
effectValue = 0;
break;
}
}
void blowOut () {
// Set fan high if status is 2 for 5 minutes (300 seconds)
time_t r = now();
timePlusThreehundredSec = r + 300;
while (r < timePlusThreehundredSec) {
// Fan speed high
}
CheckBoilerStatus();
}
void larmStop(int larmMode) {
digitalWrite(skruvPin, LOW);
digitalWrite(heaterPin, LOW);
// Set fan to High for five minutes
lcd.clear();
lcd.setCursor(0,0);
lcd.print(F("L A R M ! ! ! "));
lcd.print(larmMode);
lcd.setCursor(0,1);
lcd.print(F("Start failed!"));
lcd.setCursor(0,2);
lcd.print(F("Restart manually"));
int s = 1;
while (s < 10) {
lcd.backlight();
delay(200);
lcd.noBacklight();
delay(200);
}
}