If statements not working. Help please thanks.

Hi guys i am relatively new to this Arduino stuff i have other sketches working with ifs and elses and all that but for some reason my kiln controller im making is not working properly when i try to activate the cooling down cycle it just does the first if not the others. i have gotten it to work for two if i chance some things up, have used else and else if and also compared my other sketches to this one and everything seems to be fine it just isnt working. Is the timer library messing with me? Should i use millies or something? Please help thanks guys.

if((x > GREENBUTTON_X1) && (x < (GREENBUTTON_X1 + GREENBUTTON_W1))) {
if ((y > GREENBUTTON_Y1) && (y <= (GREENBUTTON_Y1 + GREENBUTTON_H1))) {
digitalWrite(RedLed, HIGH);
Serial.println("Cooldown");
Alarm.timerOnce(3600, Cooldown); //hold for one hour once
if((baselineTemp <= 1054) && (baselineTemp > 952)){
Alarm.timerRepeat(18, Cooldown);} //drop 1 degree every 18 seconds or 100 degree in 30 minutes
if(baselineTemp == 952){
Alarm.timerOnce(3600, Cooldown);} //hold an hour at 952 and drop to 951
if(baselineTemp <= 951){
Alarm.timerRepeat(30, Cooldown);} //drop 2 degree a minute till 0. 10.4 hour cycle to 0

That is proabably the issue i will mess with those and see if it helps i will post all the code now its pretty massive.

Here is the file it is too big to post.

BillKiln2almostyep.ino (11 KB)

I am sorry i accidentally posted the wrong file. This one is formatted and correct.

BillKiln3pushbuttonannealing.ino (11.9 KB)

Still definitely not auto formatted.

Also, please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.

I am sorry I pressed auto format and then saved it. I am using 1.0.6 if that matters. I will fix it for any future posts.

BillKiln3.1.ino (11.7 KB)

Which of the sensors supported by the DallasTemperature library are you planning to use? I don't think any of them will even come close to supporting the temperatures you're working at.

Thank you for helping, I have done button push state change stuff i dont know if it is what i need here. I just want to press one button and have it start cooling down. It holds for a period of time then falls till it gets to a target temp then holds and falls again. I dont want to have to press buttons for each stage just press one and it drops the target temp by 1 degree every seconds or whatever the timer is until it gets to a certain temp then it activates a different timer.

I am using a K-type thermocouple and MAX31850 breakoutboard it is rated to 1300 or so it works great.

Thank you i will try and implement that into my coding and get back to you tomorrow or later tonight. If you can do something like that quickly and have some time i will send you some custom glass ornament or something you would like if you are interested. Im sure i could do it but it would take a while lol.

BigBillMC:
I am using a K-type thermocouple and MAX31850 breakoutboard it is rated to 1300 or so it works great.

Ah, I see now there are multiple libraries that contain a file named DallasTemperature.h. The one I found in the Arduino Library manager doesn't support the MAX31850 but yours does.

BigBillMC:
i will send you some custom glass ornament

From the temperatures, I'm guessing you're a borosilicate lampworker. Did I get it right?

Hi guys i am working on this kiln controller and i have gotten most everything working but i cannot, for the life of me figure out how to turn off a timer once it is started. I have tried using millies and other things but i am new to all of this and my code is so large it is very hard to get anything working. Can someone please assist i have most of everything set up it is probably something very small thank you.

Billkiln2.756.ino (11 KB)

You could clarify which timer and why you want it to turn off. Did you mean to disable it persistently or just for explicit time?

Also maybe start by saying what you expect to happen when the buttons are pressed:
RedButton(1)
RedButton(2)
GreenButton(1)
GreenButton(2)

There could be an alternative solution to the using the TimeAlarms library which achieve the same thing in a simpler way.

Threads merged.

Thanks for the help guys. If i press green button1 i want it to start a timer, then after a time stop that timer and start a new timer with different timers.

Pert yes you are right i am a glass blower. If anyone could help me i would glady send you some custom glass of your liking in the mail for free i will even cover shipping. Been trying to figure this out for days.

I have modified my code to include more instructions in //format. I cant get it to declare the Alarm in the scope. All the examples i can find say to put my line of code "StupidAlarm= Alarm.timerRepeat(1,Cooldown);" where the loop is happening but it doesnt seem to be right.

KilnNew.ino (11.6 KB)

Forget about your kiln controller sketch for now and write a minimal sketch that only helps you understand how the TimeAlarms library works with the minimal amount of unnecessary complexity (print to Serial Monitor or blink an LED). Likely that will make it clear to you what needs to be done. If not, then it will make it very easy for us to provide assistance.

Now this might be something you don't want to mess with now since you're already struggling, but my recommendation is to put all the kiln cycle data in an array. That will allow you to easily modify the cycle parameters, have multiple cycles, and will make the code cleaner. Here's how I have my cycles defined:

//time parameter of 0 indicates a hold, it will stay at the specified setpoint indefinitely.
//I have used the Northstar soak durations for each step except for the final ramp, the ASGS initial annealing temperature, and strain point temperature adjustment(extrapolated for >.5" wall thickness), and the 90F second ramp endpoint. I used the Contemporary Lampworking fast cool equation for the final ramp duration
const int program[][programStepCount][2] = {  //[programID(max 99)][programStep(max 99)][parameter(0==setpoint, 1==time(minutes))] - this is not unsigned so I don't have to convert to int for the setpoint change calculation in ramper(). The setpoint cannot be higher than alarmKilnTemperatureHigh2Value because of the sanity check in the PID code section
  {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},  //0==off
  {{garageLowPoint, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},  //1==low garage
  {{garageMedPoint, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},  //2==medium garage
  {{garageHighPoint, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},  //3==hot garage
  {{annealPoint + 9, 60}, {annealPoint, 30}, {strainPoint - 18, 12}, {strainPoint - 18 - 90, 33}, {offPoint, 2}, {0, 0}}, //4==0.25" anneal
  {{annealPoint + 9, 120}, {annealPoint, 102}, {strainPoint - 36, 30}, {strainPoint - 36 - 90, 48}, {offPoint, 8}, {0, 0}}, //5==0.5" anneal
  {{annealPoint + 9, 180}, {annealPoint, 192}, {strainPoint - 50, 48}, {strainPoint - 50 - 90, 60}, {offPoint, 17}, {0, 0}}, //6==0.75" anneal
  {{annealPoint + 9, 240}, {annealPoint, 270}, {strainPoint - 72, 60}, {strainPoint - 72 - 90, 105}, {offPoint, 31}, {0, 0}}, //7==1" anneal
  {{annealPoint + 9, 360}, {annealPoint, 435}, {strainPoint - 100, 75}, {strainPoint - 100 - 90, 113}, {offPoint, 69}, {0, 0}}, //8==1.5" anneal
  {{annealPoint + 9, 480}, {annealPoint, 600}, {strainPoint - 144, 90}, {strainPoint - 144 - 90, 120}, {offPoint, 110}, {0, 0}}, //9==2" anneal
  {{annealPoint + 9, 600}, {annealPoint, 930}, {strainPoint - 200, 135}, {strainPoint - 200 - 90, 180}, {offPoint, 183}, {0, 0}}, //10==2.5" anneal
  {{annealPoint + 9, 15}, {annealPoint, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, //11==DelayedOff
  {{decalDryPoint, decalDryTime}, {decalDryPoint, decalRampDuration}, {decalPoint1, decalHoldDuration}, {decalPoint2, 1}, {0, 0}, {0, 0}}, //12==extra
  {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}  //13==coolOff - used for emergency cooling
};

This uses the same cycle definition system as the commercial programmable temperature controllers do.

Holy eff balls man, that looks nice! I wasn't expecting a fellow lampworker to chime in! I am in the process of ditching TimeAlarms and using timer instead it seems like it should be easier but if that doesnt work out soon then i will try and implement your coding into mine. How long have you been melting sand?

20 years. And you?

8 Years. What do you make mostly? I make mostly functional stuff, just made some crazy recyclers. Also
marbles, pendants, figures, goblets, chains and pretty much whatever seems interesting at the time.

I think just figured out the timer library should be working here soon. Then i can make different timers based on temp and maybe a secondary button for longer times or something.