Diferencia entre revisiones de «Medidor de parpadeo de luz»

De fabwiki
Ir a la navegación Ir a la búsqueda
Sin resumen de edición
 
(No se muestran 6 ediciones intermedias del mismo usuario)
Línea 1: Línea 1:
__NOTOC__
Este es un instrumento para medir el parpadeo de las fuentes de luz.
Este es un instrumento para medir el parpadeo de las fuentes de luz.
Algunas bombitas son mucho más estables que otras.
Algunas bombitas son mucho más estables que otras.
Línea 12: Línea 14:
=Sensor=
=Sensor=
* [[Media:Ti opt101.pdf | Texas Instruments OPT101 Hoja de Datos]]
* [[Media:Ti opt101.pdf | Texas Instruments OPT101 Hoja de Datos]]
=Medidas=
==Bombita 1==
Estabilidad en la producción de luz: 95%
<gallery>
Bombita 1.jpg
</gallery>
==Bombita 2==
Estabilidad en la producción de luz: 73%
<gallery>
Bombita 2.jpg
Bombita 3.jpg
</gallery>
==Bombita 3==
Estabilidad en la producción de luz: 72%
<gallery>
Bombita 4.jpg
</gallery>


=Codigo=
=Codigo=
Línea 18: Línea 41:
#include "I2C_LCD.h"
#include "I2C_LCD.h"


const int COLLECTION_MS = 200;
const int COLLECTION_MS = 100;
const int SENSOR_LIMIT = 850;
const int SENSOR_LIMIT = 850;
const int SENSOR_BAJO = 200;
const int STOP_PIN = 3;
const int INTERRUPT_SETTLE_MS = 1000;


I2C_LCD lcd(39);
I2C_LCD lcd(39);
volatile bool run = true;
void stop() {
  if (millis() > INTERRUPT_SETTLE_MS) run = false;
}


void setup() {
void setup() {
Línea 27: Línea 59:
   Wire.setClock(100000);
   Wire.setClock(100000);
   lcd.begin(16, 2);
   lcd.begin(16, 2);
  pinMode(STOP_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(STOP_PIN), stop, LOW);
}
}


Línea 32: Línea 66:
   int x_max = 0, x_min = 10000;
   int x_max = 0, x_min = 10000;
   unsigned long stop_ms = millis() + COLLECTION_MS;
   unsigned long stop_ms = millis() + COLLECTION_MS;
  int sample_count = 0;
   while (millis() < stop_ms) {
   while (millis() < stop_ms) {
     int x = analogRead(A0);
     int x = analogRead(A0);
     if (x > x_max) x_max = x;
     if (x > x_max) x_max = x;
     if (x < x_min) x_min = x;
     if (x < x_min) x_min = x;
    sample_count++;
   }
   }
  if (!run) return;


   lcd.clear();
   lcd.clear();
Línea 42: Línea 81:
   if (x_max > SENSOR_LIMIT) {
   if (x_max > SENSOR_LIMIT) {
     lcd.center(1, "demasiada luz");
     lcd.center(1, "demasiada luz");
  } else if (x_max < SENSOR_BAJO) {
    lcd.center(1, "falta de luz");
   } else {
   } else {
     float ratio = (float)x_min / x_max;
     float ratio = (float)x_min / x_max;
     lcd.center(0, ("ratio = " + String(ratio)).c_str());
     lcd.center(0, ("ratio = " + String(ratio)).c_str());
    lcd.center(1, ("samples = " + String(sample_count)).c_str());
   }
   }
}
}
</pre>
</pre>

Revisión actual - 18:07 9 jul 2026


Este es un instrumento para medir el parpadeo de las fuentes de luz. Algunas bombitas son mucho más estables que otras. Esos datos no son disponibles. Podemos medir y publicar datos sobre las bombitas que son comunes acá.

Fotos

Sensor

Medidas

Bombita 1

Estabilidad en la producción de luz: 95%

Bombita 2

Estabilidad en la producción de luz: 73%

Bombita 3

Estabilidad en la producción de luz: 72%

Codigo


#include "I2C_LCD.h"

const int COLLECTION_MS = 100;
const int SENSOR_LIMIT = 850;
const int SENSOR_BAJO = 200;
const int STOP_PIN = 3;
const int INTERRUPT_SETTLE_MS = 1000;

I2C_LCD lcd(39);

volatile bool run = true;

void stop() {
  if (millis() > INTERRUPT_SETTLE_MS) run = false;
}

void setup() {
  Wire.begin();
  Wire.setClock(100000);
  lcd.begin(16, 2);
  pinMode(STOP_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(STOP_PIN), stop, LOW);
}

void loop() {
  int x_max = 0, x_min = 10000;
  unsigned long stop_ms = millis() + COLLECTION_MS;
  int sample_count = 0;
 
  while (millis() < stop_ms) {
    int x = analogRead(A0);
    if (x > x_max) x_max = x;
    if (x < x_min) x_min = x;
    sample_count++;
  }

  if (!run) return;

  lcd.clear();

  if (x_max > SENSOR_LIMIT) {
    lcd.center(1, "demasiada luz");
  } else if (x_max < SENSOR_BAJO) {
    lcd.center(1, "falta de luz");
  } else {
    float ratio = (float)x_min / x_max;
    lcd.center(0, ("ratio = " + String(ratio)).c_str());
    lcd.center(1, ("samples = " + String(sample_count)).c_str());
  }
}