I took the liberty of restoring the indentation of the arduino code and adding in English translations for some of the text (Mostly for my own benefit--in the immortal words of Korben Dallas, "I only speak two languages...").
The calorimetric approach is quite nice in its simplicity. Of course the mass of the heatsink has to be taken into the calibration, and using a heatsink means that measurement accuracy will be dependent on the surrounding air flow conditions. Measuring the equilibrium temperature and examining the slope during the measurement and cooldown periods would probably allow you to largely remove the heatsink and ambient characteristics from the measurements, but that would get complicated and mathy.
But with a known mass of known material with a known absorption you can get pretty close quite easily. Neat!
Code:
// Digital Laser Power Meter// v 2.1
#include <max6675.h>
#include <LiquidCrystal.h>
#include <Wire.h>
//Max6675 CK,CS,SO
MAX6675 thermocouple(4, 3, 2);
int sense = 0;
float cal = 0.0000;
int t = 10;
int tiempo = t;
float p = 0.717;
int m = 87;
int maxt = 45;
float temperatura = 0.000;
float temperaturai = 0.000;
float temperaturaf = 0.000;
float temperaturaa = 0.000;
float w = 0.000;
//establecer conexiones LCD 16x2
// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() {
Serial.begin(9600);
// use Arduino pins FORMAX6675 VCC AND GND
pinMode(5, OUTPUT); digitalWrite(5, HIGH);
pinMode(6, OUTPUT); digitalWrite(6, LOW);
pinMode(7, OUTPUT); digitalWrite(7, HIGH);
lcd.begin(16, 2);
sense = analogRead(A7);
cal = sense * (2.0 / 1023.0);
p = cal;
// wait for MAX chip to stabilize
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print ("Medidor Potencia");
lcd.setCursor(0, 1);
lcd.print (" Laser Co2");
delay(2500);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print (" V 2.0 ");
lcd.setCursor(0, 1);
lcd.print ("521 229-419-3262");
delay(5000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print ("Cal P = ");
lcd.print (p);
delay (2500);
}
void loop()
{
//esperar temperqatura menor a tmax
temperatura = thermocouple.readCelsius();
while (thermocouple.readCelsius() > maxt)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print (" Temperatura de "); // "High sensor temperature"
lcd.setCursor(0, 1);
lcd.print (" sensor alta");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print ("Porfavor Espere"); //"Please wait"
lcd.setCursor(0, 1);
lcd.print (" T = ");
lcd.print (thermocouple.readCelsius());
lcd.print (" C");
delay(2000);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Medir Potencia "); // "Measure power"
lcd.setCursor(0, 2);
lcd.print(" Encender Laser "); // "Turn on the laser"
// guardar temperatura inicial
temperaturai = thermocouple.readCelsius();
digitalWrite(7, LOW);
//Serial.print ("Temperatura Inicial ");
//Serial.println (temperaturai);
//Serial.println ("Espera de laser");
delay (180);
do
{
temperatura = thermocouple.readCelsius();
//Serial.println(temperatura);
delay (180);
//esperar a una diferencia de un grado de temperatura
//wait for a difference of one degree of temperature
if (temperatura < temperaturai)
{
temperaturai = temperatura;
}
} while (temperatura-temperaturai < 1);
//Serial.println("Lecturas");
//esperar T segundos para absorber energia
//wait T seconds to absorb energy
do
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ESPERE "); // "WAIT"
lcd.print(tiempo);
lcd.print("Seg"); // "Sec[onds]"
tiempo=tiempo - 1;
//Serial.println(thermocouple.readCelsius());
delay (1000);
} while (tiempo > 0);
//Serial.println("Esperando Maximo");
digitalWrite(7, HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PROCESANDO"); // "PROCESSING"
temperaturaf = thermocouple.readCelsius();
delay(180);
do
{
temperatura = thermocouple.readCelsius();
//Serial.print (temperaturaf);
//Serial.print (" - ");
//Serial.println (temperatura);
delay(200);
if (temperaturaf < temperatura)
{
temperaturaf = temperatura;
}
} while ((temperaturaf - temperatura) < 0.75);
w =((((m*(temperaturaf - temperaturai))*(4.18)*(p))/30));
//w = (((m*(deltat))/1000)*4180)/(t);
//Serial.println("calculo");
//Serial.println(temperaturai);
//Serial.println(temperaturaf);
//Serial.print("Watts: ");
//Serial.println(w);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print ("POTENCIA LASER"); // "LASER POWER"
lcd.setCursor (0, 2);
lcd.print(w);
lcd.print(" Watts");
delay(10000);
tiempo = t;
digitalWrite(7, HIGH);
}