9 years, 10 months ago.

Setting interrupt threshold

Hi Karl,

I have been working with very similar sensor from AMS (formally know as TAOSinc). I have found your code really helpful. However, it doesn't fit my need so I am writing my own library. I am using TSL276711FN. /media/uploads/jspatel/tsl2671_datasheet_en_v1.pdf

Here are the list of registers.

const char ENABLE_REG =    0x00; /// Enables states and interrupts
const char PTIME_REG =     0x02; /// Proximity ADC time
const char WTIME_REG =     0x03; /// Wait Time
const char PILTL_REG =     0x08; /// Proximity interrupt low threshold low byte
const char PITLH_REG =     0x09; /// Proximity interrupt low threshold high byte
const char PIHTL_REG =     0x0A; /// Proximity interrupt high threshold low byte
const char PIHTH_REG =     0x0B; /// Proximity interrupt high threshold high byte
const char PERS_REG =      0x0C; /// Interrupt persistence filter
const char CONFIG_REG =    0x0D; /// Configuration
const char PPCOUNT_REG =   0x0E; /// Proximity pulse count
const char CONTROL_REG =   0x0F; /// Control register
const char ID_REG =        0x12; /// Device ID
const char STATUS_REG =    0x13; /// Device status
const char PDATAL_REG =    0x18; /// Proximity ADC low data register
const char PDATAH_REG =    0x19; /// Proximity ADC high data register

I am able to read and write all registers. I can read Proximity ADC registers and get value from [0, 1023]. Higher number indicates closer proximity to sensor. When I set low threshold to 0 and high threshold to 600, I never get any interrupt. I flipped the values and still not getting any interrupts. So I set both values to 600. Now I do get interrupt because proximity ADC value is not going to 600, hence trigger an interrupt. I am not sure what value to set for interrupt threshold. I am wondering if you have any insight on this. I have also attached datasheet.

Values I am setting for registers, ENABLE =0x2f PTIME = 0xff WTIME = 0xff PILTx = 0x00 00 PIHTx = 0x02 58 = 600

Any help is appreciated.

Question relating to:

Library which provides functions to control a TAOS TSL2561 Light-To-Digital Converter via I2C. TSL2560, TSL2561

1 Answer

9 years, 10 months ago.

I can't see a problem with the approach you have taken. It seems like it should work. This is all I can think of:

1) If you're using the interrupt pin, note that it is active-low and requires a pull-up resistor because it is open-drain. ( For reference: http://en.wikipedia.org/wiki/Open_collector ) As a check, you could try using the PINT field of the STATUS register to detect interrupts.

2) Make sure you have PIHTL and PIHTH in the right order.

3) Check the value of the persistence register, although this shouldn't be an issue.

Here is a code example using interrupts with my driver which might help: /media/uploads/karlmaxwell67/capture.png

Accepted Answer

My apologies, that code example is for the TCS3472_I2C class ( http://mbed.org/users/karlmaxwell67/code/TCS3472_I2C/ ), but it should be the same principles.

posted by Karl Maxwell 03 Jun 2014

Thank you Karl.

Last night I got to the same conclusion. I was using interrupt on rise. When I set it to use to fall, it worked as it should.

It was working in a weird way when I posted the question. I had interrupt clear on a button press on the board. When I pressed button I was getting an interrupt. After spending couple of hours on this I came to the same conclusion. It has to generate interrupt on fall.

posted by Jigar Patel 03 Jun 2014