heat and cool with programmable profiles.

Hello all. I am looking at building a chocolate tempering machine and the arduino looks like the perfect tool for controlling it. basically it needs to heat the chocolate to about 50 degrees Celsius hold for a set amount of time then drop the temp down to something like 28 degrees hold for a minute or so then warm up to 31 degrees or so. all of these temps need to be made into a program so that i can click a button and walk away and the machine will cycle through the program on its own. I am new to the whole arduino thing but am pretty handy with electronics although i have done very little in the way of programming. Any help or guidance would be very appreciated.

This is fairly easy to do depending on your heating element. So a few questions about your heating element: -At what voltage does it operate. -Is there any way to control it using logic level voltage (5V). -How much variance can you tolerate in time and temperature. -Do you want your temperature to step (very sharp temperature change), or ramp, (very smooth temperature change slope). -Will you be actively cooling or only applying heat and removing heat. -Do you want any sort of display.

Depending on your heating element you can either control it directly from the arduino, or have the arduino control a relay that powers the device. You'll also need a temperature sensor and a button, and all the rest of the supporting electronics.

Thanks for the reply. For the heat i am thinking along the lines of forced hot air that will blow onto the metal drum containing the chocolate. something like a 230v heatgun. the time it takes to heat up is not a major concern as long as it all melts. the temperatures need to change pretty quick so the whole cycle takes less than an hour. for cooloing i thinking of eather a peltier with a fan also blowing on the drum or a smal A/C unit. yes a display would be needed to show the preset program current temp and target temp etc.

Ok for the display you can probably use a 16x2 lcd screen to display the temp and target temp. Search google for something that will work for you "arduino 16x2 lcd" There are lots of discussions about switching 240v so I will link to one here http://arduino.cc/forum/index.php/topic,11502.0.html certainly search google for more information on the subject "arduino 240v relay". You should be able to use one relay for the heating and one relay for the cooling.

For more info on PID go here http://playground.arduino.cc/Code/PIDLibrary

As always with high voltages, be safe, don't kill yourself.

For more info on PID go here http://playground.arduino.cc/Code/PIDLibrary

Or if you like your logic fuzzy, have a look here

basically it needs to heat the chocolate to about 50 degrees Celsius hold for a set amount of time then drop the temp down to something like 28 degrees hold for a minute or so then warm up to 31 degrees or so.

I do not know how to make chocolate, but I am guessing if room temperature too close to 28 degrees, the time to drop to 28 degrees might take too long. Thermoelectric effect device (cooling element might help )

JimboZA: Or if you like your logic fuzzy, have a look here

bookmarked, and thank you.

thanks guys. sonnyyu i know it would take ages and also would not temper thats why it will have a small air conditioner or peltier to drop the temp faster.

So what parts would i be looking at ? 1 anduino board 2 2 X ssrs ? 3 waterproof sensor to read chocolate temperature 4 display and buttons for control

http://brewpi.com/ this guy has made a unit that will raise, lower and hold temperatures of fermenting beer in much the same way as what i want but his setup just looks too complicated... do i need to have a custom shield or can i do this of a standard board ?

just one more thought, how about water with ice as cooler, as long as there is ice in water, the temp will be lock in 0 degrees Celsius. plus water heat exchange will be very efficiency. now we need pumper, say the one from fish tank?

aussietrev: 3 waterproof sensor to read chocolate temperature

Food & Beverage Industry need sensor has food grade. I mean eatable.

I had thought about the water cooling but it looks like it will be even more hastle. the bowl that the chocolate sits in rotates so it make having a water jacket kinda hard. and i worried about the over shooting the temp. i need very accurate temp control otherwise the system wont work.

this is pretty much what i want to build

But the problem with there machice is it just has a fan for cooling, so i will use a faster cooling setup

ok so i just ordered my parts.

Arduino uno LCD keypad shield 2 channel relay board ds18b20 temperature sensor.

should all get to me on friday i hope if anyone can point me int he direction of some code that can get me started i would be very grateful as i have no programming or arduino experience.

Start here to get your temp sensor to give you data
It also indicates that you’ll need some resistors, and I’d suggest your get a pack of them similar to this, and you might as well get the capacitor pack too.
Once you get the temp sensor working then get the LCD to display the temperature from the LCD. Depending on the LCD that you have this example may work, otherwise find an example that is compatible with the LCD that you have.

Also note that your temp sensor may not be food grade, so you’ll need to contain the sensor in something that is.

While you're waiting for parts, take a look at the blink without delay example sketch. You're going to need to read the temperature frequently and keep track of elapsed time. The example shows you how to use millis() to do this. Steer clear of delay() except for short debouncing intervals. Be aware that that example takes a while to get your head around the first time you see it.

Ok so i got all the stuff and having playing around with some code. I can get a temperature display on the computer, i can get the lcd to work and have tried out some example scetchs without any problems. but..... I have hit a wall with how i combine code. How I make the PID program work with the screen, the temperature sensor and make that all work with a menu and add preset programs to that. I feel a little overwhelmed and I think i am just missing some direction.

You’ll want to just start out simple and gradually add more complexity. First start by just getting the temperature to a single steady state point. In the example below that is 50C.

You’ll also need to tune the PID values, in the example they are 2,5,1. You can use a method similar to this to tune the PID values.

You’ll want to display the desired temperature, and the temperature sensor reading at the same time.

#include <PID_v1.h>
#define RelayPin 6

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

int WindowSize = 5000;
unsigned long windowStartTime;
void setup()
  windowStartTime = millis();

  //initialize the variables we're linked to
  Setpoint = 50;  //Our set point will be 50C

  //tell the PID to range between 0 and the full window size
  myPID.SetOutputLimits(0, WindowSize);

  //turn the PID on

void loop()
  Input = analogRead(0);  //read the temperature sensor
  myPID.Compute(); //compute the PWM signal to send

   * turn the output pin on/off based on pid output
  unsigned long now = millis();
  if(now - windowStartTime>WindowSize)
  { //time to shift the Relay Window
    windowStartTime += WindowSize;
  if(Output > now - windowStartTime){

Rather than attacking the whole problem, try a bit of bottom up. Build the minimum system you can that actually does something. Since you've got the thermometer reporting, turn on the heater and report the temps through serial or on the LCD. After 5 mins, turn on the cooling instead and track the temps. Then add the PID, etc.

You'll probably have to refactor stuff later, but you can get some building blocks that will make the full problem less daunting. Try to put the functionality you build into distinct functions rather than jaming all you code in loop. It'll hopefully make it easier to reuse/refactor.

ok. after a week of playing around I have found code for a dual tempreature controller that i have treaked and it heats or cools based on the desired temperature. But it does not use PID algorithems so its not as precise as I would like it to be and has nothing about adding profiles.
So can I " add " the PID code into my current sketch ?
How can I implement temperature profiles ?

Post your code and we can take a look at whether PID is possible. Your temperature profile will be either a 2-dimensional array, or 2 arrays for holding a temperature value and a time value. So the ideas will go something like this:

unsigned long startMillis = 0;
double[] temps={70,100,90,70};
long[] times={0,5000,10000,20000};

void setup(){
  startMillis = millis();
  temps[0] = readTempValue(); //more accurate to make temp at time zero equal to reading at time zero;

void loop(){
  double desiredTemp = calculateDesiredTemperature();
  double currentTemp = readTempValue();

double calculateDesiredTemperature(){
  deltaTime = millis()-startMillis;
  int index = -1;
  for(int i = 0;i<4;i++){
      index = i;
  //Make sure that you found a time greater than the current time otherwise profile is done
  //Also make sure that times[index - 1] won't throw an exception
    double ratio = ((double)(deltaTime-times[index - 1]))/((double)(times[index]-times[index - 1]));
    return (temps[index - 1] + ratio*(temps[index] - temps[index - 1]));
    return -274.0; //colder than absolute zero means no value calculated;

-How much time has passed since this profile has started
-Look up the deltaT in your time array, and interpolate as necessary
-Use the same interpolation to get the desired temperature from your temperature array
-Pass the current Temperature reading and your desire reading to the function which controls the heating and cooling.

okhere is the file becasue the code was to big to fit on the forum. I did not write the code at all, I just modded it a little to suit my needs.
I know this is a bit of a mess and it does heat and cool like i want it to but its not acurate. instead of holding a set temp with PID control it is turning on and off heating and cooling to balance.

Chocolate_temperer.ino (19.8 KB)