PDA

View Full Version : UV sensor ML8511



visnja30
- 5th January 2016, 16:12
Hi to all and Happy New year.
Today I receive a UV sensor ML 8511.
Watching his datasheet the output voltage is linear to intensity of the UV light.
How to measured voltage convert into a UV index.
Supply voltage PIC and the sensor is 5.0V
AD conversion is 10 bit and I use 18F4520 chip




Code example to measure voltage:

' ** Setup the ADCIN Defines **

Define ADC_BITS 10 ' Set resolution of conversion
Define ADC_CLOCK 2 ' Set clock source (x/FOSC or FRC)
Define ADC_SAMPLEUS 50 ' Set sampling time (in uS)




' ** Declare the Variables **

AD_Raw Var Word ' 10-bit result of A/D conversion
AD_Result Var Word ' Quantasized ADC result
Average Var Word ' Variable for building up the average result
Samples Var Byte ' Amount of samples taken
Volts Var Byte ' Holds the Volts part of the result (only for display purposes)
Millivolts Var Word ' Holds the Millivolts part of the result (only for display purposes)



' quanta level = (5/1024) * 256 == 1250
Quanta Con 1250
' ** Define the bits within the ADCON1 register **

ADFM Var ADCON1.7 ' ADC result fotmat select bit
PCFG3 Var ADCON1.3 ' ADC port configuration bit
PCFG2 Var ADCON1.2 ' ADC port configuration bit
PCFG1 Var ADCON1.1 ' ADC port configuration bit
PCFG0 Var ADCON1.0 ' ADC port configuration bit




PCFG0=0
PCFG1=1
PCFG2=0
PCFG3=0 ' Configure for AN0-AN4 as analogue input
ADFM=1 ' Right justified result in ADRESL and ADRESH

' ** THE MAIN PROGRAM STARTS HERE **
main:

Average=0 ' Clear the Average variable befor use
For Samples=0 to 9 ' We will take 10 samples of the ADC
ADCIN 1,AD_Raw ' Place the conversion of channel0 into AD_RAW
Average=Average+AD_Raw ' Build up the Average result
Next ' Close the loop
Average=Average/10 ' Calculate the average by dividing by the number of samples taken
AD_Result=(Average) */ Quanta ' Quantasize the result

Volts= AD_Result/100 ' Calculate the Volts part of the result
Millivolts=AD_Result//100 ' Calculate the Millivolts part of the result


Lcdout $fe, 2 '
Lcdout "Napon = ", DEC volts, ".",dec Millivolts, "V" '

pause 100

goto main

Gusse
- 5th January 2016, 17:08
How to measured voltage convert into a UV index.
Supply voltage PIC and the sensor is 5.0V
UV Index is defined W/m2 --> 1 mW/cm2 = 10 W/m2 (10x)
From datasheet:
UV Index: 0 = 1.0V (typ), 100 = 2.2V (typ)
Make sure that supply voltage is very stable, 1mV = 0.833 UV index

Check operating voltage from datasheet!!

visnja30
- 5th January 2016, 18:29
On board is 3V3 voltage regulator so I think it must work with 5V input voltage.

Scampy
- 5th January 2016, 18:51
can you provide a link to the actual module you have. Most of the hits from Google suggest the unit is 3.3v, with a pull up resistor between EN and +3.3v and show no regulator... It would also suggest that the voltage out will be from 0 to +3.3v and not 5v that you might expect.

https://i.publiclab.org/system/images/photos/000/003/847/medium/ML8511-characteristics.png

visnja30
- 5th January 2016, 19:12
http://www.ebay.com/itm/351494135550?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I know that the maximum voltage from the module is 3.3volts and my PIC AD module can measure 5 volt maximum.Is that problem?

Gusse
- 6th January 2016, 12:53
It seems that it is challenging to calculate accurate UV-Index (0-11+), as you would like to do.
Index is weighted using 3 different wavelengths and this broadband UV sensor covers all of them.
Problem is that there is just one output value for all of them.

Wavelenghts and weighting:
295 nm -> 1x , 305 nm -> 0.22x , and 325 nm -> 0.003x
How is the UV-Index Calculated? (http://www.serc.si.edu/labs/photobiology/UVIndex_calculation.aspx)

Basically you could generate your own multiplier, based on above values and hands-on testing.

About operating voltages, even there is 3.3v LDO for chips itself, EN (enable pin) still need to be in spec. Put voltage divider between PIC and sensor.
ADC is not a problem, measure & scale result (1v -> 0, 3v -> 1023, 10-bit ADC)

visnja30
- 6th January 2016, 14:51
ADC is not a problem, measure & scale result (1v -> 0, 3v -> 1023, 10-bit ADC) ...... Yes it is problem

This is my problem I can measure voltage from sensor but how to scale it to UV intensity from datasheet.

I change the power supply to 3.3V and EN pin is connected to VCC pin.

Gusse
- 8th January 2016, 12:24
ADC is not a problem, measure & scale result (1v -> 0, 3v -> 1023, 10-bit ADC) ...... Yes it is problem
This is my problem I can measure voltage from sensor but how to scale it to UV intensity from datasheet.
In Lapis website (http://www.lapis-semi.com/en/semicon/sensor/ml8511.html), they have graph including UV-index.
1V = 0 UV-Index
3V = 15 UV-Index

Don't know how they have calculated that, but lets take it as it is.

Scaling ADRaw: 310 (1V) - 925 (3V) to UVIndex: 0 -15

If AD_Raw < 310 THEN AD_Raw = 310
UVIndex = (((AD_Raw * 4)/17)-71)/10

8147

Above is approximation for accurate calculation formula. It should be close enough, but if it is not then alternate parameters...
Remember that intermediate results (step by ste) must remain as an integer value