Commit ac8e076d authored by Sebastián Fernández's avatar Sebastián Fernández

medicion radiacion inicial se hace luego de tiempo de calentamiento

parent 590b7264
......@@ -75,7 +75,7 @@ por
****************************************/
#define version "Version 1.0"
// UV metering
const float target_dose = 2500; // mJ/cm2
const float target_dose = 2000; // mJ/cm2
/****************************************
......@@ -108,7 +108,8 @@ const int tics_slow_blink = tics_per_sec ;
const int tics_slow_chime = tics_slow_blink * 6;
const int tics_fast_blink = tics_per_sec/2 ;
const int tics_fast_chime = tics_fast_blink * 3;
const int tics_wait_power_stabilization_period = tics_per_sec * 5;
const int sec_wait_power_stabilization_period = 200;
const int tics_wait_power_stabilization_period = tics_per_sec * sec_wait_power_stabilization_period;
volatile int tic = LOW;
volatile int tic_heart_bit = LOW;
......@@ -288,9 +289,19 @@ void display_calibration_power(int value) {
lcd.setCursor(0, 1);
lcd.print("Pot.: "); //
lcd.print(value);
lcd.print(" mW/cm2 "); //
lcd.print(" uW/cm2 "); //
}
void display_calibration_warming(int value) {
//76543210
// ToDo: 7 segment message
lcd.setCursor(0, 0);
lcd.print("Calib. en curso "); //
lcd.setCursor(0, 1);
lcd.print("Calentando: "); //
lcd.print(value);
lcd.print(" s "); //
}
void display_msg_door() {
//76543210
lc.setRow(0, 7, B00111101);
......@@ -352,7 +363,7 @@ void display_power_time(int disp, int value) {
lcd.setCursor(0, 0);
lcd.print("Pot.: "); //
lcd.print(value);
lcd.print(" mW/cm2 "); //
lcd.print(" uW/cm2 "); //
}
else {
first_digit_pos= 3;
......@@ -518,7 +529,7 @@ void loop() {
void on_tic(){
int remaining_warmup_sec;
switch(state)
{
......@@ -573,24 +584,20 @@ switch(state)
if (tics_gral_passed >= tics_wait_power_stabilization_period) {
tics_gral_passed = 0;
last_adc_value = new_adc_value;
new_adc_value = get_adc_read();
float dif_rel = (new_adc_value - last_adc_value) / new_adc_value;
dif_rel = abs(dif_rel);
DEBUG_PRINT((String)"last_adc_value: " + last_adc_value);
DEBUG_PRINT((String)"new_adc_value: " + new_adc_value);
DEBUG_PRINT((String)"dif_rel: " + dif_rel);
radiation_power = calculate_radiation_power(new_adc_value);
display_calibration_power(radiation_power);
// stable if difference between read < 5%
if (dif_rel < 0.05)
state = DOSE_CALCULATION;
state = DOSE_CALCULATION;
} else {
tics_gral_passed += 1;
tics_gral_passed += 1;
remaining_warmup_sec = ((tics_wait_power_stabilization_period - tics_gral_passed) / tics_per_sec);
display_calibration_warming(remaining_warmup_sec);
}
}
......@@ -601,7 +608,7 @@ switch(state)
DEBUGST_PRINT("state: DOSE_CALCULATION");
state = WAIT_TO_START;
remaining_desinfection_time = (int)(target_dose/radiation_power); // secs
remaining_desinfection_time = (int)(target_dose*1000/radiation_power + sec_wait_power_stabilization_period); // secs
tics_gral_passed = 0;
tics_on_passed = 0;
secs_on_passed = 0;
......
......@@ -522,10 +522,21 @@ float getCurrentRawADC()
fuvc_v_val_avg = (float)iuvc_v_val;
for (int j = 0; j < reads_to_average; j = j + 1) {
iuvc_v_val = analogRead(uvc_pin);
// Serial.print(j);
// Serial.print(" - ");
// Serial.println(fuvc_v_val_avg);
fuvc_v_val_avg = ((float)iuvc_v_val + fuvc_v_val_avg);
}
fuvc_v_val_avg = fuvc_v_val_avg / reads_to_average;
// Serial.print("fuvc_v_val_avg : ");
// Serial.println(fuvc_v_val_avg);
// Serial.print("reads_to_average : ");
// Serial.println(reads_to_average);
fuvc_v_val_avg = fuvc_v_val_avg / reads_to_average;
// Serial.print("fuvc_v_val_avg : ");
// Serial.println(fuvc_v_val_avg);
return fuvc_v_val_avg;
}
......@@ -536,7 +547,7 @@ void displayRadiationPower(int radiation_power) {
lc.setChar(0, 7 - i, digitos_disp[i], false);
}
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print("P.radiada: "); // Print the string "Hello World!"
lcd.print("P.radiada: "); //
lcd.print(radiation_power);
lcd.print(" ");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment