[SOLVED]Temperature Ladder

Hi All;

The project I have is a chamber that requires a constant temperature(say 23 C ), but when a button is pushed the heating element needs to increase temperature to a user specified point (30 C), hold it for 10 minutes, then switch to the next set-point(40 C), hold it for 10 minutes...repeat for the third after which it exits the loop and returns to the constant temperature control(23 C).

Is this feasible? would it be easier to assign a button to each set-point change for a manual operation? Any feedback is appreciated.

You can buy programmable modules very cheaply on eBay that do exactly what you want.

Look for "PID controllers".

Anything is possible, and in my opinion, going on a ebay-hunt is often a guessing-game since pretty much anything ive bought there has been without manual, instructions or similar, a picture with pinouts at best.

If one already posesses the knowledge about the components, then its of course a far lesser problem, but ive spent my fair share of life-lesson-money on ebay.. :stuck_out_tongue:

Regarding the original question; Yes it would be easier with manual control.
But then again, ask yourself this; would it be as much fun?
Would it be more fun if you built a timer yourself?
Do you have the time and patience (and other pre-requisites) to learn?

If yes, yes and yes; then please feel welcome to try, we´ll help where we can.

But be prepared for some "life-lessons" along the way to success... :slight_smile:

To step between "modes" can be somewhat tricky, depending on what youre controlling..

But if youre heating a enclosed volume that you wish to be at a set temperature, you can heat it for X amount of time, then leave it off for Y time before repeating.
You can then adjust the X/Y values along the way with feedback from a temp sensor, keeping a constant temperature (or at least between two values).

In any way, the arduino can control pretty much anything as long as you wire it correctly, in your case it would be with a relay or a mosfet, if the load is small enough.

Thank you for your responses.

My original code was a bang-bang controller for temperature. Far from a PID but worked well enough inside the acceptable criteria boundaries of the project. Now the system needs the temperature controller with the additional capability of doing the temperature ladder upon a user input. So far I have the "resting" controller running continuously until a button is pushed. This starts the same bang-bang controller but calls on a higher set-point causing the system to heat up and maintain that temperature instead of the resting temperature.

The biggest issue is then starting a timer once that set-point has been reached so that once the time is up, the loop then moves to the next loop that has the next set-point and so on until the ladder has been complete, then bails out to the resting state controller.

I will update as I fiddle with my code more.

prs:
The biggest issue is then starting a timer once that set-point has been reached so that once the time is up, the loop then moves to the next loop that has the next set-point and so on until the ladder has been complete, then bails out to the resting state controller.

Sounds like textbook application of blink-without-delay techniques.

If you want to use Arduino to do this then Dr. Azzy has it right, start with the BlinkWithoutDelay (aka Do-Many-Things-At-Once) technique.

In your loop() you should have parts in your code that:

  1. runs the bang-bang ALWAYS getting&keeping temperature to the value set in a variable

  2. runs a button handler -- maybe for stop as well as start?

  3. runs the timed ladder on signal from the button handler (flag value in a variable)
    --- this will change the bang-bang temperature variable from time to time
    --- this is probably best done as a state machine but resist hard the temptation to put the whole sketch in the state machine.

Keep the parts separate, all inside loop() but NONE inside of any other, they need to run independently.

If you add a part 4 that adds 1 to an unsigned long counter and once a second prints that out then zeros the counter you will have a measure of how often the sketch updates ALL of the tasks. With decent non-blocking code it will be > 10K, enough for the bang-bang to work?

Somethiing like this? (untested).
Leo…

const byte buttonPin = 2; // sequence start button between pin D2 and ground
boolean ladder = 0; // normal or temp ladder condition
unsigned long currentMillis, startLadder, interval_1 = 600000, interval_2 = 600000; // timings

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  if (!digitalRead(buttonPin) && !ladder) { // if button is pressed during normal 23C condition
    ladder = HIGH; // remember that button was pressed
    startLadder = millis(); // remember the start time
  }
  if (ladder) { // if ladder sequence has been activated
    currentMillis = millis(); // get the current time
    if (currentMillis < startLadder + interval_1) // if less than 10 minutes
    {
      // maintain 30C here
    }
    else
    {
      // maintain 40C here
    }
    if (currentMillis > interval_1 + interval_2) // if both times have passed
    {
      ladder = 0; // stop the sequence
    }
  }
  else // if ladder sequence is not active
  {
    // maintain 23C here
  }
}

That's not what I wrote. It should do the job anyway with some work getting temperature control into a function.

Hi All,

Thank you for the replies. As an update, I got a code to work and I am currently running tests to optimize it.