DIY: Cree CXA Arduino Thermal Monitoring & Protection.

stardustsailor

Well-Known Member
I'm saving this page for future reference.Thank you very much for the write up! I'll have to read through it in detail later. A little strapped for time at the moment.

How many emitters could an arduino mega monitor? With the UNO, is there any more overhead for other sensors/relays?

Thanks for the tutorial. I'm going to be incorporating automation into my designs as well :)
I never have used mega ...
Yes ...All the digital I/Os are free except pin 5 (the SSR's signal output ) ...
Each thermistor needs one ANALOG input ..
 

stardustsailor

Well-Known Member
I was temp Controlling once with ardu, i found switching stuff with this very convinient:
http://www.ebay.com/itm/5V-Eight-8-Channel-Relay-Module-With-optocoupler-For-PIC-AVR-DSP-ARM-Arduino-/191114725447?pt=LH_DefaultDomain_0&hash=item2c7f534847

like 1$ per opto controlled relay
plug and play
Awesome ! Can it really deliver 10A ?
Or is total load amperage ?
Anyway ...
It seems more than enough and way cheap for it's features !
Yes,I think that this is a great relay solution for the present project ..
Much thanx for the contribution !
:weed:
 

lax123

Well-Known Member
yea that mega, not just 16 CXA...one thingy can control loads of stuff...
and also with "easy" plug and play stuff like this: http://www.ebay.com/itm/Keypad-Shield-1602-LCD-For-Arduino-MEGA-2560-1280-UNO-R3-MEGA2560-MEGA1280-/171058768559?pt=LH_DefaultDomain_0&hash=item27d3e5aaaf
I built a menu with this, works fine (up, down, select, back, menu section/tree entries). You can then easily add things like , "Fan Speed Settings", "Temp Thresholds", Lighting-Schedule etc,

I mean complete DIY is great, but i think this is perfect for experimenting

Awesome ! Can it really deliver 10A ?
Its a relay. Or i didnt get what you were saying
 
Last edited:

stardustsailor

Well-Known Member
Yes,I'm sorry ,I meant ,if can it really operate continuously under such load (10 amps are 10 amps ! ) ..
Anyway ...
Great finds ,there !

No time for experimenting with electronics and programming mc's ...
Experimenting goes all to leds and plants,right now ...

Engineering,3D designing,electronics,machining ,etc are just ...side-something of the
whole ...'art' of the DIY led growing illumination...
Nobody said that's simple ...
But is one of the most fascinating things ,aside from growing and enjoying your ..flowers ,of course ...

I'm interested on your project...
Sounds really interesting ...
I could use one like that,for sure ...
Handy ,enough ...
 

Positivity

Well-Known Member
I can see cleearly nooow the rain is gonnne..

Not! Wow...that's awesome how you all can work with these things. I always thought I was pretty good with computers but this is crazy cool and beyond me..lol

Be interesting if you ran a 3070 at max rated current. Then along with a lumen or par meter find the exact sweet spot/spots of the particular led..omg..I'd be in DIY heaven being able to do stuff like that
 

stardustsailor

Well-Known Member
Case temperature monitoring+active protection + ...fan control ...


Well this is a 'Beta-Code " ..
I haven't had the chance to test it ...
But this is what I'm going to use(most probably ) in my new CXA3070 light ..

Another digital pin is used now ....
For controlling the fans ...

Arduino will adjust the power level(speed ) of fans ,depending on the case temperature of the chips ...
It will constantly monitor the TC of the 6 chips and lower(to save energy ) or increase (to cool the chips )...

It starts at a min TC of 25 C with a Duty Cycle of 37.5% and adjusts up to 75C .
From Tc=75C and up fans will operate at 100% DUTY cycle (overdriven at 14 -15 Volts )...
At Tc=90C ,led drivers switch off-along the CXAs -,fans will still operate ..

Arduino controls the Fans with "raw" pwm signal ,at 25 kHz (25000 Hz ) frequency,
outside of the audible range .
So the fans do not make any weird whistling or hissing noises ...
And with a higher operating voltage than the nominal of the fans...
-For 12 V fans : Vp-p = 13.5-14.5 VDC
-For 24 V fans : Vp-p = 25.5-26.5 VDC

Pin 9 is used as Fan output ...
(Yes it needs an output circuit ..Later on ..I've to sleep also... )
It won't work with all PC case fans ,but with the ~90% of them ...
4 wire fans can be driven directly ,this way ,without anyb added circuitry .
3 wire fan will not give back correct tach pulses (yellow wire ) .
Some fans might not work at all .. (A small number ,really ) ..
Service/operational life of the fan can/ might decrease up to 50% in some cases ,but most common figure is around 10-20% .
Lower Duty /Fan Power cycles less than ~30% are not suggested ,due to immense fan coil electrical ,thermal and mechanical "fatigue",at low speeds ...
And they do no offer any cooling really at that power levels ...( <30% )

Fans are controlled with 11 power level steps ("speeds"),from 37.5% min to 100% max.
It might need further calibration ,depending on the particular fan(s) and heatsinks used ,etc...

Default settings :
-PWM Freq : 25 kHz ( 40 usec period )
-Min Fan Power : 37.5 % @25°C
-Max Fan Power :100% @> 75°C
-Half Fan Power /50% duty cycle : @ 35-39° C range
-Power Aver. Ramp* : +/- 1.25% / °C ( * Δ Power min-max / ΔTthres-limit : 62.5% / 50°C )
-Ramp Step : +/- 6.25% , ΔΤrang 5 °C

Libraries needed : TimerOne.h

The code :

//LIB.
#include <math.h>
#include <TimerOne.h>
//Pins
#define SSR_PIN 5
#define FAN_PIN 9
#define SENSOR30A_PIN A0
#define SENSOR30B_PIN A1
#define SENSOR50A_PIN A2
#define SENSOR50B_PIN A3
#define SENSOR27A_PIN A4
#define SENSOR27B_PIN A5
//VAR
#define THR_NOM_RES 10000
#define TEMP_NOM 25
#define AI 0.003353832
#define B1 0.0002569355
#define C1 0.000002626311
#define D1 0.000000675278
#define SAMPLE 5
#define SER_RES_30A 9930
#define SER_RES_30B 10000
#define SER_RES_50A 10000
#define SER_RES_50B 10000
#define SER_RES_27A 10000
#define SER_RES_27B 10000
//INT
int samples30A[SAMPLE];
int samples30B[SAMPLE];
int samples50A[SAMPLE];
int samples50B[SAMPLE];
int samples27A[SAMPLE];
int samples27B[SAMPLE];
//SET UP
void setup()
{
//analogReference(EXTERNAL); //activate for shield
pinMode( SSR_PIN,OUTPUT );
digitalWrite(SSR_PIN,LOW);
pinMode (FAN_PIN,OUTPUT );
Timer1.initialize(40);
Timer1.pwm(FAN_PIN, 768,40);
pinMode (SENSOR30A_PIN,INPUT);
pinMode (SENSOR30B_PIN,INPUT);
pinMode (SENSOR50A_PIN,INPUT);
pinMode (SENSOR50B_PIN,INPUT);
pinMode (SENSOR27A_PIN,INPUT);
pinMode (SENSOR27B_PIN,INPUT);
}
void loop()
{
uint8_t i;
float average30A;
float average30B;
float average50A;
float average50B;
float average27A;
float average27B;
for (i=0; i< SAMPLE; i++)
{
samples30A = analogRead(SENSOR30A_PIN);
samples30B = analogRead(SENSOR30B_PIN);
samples50A = analogRead(SENSOR50A_PIN);
samples50B = analogRead(SENSOR50B_PIN);
samples27A = analogRead(SENSOR27A_PIN);
samples27B = analogRead(SENSOR27B_PIN);
delay(10);
}
average30A=0;
average30B=0;
average50A=0;
average50B=0;
average27A=0;
average27B=0;
for (i=0; i< SAMPLE; i++)
{
average30A += samples30A;
average30B += samples30B;
average50A += samples50A;
average50B += samples50B;
average27A += samples27A;
average27B += samples27B;
}
average30A /= SAMPLE;
average30B /= SAMPLE;
average50A /= SAMPLE;
average50B /= SAMPLE;
average27A /= SAMPLE;
average27B /= SAMPLE;
//
average30A = 1023 / average30A - 1;
average30A = SER_RES_30A / average30A;
//
average30B = 1023 / average30B - 1;
average30B = SER_RES_30B / average30B;
//
average50A = 1023 / average50A - 1;
average50A = SER_RES_50A / average50A;
//
average50B = 1023 / average50B - 1;
average50B = SER_RES_50B / average50B;
//
average27A = 1023 / average27A - 1;
average27A = SER_RES_27A / average27A;
//
average27B = 1023 / average27B - 1;
average27B = SER_RES_27B / average27B;
//
float TC30A;
TC30A = average30A / THR_NOM_RES;
TC30A = log(TC30A);
TC30A =1/(AI+(B1*TC30A)+(C1*TC30A*TC30A)+(D1*TC30A*TC30A*TC30A));
TC30A =TC30A- 273.15;
float TC30B;
TC30B = average30B / THR_NOM_RES;
TC30B = log(TC30B);
TC30B =1/(AI+(B1*TC30B)+(C1*TC30B*TC30B)+(D1*TC30B*TC30B*TC30B));
TC30B =TC30B- 273.15;
float TC50A;
TC50A = average50A / THR_NOM_RES;
TC50A = log(TC50A);
TC50A =1/(AI+(B1*TC50A)+(C1*TC50A*TC50A)+(D1*TC50A*TC50A*TC50A));
TC50A =TC50A- 273.15;
float TC50B;
TC50B = average50B / THR_NOM_RES;
TC50B = log(TC50B);
TC50B =1/(AI+(B1*TC50B)+(C1*TC50B*TC50B)+(D1*TC50B*TC50B*TC50B));
TC50B =TC50B- 273.15;
float TC27A;
TC27A = average27A / THR_NOM_RES;
TC27A = log(TC27A);
TC27A =1/(AI+(B1*TC27A)+(C1*TC27A*TC27A)+(D1*TC27A*TC27A*TC27A));
TC27A =TC27A- 273.15;
float TC27B;
TC27B = average27B / THR_NOM_RES;
TC27B = log(TC27B);
TC27B =1/(AI+(B1*TC27B)+(C1*TC27B*TC27B)+(D1*TC27B*TC27B*TC27B));
TC27B =TC27B- 273.15;

//THERMAL PROTECTION RULES
if ( ( TC30A || TC30B ||TC50A || TC50B || TC27A ||TC27B ) >= 90)
{
digitalWrite(SSR_PIN,HIGH);
}
else
if ( (TC30A && TC30B &&TC50A && TC50B && TC27A && TC27B) < 90)
{
digitalWrite(SSR_PIN,LOW);
}
//FAN CONTROL RULES
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )>= 25 &&( TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=29)
{
Timer1.setPwmDuty(FAN_PIN, 384 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )>= 30 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )<=34)
{
Timer1.setPwmDuty(FAN_PIN, 448 );
}
else
if (( TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 35 &&( TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=39)
{
Timer1.setPwmDuty(FAN_PIN, 512 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 40 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )<=44)
{
Timer1.setPwmDuty(FAN_PIN, 576 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 45 &&( TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=49)
{
Timer1.setPwmDuty(FAN_PIN, 640 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 50 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )<=54)
{
Timer1.setPwmDuty(FAN_PIN, 704 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B)>= 55 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=59)
{
Timer1.setPwmDuty(FAN_PIN, 768 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 60 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=64)
{
Timer1.setPwmDuty(FAN_PIN, 832 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )>= 65 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=69)
{
Timer1.setPwmDuty(FAN_PIN, 869 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) >= 70 && (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B) <=74)
{
Timer1.setPwmDuty(FAN_PIN, 960 );
}
else
if ( (TC30A || TC30B || TC50A || TC50B || TC27A || TC27B )>= 75 )
{
Timer1.setPwmDuty(FAN_PIN, 1023 );
}
delay(1000);
}
//END
 
Last edited:

stardustsailor

Well-Known Member
Well the beta code won't work ....

A part of it has to be changed to :

//THERMAL PROTECTION RULES
if ( TC30A >= 90|| TC30B >= 90||TC50A >= 90|| TC50B >= 90|| TC27A >= 90||TC27B >= 90)
{
digitalWrite(SSR_PIN,HIGH);
}
else
if ( TC30A < 90&& TC30B< 90 &&TC50A< 90&& TC50B< 90&& TC27A < 90&&TC27B < 90)
{
digitalWrite(SSR_PIN,LOW);
}
//FAN CONTROL RULES
float TCAVERG;
TCAVERG= ( (TC30A+TC30B+TC50A+TC50B+TC27A+TC27B ) / 6 );

if ( TCAVERG < 25 || TCAVERG >= 25 && TCAVERG < 27.5)
{
Timer1.setPwmDuty(FAN_PIN, 384 );
}
else
if ( TCAVERG >= 27.5 && TCAVERG < 30 )
{
Timer1.setPwmDuty(FAN_PIN, 416 );
}
else
if ( TCAVERG >= 30 && TCAVERG < 32.5 )
{
Timer1.setPwmDuty(FAN_PIN, 448 );
}
else
if ( TCAVERG >= 32.5 && TCAVERG < 35 )
{
Timer1.setPwmDuty(FAN_PIN, 480 );
}
else
if ( TCAVERG >= 35 && TCAVERG < 37.5 )
{
Timer1.setPwmDuty(FAN_PIN, 512 );
}
else
if ( TCAVERG >= 37.5 && TCAVERG < 40 )
{
Timer1.setPwmDuty(FAN_PIN, 544 );
}
else
if ( TCAVERG >= 40 && TCAVERG < 42.5 )
{
Timer1.setPwmDuty(FAN_PIN, 576 );
}
else
if ( TCAVERG >= 42.5 && TCAVERG < 45 )
{
Timer1.setPwmDuty(FAN_PIN, 608 );
}
else
if ( TCAVERG >= 45 && TCAVERG < 47.5 )
{
Timer1.setPwmDuty(FAN_PIN, 640 );
}
else
if ( TCAVERG >= 47.5 && TCAVERG < 50 )
{
Timer1.setPwmDuty(FAN_PIN, 672 );
}
else
if ( TCAVERG >= 50 && TCAVERG < 52.5 )
{
Timer1.setPwmDuty(FAN_PIN, 704 );
}
else
if ( TCAVERG >= 52.5 && TCAVERG < 55 )
{
Timer1.setPwmDuty(FAN_PIN, 736 );
}
else
if ( TCAVERG >= 55 && TCAVERG < 57.5 )
{
Timer1.setPwmDuty(FAN_PIN, 768 );
}
else
if ( TCAVERG >= 57.5 && TCAVERG < 60)
{
Timer1.setPwmDuty(FAN_PIN, 800 );
}
else
if ( TCAVERG >= 60 && TCAVERG < 62.5 )
{
Timer1.setPwmDuty(FAN_PIN, 832 );
}
else
if ( TCAVERG >= 62.5 && TCAVERG < 65 )
{
Timer1.setPwmDuty(FAN_PIN, 864 );
}
else
if ( TCAVERG >= 65 && TCAVERG < 67.5 )
{
Timer1.setPwmDuty(FAN_PIN, 896 );
}
else
if ( TCAVERG >= 67.5 && TCAVERG < 70 )
{
Timer1.setPwmDuty(FAN_PIN, 928 );
}
else
if ( TCAVERG >= 70 && TCAVERG < 72.5 )
{
Timer1.setPwmDuty(FAN_PIN, 960 );
}
else
if ( TCAVERG >= 72.5 && TCAVERG < 75 )
{
Timer1.setPwmDuty(FAN_PIN, 992 );
}
else
if ( TCAVERG >= 75 )
{
Timer1.setPwmDuty(FAN_PIN, 1023 );
}
delay(1000);
}
//END



Now Arduino averages the case temperatures of the six arrays ,and selects
the pwm duty cycle ,thus fan speed ,accordingly.

Steps are doubled to 22 .( 22 different fan speed levels )
( Maximum power levels : 10 bit => 2^10 => 1023 with max analysis 0.0977 % of Duty Cycle,per step )

Default settings :
-PWM Freq : 25 kHz ( 40 usec period ) ( Max setting : 1 MHz => 1 usec period )
-Min Fan Power : 37.5 % @25°C
-Max Fan Power :100% @> 75°C
-Half Fan Power /50% duty cycle : @ 35-37.5° C range
-Power Aver. Ramp* : +/- 1.25% / °C ( * Δ Power min-max / ΔTthres-limit : 62.5% / 50°C )
-Ramp Step : +/- 3.125% , ΔΤrang 2.5 °C
 
Last edited:

stardustsailor

Well-Known Member
1-wire to rule them all...

http://www.maximintegrated.com/datasheet/index.mvp/id/2813
http://www.maximintegrated.com/datasheet/index.mvp/id/2812
http://bildr.org/2011/07/ds18b20-arduino/

And a hint for the if; then; else,else...

Switch (var)
Case 1 //do something
Break;
Case 2
...
...
Default // if all option are bad
Yes,last night it hit me about the Switch(var)
Case x ,if that, break ,case this ,Case y ...etc

Still ,I think its going to work with the averaging Tcs
( arduino was really confused ,with 6 different -constantly changing- Tc s and could not select a proper speed ... )
and all the ifs and elses ...
Anyway ,the way you suggest probably is better ...
Specially if other stuff (routines ) have to start or stop ..
( Along with the use of Interrupts )

I''ll check the links ,now ...
 

stardustsailor

Well-Known Member
FGS Guod!!!!
How on Earth I'm going to install a whole TO-92 package on a CXA chip ,attached with Ideal array holder ,when already is restricted "space" even for a thermocouple's tiny tip ?
........
Yesterday I was checking on that and the Philips tiny thermistors I got ...
I'm going to have some trouble there ,I'm sure ...
But ,I know ...I'll manage to do it ,at the end !! :cool:
LOL !


Thanx ,anyway ..
Good to know ,about those 1-wire temperature sensng ICs from Maxim ...

Edit: It has to be something really small of a sensor ...
Most common options are a) Thermocouples b) Thermistors/Silistors ..
c) IR heat sensing small photodiodes ?????
 
Last edited:

stardustsailor

Well-Known Member
And all that ,because my 555/mosfet pwm fan control circuit ,that i've made on pcb ,keeps
frying up the 555 timer ( @15 VDC ) and the pot !

I'm not sure what is going wrong ...

So Arduino will 'clean' the mess ,once more !
It will control the fans ,too...
...
Easy tasks...
a) Monitors six temperature sensors ..
b) 'Keeps an eye',if any temp goes higher than 90 C ..
bi) If in case it does ,it signals a relay,to cut the power off to the led drivers ...
bii) At such case it waits until the temp(s) have dropped below 90C and re-powers led drivers
c) Averages the six temps ..
d) Adjusts fan(s) speed accordingly ...

Simple ..My grand-mother can do it ,in her rockin' chair ,while drinking bourbon ..
(Should I 've her do all that ? :dunce:...)
 

stardustsailor

Well-Known Member
The fan control Arduino output circuit :
( Raw PWM version )
pwm output circuit.JPG


Notes on the circuit :

The IRF540N is an
"
Advanced HEXFET® Power MOSFETs from International
Rectifier utilize advanced processing techniques to achieve
extremely low on-resistance per silicon area. This benefit,
combined with the fast switching speed and ruggedized
device design that HEXFET power MOSFETs are well
known for, provides the designer with an extremely efficient
and reliable device for use in a wide variety of applications.
The TO-220 package is universally preferred for all
commercial-industrial applications at power dissipation
levels to approximately 50 watts. The low thermal
resistance and low package cost of the TO-220 contribute
to its wide acceptance throughout the industry.

"
At the 5 - 4.5 VDC signal ,the fet can handle a drain -source current of ~10 A ...
( when saturated ,meaning when used as a switch ,not as amplifier ...)
irf540 oper amp.JPG




-The 10K resistor, connecting fet's gate to Ground is not really needed, because when Pin 9 is not HIGH
(+5VDC ) is pulled down to ground ,so it pulls the Fet's gate to ground also (in order for the fet to 'open' ,to stop
contacting current at between Drain- Source ...
Fet's differ when used as switches from their cousins ,the transistors ...
While in the transistor the operation is simple : Current at Base ?
the transistor closes and conducts current at
Collector-Emitter path...
No Current at Base ?
the transistor opens and it no more conducts current at
Collector-Emitter path...

( N-channel) Fets .....once a >+4V signal goes to gate ,fets conduct...
If that signal ceases ..
Fets still conduct ....
Gate has to be pulled to ground ,in order for the 'switch' to go again at 'off " position ....

So a 10K resistor is used for that purpose ..better have it there ..
It ensures that when no voltage is applied to fet's gate ,the fet will remain "open" as a switch ...( off ) ....

The two "steering' diodes are not also a 'must' ...
But they offer protection in case of a "tough nut " of a fan ..
( kick back ,reverse polarity spikes from fan coils to Mosfet )
IRF540 is a 'tough' Fet but ....
You never know ...
 

stardustsailor

Well-Known Member
Guys I hope that you know that all ideas are welcome ..specially about the fan speed control ..

I'm not that satisfied about the "scheme" that I've programmed the Arduino to follow ...
 
Top