Electric brew kettle controller

Hi
This is my first post here. I've been lurking around a year or so but havent posted anything before now. I have a little project going on and was hoping someone could help me with the code. I dont have much experience with programming but has copy and pasted some sketches and got some LED's to blink :slight_smile:
Last year I made a magnetic stirrer with an Arduino, a old pc fan, a potmeter and some neodymium magnets. It was simple enough since I found the code and just had to upload it :slight_smile:
Anyway.... I'm in the process of building a new an bigger electric brewing kettle. The one I've got has a 4500w heating element, a SSR and a Auber PID to controll it. I put the PID in manual mode, set the cycle time to 2-3 sec and adjust how many % off the cycle time the element should be on. I also run the wires for the SSR throug a relay so I easely can switch of the element in case of boilover. Its working very well and want something similar with my new kettle. Since I have a couple of RBBB Arduinos I want to use one for this instead of buying a new PID.
What I want to do is connect a 40A SSR to a Arduino and controll the percentage of the cycle that the output is high vs low with a potmeter. It would also bee cool to connect a LCD to display the percent I have set it to. Is this doable? Have someone done something similar? I've been googling without finding what I need.
Can someone help me with this?

Trond

megatrond:
What I want to do is connect a 40A SSR to a Arduino and controll the percentage of the cycle that the output is high vs low with a potmeter. It would also bee cool to connect a LCD to display the percent I have set it to. Is this doable? Have someone done something similar? I've been googling without finding what I need.

OK, in the Playground there are some libraries and other information on using PID in an Arduino sketch. I'm guessing you didn't try searching there, because otherwise you probably would have seen this link to a 5 page blog post about a using PID on an Arduino to control a heater. :stuck_out_tongue: You'll find some more helpful links mentioned in the blog as well.

Thanks Far-seeker
I think that is a bit to complicatet for my needs. What I need is a PWM signal on one pin with a 2 sec period and the abillity to change the duty cycle with a potmeter. I found this in the playground but dont know how to write the code for what I want.

/*
 *  Timer1 library example
 *  June 2008 | jesse dot tane at gmail dot com
 */
 
#include "TimerOne.h"
 
void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(500000);         // initialize timer1, and set a 1/2 second period
  Timer1.pwm(9, 512);                // setup pwm on pin 9, 50% duty cycle
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
}
 
void callback()
{
  digitalWrite(10, digitalRead(10) ^ 1);
}
 
void loop()
{
  // your program here...
}

Can someone help me write the code for what I want to do?

After a couple of hours googling and trying and failing it seems like I did something right :slight_smile: I havent tried it with a SSR, only a LED but it works like I want. I have set the Period to 2,5 sec and adjust the duty cycle with a potmeter. The code is probably awful so I hope someone can comment and give me some tips.... :slight_smile:

The values I get from analogread is pretty unstable so to get full output when the pot is turned to max I included a if statement.

#include "TimerOne.h"

int sensorPin   = 0;
int sensorValue =  0;
//int Cycle =  0;
int Val = 0;
int SSRval = 0;

 
void setup()
{
  pinMode(10, OUTPUT);
  Timer1.initialize(2500000);         // initialize timer1, and set a 2,5 second period
  Timer1.pwm(9, 0);                   // setup pwm on pin 9, duty cycle = 0
  Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
  Serial.begin(9600);
}
 
void callback()
{
  digitalWrite(10, digitalRead(10) ^ 1);
  
}
 
void loop()
{
  Val = analogRead(sensorPin);
    if (Val >= 1010) {
      SSRval = 1024;
    }
        
    else {
      SSRval = Val;
    }
    
                                        
     Timer1.setPwmDuty(9, SSRval);
     Serial.println(SSRval);                                        
  delay(1000);
  
}