PID Control of a Heating Element Using an AC Dimmer

Hello Everyone, I'm caught in a rut of knowing what I want to do in concept, but have been unable to find the necessary tutorials/coding to get started on making this work.

From a Hardware perspective I have a 1500 watt AC 120V Heating element. I'm trying to use this to keep a pot of liquid at a set point for a given amount of time. I have tried using a relay and on off control, however i'm not getting the temp control I want. +/- 2 degrees.

Therefore I bought a dimmer board from research design labs https://researchdesignlab.com/modules/dimmer-module/serial-3-channel-ac-230v-ssr-and-dimmer.html

The goal is to use this dimmer with my adruino mega to implement PID control of the heating element. My thought is keeping the element on a varying levels of wattage vrs on/off should yield tighter control. I understand how PID works, and believe i can code that based on other examples I have read.

The issue I have is how to convert the PID portion of the programs output to the serial output of a pin to make the dimmer function. I don't have experience with coding serial communications, and there seems to be a lack of examples of how to use these boards.

I looked at the ones posted on the website I purchased this from and the connection/coding doesn't make sense.

Can anyone point me in a direction of where to start, or how to get this dimmer working in a simple sense then go from there.

Thank you in advanced.

Can anyone point me in a direction of where to start, or how to get this dimmer working in a simple sense then go from there.

The web page you linked offers Arduino code to control the dimmer, which certainly could be a good place to start.

It might be easier to just switch the heater on/off under PID control - e.g. using mark/space switching .( so for example , a long way from setpoint heater is on most of the time, but closer in , say only on for one second in 10)

Using a dimmer will probably introduce another level of non linearity , making loop tuning a bit tricky

hammy:
It might be easier to just switch the heater on/off under PID control - e.g. using mark/space switching .( so for example , a long way from setpoint heater is on most of the time, but closer in , say only on for one second in 10)

Using a dimmer will probably introduce another level of non linearity , making loop tuning a bit tricky

Hammy, just to clarify my understanding are you suggesting to use the PID to control time then rather than wattage output of the burner?

fastrunner08:
Hammy, just to clarify my understanding are you suggesting to use the PID to control time then rather than wattage output of the burner?

It looks like it - that's what you do when you only have the ability to turn your heater on & off. Which would be going back to the use of a relay as you initially did. Were you using PID then?

As noted above, the example code provided looks simple enough - you just need the PID to give you a percentage between 0 and 100 and then use their (slightly convoluted and badly named) convert_display routine to command the dimmer.

Certainly, try the dimmer approach. I disagree with the speculation about nonlinearity above.

1 Like

To date I have only done a simple controller that would more be like a P. aka if reading is > setpoint heater off
if reading is < setpoint heater on.

I have not used this dimmer module yet, because I have never coded something using the serial TX RX connections before, and i'm not quite sure how that works.

I would love to try the dimmer option, but does anyone have some advice on where i can look/learn how to do the TX RX. Reading the example code doesn't necessarily tell me what exactly it is doing to turn the dimmer on/off or rate.

Looks like you would connect RX on dimmer board to TX on Arduino and vice versa, if you can get it to work with the example code, it shouldn't be too hard to add in PID.

/*
 * Project name:
     3 channel serial Dimmer
 * Copyright
     (c) Researchdesignlab.com
 * Description:
    
 * Test configuration:
     MCU:             ATMEGA328
     Dev.Board:       Arduino uno
     Oscillator:      16 MHz
     Software:        Arduino

*/


int s1=8;                  //connect switch1 to pin 2 of arduino
int s2=9;                  //connect switch2 to pin 3 of arduino
int s3=10;                  //connect switch3 to pin 4 of arduino
int s4=11;                 //connect switch4 to pin 5 of arduino
int s5=12;                 //connect switch5 to pin 6 of arduino 
int s6=13;

void setup()
{
  Serial.begin(9600);      // initialize the serial communications
  pinMode(s1,INPUT);
  pinMode(s2,INPUT);
  pinMode(s3,INPUT);
  pinMode(s4,INPUT);
  pinMode(s5,INPUT);
  pinMode(s6,INPUT);
}

void loop()
{
  unsigned char LOAD1=0,LOAD2=0,LOAD3=0; 
   if(s1==LOW)		     
   {
     if(LOAD1<100)
     LOAD1++;
     Serial.write('A');
     CONVERT_DISPLAY(LOAD1);	 
     delay(500);			   
     }
    
    if(s2==LOW)		      
     {
       if(LOAD1>0)
        LOAD1--;
	Serial.write('A');
	CONVERT_DISPLAY(LOAD1);	 
	delay(500);			   
      }
   
   if(s3==LOW)		     
   {
     if(LOAD2<100)
     LOAD2++;
     Serial.write('B');
     CONVERT_DISPLAY(LOAD2);	 
     delay(500);			   
     }
     
     if(s4==LOW)		      
     {
       if(LOAD2>0)
        LOAD2--;
	Serial.write('B');
	CONVERT_DISPLAY(LOAD2);	 
	delay(500);			   
      }
  
  if(s5==LOW)		     
   {
     if(LOAD3<100)
     LOAD3++;
     Serial.write('C');
     CONVERT_DISPLAY(LOAD3);	 
     delay(500);			   
     }
    
     if(s6==LOW)		      
     {
       if(LOAD3>0)
        LOAD3--;
	Serial.write('C');
	CONVERT_DISPLAY(LOAD3);	 
	delay(500);			   
      }
}
  
  
void CONVERT_DISPLAY(unsigned int d)
{
   unsigned char dig1,dig2,dig3,dig[3];
   unsigned char x;
   unsigned char temp;
   temp=d;
   temp=temp/10;
   dig1=d%10;
   dig2=temp%10;
   dig3=temp/10;
        
        dig[0]=dig3;
	dig[1]=dig2;
	dig[2]=dig1;

	for(x=0;x<3;x++)
	{
           temp=dig[x]|0x30;
           Serial.write(temp);		
    }										
}

Reading the example code doesn't necessarily tell me what exactly it is doing to turn the dimmer on/off or rate.

Your best source of advice is the product data sheet or user manual.

See also reply #4, which explains what you need to do.

So in that code what is actually taking place? I guess that is what i'm trying to understand.

Serial.Write('A'); is telling it to apply the next line of code to the A channel on the board or the first output?

Then what does Convert_display command actually do?

I guess those are the things i'm trying to understand. I'm not familiar with serial commands other than the serial.print function.

Would someone who understands that code be willing to write in what each line is actually doing for this portion in laymen's terms?

if(LOAD1<100) aka // checks to see if the first load has a value of less than 100
LOAD1++; // ????
Serial.write('A'); //????
CONVERT_DISPLAY(LOAD1); //?????
delay(500); // delays the next line of code for 500 mili sec.
}

It looks as though the device expects to be told over serial what channel should be set to what percentage dimming. The percentage should have leading zeroes so it's always three characters. So to set channel B to 77% it wants to see:

B077

CONVERT_DISPLAY is their function that sends the number part. Try this - you can see what it does:

boolean newData = false;

void setup() {
  Serial.begin(115200);
  Serial.println("<Arduino is ready>");
  for(int i=0;i<105;i++)
    {
    CONVERT_DISPLAY(i);
    Serial.println("");
    }
}

void loop() 
{
}

void CONVERT_DISPLAY(unsigned int d)
{
   unsigned char dig1,dig2,dig3,dig[3];
   unsigned char x;
   unsigned char temp;
   temp=d;
   temp=temp/10;
   dig1=d%10;
   dig2=temp%10;
   dig3=temp/10;
        
        dig[0]=dig3;
  dig[1]=dig2;
  dig[2]=dig1;

  for(x=0;x<3;x++)
  {
           temp=dig[x]|0x30;
           Serial.write(temp);    
    }                   
}

You should reconsider your selection of a dimmer board, you're overloading the one you've linked to by about 50% when using a 120 volt supply. Triacs are current based devices and as a result, the board is only good for half the stated load when using half the voltage. That means 1000 watts at 120V or approximately 8 amps which is appropriate for what is probably a 12 amp rated triac.

Edit: looking at the website again, I question if the 2000 watts is the rating for the entire board which means 666 watts per channel. That seems more in line for a TO-220 packaged triac. Regardless, you're overloading the board. I'd be very cautious, you could blow the pc traces off the board at 1500 watts if they are undersized. Molten copper from vaporized pc traces can cause severe burns or worse.

You never stated how you were achieving the temperature control that was insufficient for your needs. Was it simple on-off control?

Do you know how much time your liquid requires to go from room temperature to operating temperature? Once it is at operating temperature, how often and for how long did the relay turn on?

The times mentioned above will determine if you need to resort to phase angle firing control or simple time based pulsed heating control. It all depends upon how much thermal mass you're dealing with.

A small mass is sensitive to heat input and responds quickly, perhaps too quickly for your control system. In that case, you reduce the amount of heat applied.

A large mass requires more heat and the temperature rises slowly, needing a bigger heater and more time.

avr_fred:
You should reconsider your selection of a dimmer board, you're overloading the one you've linked to by about 50% when using a 120 volt supply. Triacs are current based devices and as a result, the board is only good for half the stated load when using half the voltage. That means 1000 watts at 120V or approximately 8 amps which is appropriate for what is probably a 12 amp rated triac.

Edit: looking at the website again, I question if the 2000 watts is the rating for the entire board which means 666 watts per channel. That seems more in line for a TO-220 packaged triac. Regardless, you're overloading the board. I'd be very cautious, you could blow the pc traces off the board at 1500 watts if they are undersized. Molten copper from vaporized pc traces can cause severe burns or worse.

You never stated how you were achieving the temperature control that was insufficient for your needs. Was it simple on-off control?

Do you know how much time your liquid requires to go from room temperature to operating temperature? Once it is at operating temperature, how often and for how long did the relay turn on?

The times mentioned above will determine if you need to resort to phase angle firing control or simple time based pulsed heating control. It all depends upon how much thermal mass you're dealing with.

A small mass is sensitive to heat input and responds quickly, perhaps too quickly for your control system. In that case, you reduce the amount of heat applied.

A large mass requires more heat and the temperature rises slowly, needing a bigger heater and more time.

Good to know, I guess i wasn't considering it meant current for all 3 outputs. Essentially, i'm heating 2500ml to 3500ml of water.

Before I used a simple relay board for AC current and an on/off style controller.

I'm using the Mega to control a series of pumps, E-valves, and then heating the fluid in the main tank as well.

I was hoping to control current to the heating element to regulate temperature more smoothly vrs. On/Off.

I'm working with some temperature sensitive enzymes, and keeping the element at full current as it tends to over heat the boundary layer.

From my perspective, that’s a very high watt density for that amount of liquid. Lowering the watt density/raising the surface area of the heater may be a simpler and more successful approach. But, there are lots of unknowns for example: allowable heat up time, max delta T, if it’s being stirred/agitated to name a few.

You’ll only get so far with phase angle/dimmer control since the heater surface temperature isn’t going to be linear with applied voltage. At some point, you’ll reach the maximum interface temperature the material can withstand, that may only be 20 or 30%. It is very difficult to predict when you don’t know all the thermal interfaces involved - which is why you get just general guidelines for industrial immersion heaters. This my only exposure here, industrial, no lab experience.

It’s certainly worth trying but know the method will have limitations, the most important right now being the maximum load the board you’ve selected can handle.