SI1145 IR range

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
egutting
 
Posts: 297
Joined: Wed Nov 14, 2012 12:57 am

Re: SI1145 IR range

Post by egutting »

I can throw up a virtual machine to try to get them. I do have my old copy of XP that's not installed anywhere.

User avatar
primexandy
 
Posts: 89
Joined: Sat Sep 06, 2014 11:09 am

Re: SI1145 IR range

Post by primexandy »

...useful if you could....was rather hoping someone from Adafruit could lay their hands on the info. Grateful for any info from where ever though :)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: SI1145 IR range

Post by adafruit_support_rick »

I took pity on you guys and installed the toolkit. Here are the files:
Si114x_functions.zip
(14.56 KiB) Downloaded 169 times

User avatar
primexandy
 
Posts: 89
Joined: Sat Sep 06, 2014 11:09 am

Re: SI1145 IR range

Post by primexandy »

many thanks...

it looks more complicated than I was expecting, but hey ho.

Will now plough through it. :)

User avatar
egutting
 
Posts: 297
Joined: Wed Nov 14, 2012 12:57 am

Re: SI1145 IR range

Post by egutting »

Maybe focus on these functions:

Code: Select all

//
// Returns the calibration ratio to be applied to VIS measurements
//
static u32 vispd_correction(u8 *buffer)
{

    struct operand_t op;
    u32              result;
    s16              index = cal_index( buffer );

    if ( index < 0 ) result = FX20_ONE;

    op.op1 = calref[ index ].vispd_adclo_whled; 
    op.op2 = VISPD_ADCLO_WHLED;
    result = fx20_divide( &op );

    if ( result == FX20_BAD_VALUE ) result = FX20_ONE;

    return result;
}

//
// Returns the calibration ratio to be applied to IR measurements
//
static u32 irpd_correction(u8 *buffer)
{
    struct operand_t op;
    u32              result;
    s16              index = cal_index( buffer );

    if ( index < 0 ) result = FX20_ONE;

    // op.op1 = SIRPD_ADCLO_IRLED_REF; op.op2 = SIRPD_ADCLO_IRLED;
    op.op1 = calref[ index ].sirpd_adclo_irled; 
    op.op2 = SIRPD_ADCLO_IRLED;
    result = fx20_divide( &op );

    if ( result == FX20_BAD_VALUE ) result = FX20_ONE;

    return result;
}

//
// Returns the ratio to correlate between x_RANGE=0 and x_RANGE=1
// It is typically 14.5, but may have some slight component-to-component 
// differences.
//
static u32 adcrange_ratio(u8 *buffer)
{
    struct operand_t op;
    u32              result;
    
    op.op1 = SIRPD_ADCLO_IRLED  ; op.op2 = SIRPD_ADCHI_IRLED  ;
    result = fx20_divide( &op );

    if ( result == FX20_BAD_VALUE ) result = FLT_TO_FX20( 14.5 ); 

    return result;
}

//
// Returns the ratio to correlate between measurements made from large PD
// to measurements made from small PD.
// 
static u32 irsize_ratio(u8 *buffer)
{
    struct operand_t op;
    u32              result;

    op.op1 = LIRPD_ADCHI_IRLED  ; op.op2 = SIRPD_ADCHI_IRLED  ;
    result = fx20_divide( &op );

    if ( result == FX20_BAD_VALUE ) result = FLT_TO_FX20(  6.0 ); 

    return  result;
}

//
// Returns the ratio to adjust for differences in IRLED drive strength. Note
// that this does not help with LED irradiance variation.
// 
static u32 ledi_ratio(u8 *buffer)
{

    struct operand_t op;
    u32              result;
    s16              index = cal_index( buffer );
    
    if ( index < 0 ) result = FX20_ONE;

    // op.op1 = LED_DRV65_REF; op.op2 = LED_DRV65;
    op.op1 = calref[ index ].ledi_65ma; 
    op.op2 = LED_DRV65;
    result = fx20_divide( &op );

    if ( result == FX20_BAD_VALUE ) result = FX20_ONE;

    return result;
}

User avatar
primexandy
 
Posts: 89
Joined: Sat Sep 06, 2014 11:09 am

Re: SI1145 IR range

Post by primexandy »

...been through the files and it's a little more complicated than that. I think you have to normalize data then process then denormalize it before placing into the ucoef registers.

....simply copying the functions would suffice and work but I trying to understand what they are doing a bit more.

At the end of the day I don't think that calibrating the coefficients from the default values will greatly change the readings. It'll be more the case that at least I know it's calibrated :)

On another thread regarding the SI1145 it was mentioned that you can convert the UV index to watts/m2 by dividing by 100 (for uv index) and then again by 40 to get w/m2 but I think that was incorrect. If anything that formula may give mw/cm2.

I'm hoping that if I can get accurate readings, by calibrating and understanding how the device works more then I can better monitor light and irradiance, insolation etc. Taking that further I'm hoping to combine this data with NDVI (infraread photography of plants) to work out plant health and productivity. NDVI is an interesting concept but it seems a bit limited unless you know how much light of what frequencies (UV, Red, Blue, Infrared) was shining on the plant at the time of taking the photo.

The more I learn the more I'm beginning to think/realise that this sensor isn't a UV sensor, it is an IR and VIS light sensor that then works out how much UV there "probably" is. It gets more complicated because the IR sensor's response isn't flat to all IR frquencies and neither is the VIS light sensor, added to that the VIS light sensor also picks up some IR and probably some UV and also isn't a flat response to all frequencies. I think the sensor may have been calibrated to a known light source (light bulb type thing) as a reference but the real sunlight in reality changes the amount of UV and IR getting to the earths surface depending on clouds, pollution, ozone, CO2 etc etc so if the sensor is guestimating UV based upon what IR and VIS light it sees then it'll be varying quite wildly from day to day....i think.

....i could be totally wrong though :)

The more info I can find out and the more experiments I can do with the sensor the more I can learn and see how it can benefit me, if at all. Thoroughly enjoying the process of learning though :)

User avatar
smerrett79
 
Posts: 16
Joined: Sun Aug 30, 2015 9:46 pm

Re: SI1145 IR range

Post by smerrett79 »

Hi, if you look at page 36 of Silicon Labs Application Note 498:

5.6.1. Byte Alignment
All of the output registers contain two bytes. They form 16-bit quantities. For example, ALS_VIS_DATA1 and
ALS_VIS_DATA0 combine to form a 16-bit quantity in the following way:

ALS_VIS_DATA = 256 * ALS_VIS_DATA1 + ALS_VIS_DATA0


This makes me think you might have been ignoring half the data (perhaps the least significant half, admittedly, but not multiplying it but 256 either). From a quick sscan of the Adafruit library .cpp on Github it looks like they are only reading one of the two registers for each of the Vis and IR readings (4 in total from 0x22 to 0x25). Haven't tried it myself yet so I'm not throwing stones - it's just the next thing I'm going to try.

Other notes in the section:
Note the “ordering” of the registers from the perspective of where it is in the I2C Register Map.
It is recommended that these output registers be read using an I2C Burst Read operation.
Register ordering is “little-endian” by nature. Therefore, if the host processor is “big endian”, simply pointing to
ALS_VIS_DATA0, for example, and casting it as a 16-bit variable will result in a byte swap. To avoid byteswapping,
it is recommended that the 16-bit quantity be explicitly calculated similar to the example shown above.

User avatar
smerrett79
 
Posts: 16
Joined: Sun Aug 30, 2015 9:46 pm

Re: SI1145 IR range

Post by smerrett79 »

UPDATE

I rewrote the adafruit library .cpp function to perform the calculation in the way they said and it chucks out the same results as their original code, so it doesn't look like their library falls foul of the endian issue. Once I applied the multipliers in this post, I got great readings. However, the key bit is getting your "dark" readings for IR and VIS ALS and then subtracting this offset from the VIS and IR values before multiplying by the 14.5 and dividing by the counts/lux coefficient. Very many thanks to primexandy!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”