📜 ⬆️ ⬇️

Invented and made the device

This morning I did not write posts and test light bulbs, but I started working on it. A couple of days ago I “invented” a device that I really missed when testing lamps, and today I was able to make it.


The device shows the change in brightness as a percentage over time. First of all, I need it in the lamptest.ru project to measure the minimum voltage at which the lamps are lit, without reducing the brightness by more than 10%. In addition to information about the minimum voltage, which is useful for those who live in places with not very high-quality power supply, where the voltage in the network can significantly decrease (for example, in rural areas), this will help draw conclusions about the type of driver and the quality of the lamps.

Another device is useful for analyzing the decrease in lamp brightness as it warms up.
')
In the upper left corner of the screen shows the current value of illumination in lux, in the lower left corner - the original value of illumination. In the upper right - what percentage is the first number from the second. The Select button sets the initial light value to the current one.

Additionally made an indication of pulsation, but it is very approximate. I use the TSL2561 digital light sensor, it has a minimum integration time of 13 ms, and the duration of one half-period of the mains voltage is 10 ms. I do 12 measurements in a row with the hope that some of them accidentally fall on the minimum of brightness during pulsation, and some other on the maximum. Using the Left button you can make external light correction to calculate the pulsation by pressing it when the lamp under study is turned off.

The whole construction consists of three ready-made modules - Arduino UNO R3 , LCD Keypad Shield , MH-2561 and four wires.

Sketch for Arduino
Sketch for Arduino:
<textarea rows="130" cols="110"> #include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_TSL2561_U.h> #include <LiquidCrystal.h> //initialize LCD with the numbers of the interface pins LiquidCrystal lcd(8, 9, 4, 5, 6, 7); int start; int lm; int procent; //    samopal.pro #define MAX_UNITS 12 uint16_t l_min=0,l_max=0,l=0,env=0; int pulse = 0; Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345); void configureSensor(void) { tsl.setGain(TSL2561_GAIN_1X); /* No gain ... use in bright light to avoid sensor saturation */ // tsl.setGain(TSL2561_GAIN_16X); /* 16x gain ... use in low light to boost sensitivity */ // tsl.enableAutoRange(true); /* Auto-gain ... switches automatically between 1x and 16x */ /* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */ // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */ // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS); /* medium resolution and speed */ tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* 16-bit data but slowest conversions */ } void setup(void) { // set up the LCD's number of columns and rows: lcd.begin(16, 2); Serial.begin(9600); /* Initialise the sensor */ if(!tsl.begin()) { /* There was a problem detecting the TSL2561 ... check your connections */ Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!"); while(1); } /* Setup the sensor gain and integration time */ configureSensor(); //    sensors_event_t event; tsl.getEvent(&event); start = event.light; lcd.setCursor(0,1); lcd.print(start); } void loop(void) { tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS); /* Get a new sensor event */ sensors_event_t event; tsl.getEvent(&event); lm = event.light; lcd.setCursor(0,0); lcd.print(lm); lcd.print(" "); procent = (event.light/start*100); lcd.setCursor(10,0); lcd.print(procent); lcd.print("% "); { int x; x = analogRead (0); if (x < 60) { // lcd.print ("Right "); } else if (x < 200) { // lcd.print ("Up "); } else if (x < 400){ // lcd.print ("Down "); } else if (x < 600){ // lcd.print ("Left "); env = event.light; } else if (x < 800){ start = lm; lcd.setCursor(0,1); lcd.print(start); lcd.print(" "); } } //   tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); l=event.light-env; l_min = l; l_max = l; for (int i = 0; i < MAX_UNITS; i = i + 1) { tsl.getEvent(&event); l=event.light-env; if( l < l_min )l_min = l; if( l > l_max )l_max = l; } if( l_max != 0 )pulse = (double)((l_max - l_min))*100/(double)((l_max + l_min)); else pulse = 0; lcd.setCursor(10,1); lcd.print(pulse); lcd.print(" "); } 


Honestly, I did not hope that in half a day I would have a ready-made working device. And this is despite the fact that from programming languages ​​I once knew only the assembler BK0010 and I do a lot just by typing.

In the program for Arduino, I used fragments of example programs using TSL2561, LCD Keypad Shield, and for calculating the ripple a piece of the sketch of a luxmeter with samopal.pro. Some things work, but I don't understand what they mean :)

Nevertheless, the device works and very significantly saves time. With it, I have already tested 50 light bulbs for minimum voltage and driver type.

PS I would be very grateful if someone who is familiar with Arduino will sometimes be ready to answer my questions in Telegram, Facebook or Vkontakte.

© 2017, Alexey Nadyozhin

Source: https://habr.com/ru/post/401837/


All Articles