The block diagram:
The plan explained in the first blog was to use 4 thermal switches for more controlled and reliable sensing. The experimental setup uses 2 thermal switches instead of 4, since the outcome is the same.
Developing the logic:
There are 4 possible combinations that can be achieved using the 2 thermal switches TS1 and TS2. The decision based on these 4 combinations would be meaningless since the current state transitions of TS1 and TS2 are independent of each other. Hence, the previous state of the switches is also to be considered to ensure smoother transition between various levels of brightness.
Arduino code:
#include <elapsedMillis.h>
elapsedMillis timer;
elapsedMillis timer1;
elapsedMillis timer2;
elapsedMillis timer3;
#define ledPin1 3
#define ledPin2 9
#define thermal1 4
#define thermal2 5
byte y=255;
bool from10=0;
bool from11=0;
bool from01=0;
byte dly=5000; // state transition time
byte stand=20;
void setup()
{
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(ledPin1,OUTPUT);
pinMode(ledPin2,OUTPUT);
}
void loop()
{
if(digitalRead(thermal1)== 0 && digitalRead(thermal2)== 0)
{ delay(10);
if(digitalRead(thermal1)== 0 && digitalRead(thermal2)== 0)
{if( (from10 == 1 || from11 == 1) && y!=255)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>= dly)
{y++;timer=0;}
}
else if(from01==1 && y!=255)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>=dly)
{y--;timer=-0;}
}
else
{from10 =0;from11=0; from01=0;
analogWrite(ledPin1,255);
analogWrite(ledPin2,0);
}
timer2=0;
}
}
//*************************************************************************************
else if(digitalRead(thermal1)== 1 && digitalRead(thermal2)== 0)
{delay(10);
if(digitalRead(thermal1)== 1 && digitalRead(thermal2)== 0)
{if(timer2>dly)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>=dly && y!=stand)
{y--; timer=0;}
from10=1;
from01=0;
from11=0;
}
timer3=0;
}
}
//*************************************************************************************
else if(digitalRead(thermal1)== 0 && digitalRead(thermal2)== 1)
{delay(10);
if(digitalRead(thermal1)== 0 && digitalRead(thermal2)== 1)
{if(timer1>dly)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>= dly && (255-y)!=stand)
{y++; timer=0;}
from01 = 1;
from11=0;
from10=0;
}
timer2=0;
timer3=0;
}
}
//*************************************************************************************
else if(digitalRead(thermal1)==1 && digitalRead(thermal2)==1)
{ delay(10);
if(digitalRead(thermal1)==1 && digitalRead(thermal2)==1)
{if(timer3>dly)
{ if(from10==1 && y!=125)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>dly)
{y++;timer=0;}
}
else if(from01==1 && y!=125)
{analogWrite(ledPin1,y);
analogWrite(ledPin2,255-y);
if(timer>dly)
{y--;timer=0;}
}
else
{from10=0; from01 = 0;
analogWrite(ledPin1,125);
analogWrite(ledPin1,125);
}
from11 = 1;
timer2=0;
}
}
}
}
Different states of brightness:
The picture1(top left corner) shows the initial brightness level. After entering the subsequent states of the logic, it returns back to the initial state only if both the thermal switches go below the 40°C mark.
The reason for maintaining a 40-100% brightness level after crossing the initial state is to reduce the thermal expansion and contraction effects on the LED filaments (as mentioned by Gough Lui in my blog1 comment). This aspect is also taken care of by the software where the brightness level changes gradually depending on the set timer value.
A 0-100% brightness level and a 40-100% / 100-40% brightness level both have the same light output with only subtle difference, which when used in a larger space would have negligible impact.
Mounting the Thermal Switch:
The OHD1-50B type KEMET thermal switch was mounted on to the backside of the heatsink. The switches were accurate and the cutoff temperature recorded was around 49°C.
The final output:
The circuit installation was done on the workbench and the change in light intensity was recorded. A video clip focusing the light bulbs is included along with a video of a user-perspective view of the light intensity change over the workbench. The transition time of the LEDs had to be reduced to 200ms and further the video had to be played at 2x speed for the light intensity change to be noticeable. So, it is understood that, on normal circumstances, the change in light intensity is unnoticeable.
In the video, the light intensity change can be observed by noticing the difference in the shadow cast by the wire at various instances of the clipping.
Conclusion:
KEMET Thermal switches are useful for a variety of switching applications. They are accurate and a long-lasting solution as they have reduced metal fatigue due to no metal expansion. However, the downside could be the power rating. While their bimetallic counter parts have higher ratings, these reed switches have a maximum power rating of 75W, which in most cases can be a bit less considering a direct series connection with the device’s mains input.
Top Comments