Hello, I am using a pressure/temperature sensor called the 86BSD. Docuemntation relating to the i2c communications of this device can be found here.
I currently use a polling based system to get information from the sensor, and would like to switch to an interrupt driven system. I have scoped the interrupt pin on my sensor and have read that the pin always stays high. In the documentation on 1.3 it says "When programmed as an I2C device, the INT/SS pin operates as an interrupt. The INT/SS pin rises when new output data is ready and falls when the next I2C communication occurs." If my interpretation is correct then the interrupt pin should be varying constantly since I am currently polling from the sensor, but in reality it does not. If my interpretation is wrong please let me know why, and if maybe I am not calling a correct command let me know.
Here is the relevant parts from my function:
double GetTemperature(int address)
{
//start the communication with IC with the address xx
Wire.beginTransmission(address);
//Write a 1 to specify the we are reading from the sensor
Wire.write(1);
Wire.endTransmission();
delay(delay_time); //There is an i2c bug that occurs and causes the arduino to crash eventually if this isnt here
//request 1 byte from address xx
Wire.requestFrom(address, 4);//We need to get 4 bytes of data because this is the only request available that would get the full 10 bit data structure.
//wait for response
double data = 0;
int a,b,c,d; //Use these to get individual packets
while(Wire.available())
{
a = Wire.read();
b = Wire.read();
c = Wire.read();
d = Wire.read();
}
PaulS:
I have to ask why. Why do you need to know the nanosecond that the temperature changes?
The pressure in my project is pretty important to keep track of, I just gave the temperature function (the pressure function is pretty much the same thing). I also have another sensor in my system which is interrupt driven, and I am comparing the benefits of turning all of my sensors into interrupt driven.
Delta_G:
Doesn't the Wire library already have an onReceive or something like that which will handle this?
I haven't used much I2C with Arduino so I'm not sure if it is interrupt driven or not.
Can you elaborate? I also managed to get data from the sensors by just polling it every loop, so maybe I got lucky if you do need to have interrupts for an i2c system.
Delta_G:
You don't have to use an interrupt. Polling is probably best for a sensor like that unless you expect big temperature changes on the millisecond time scale. Adding interrupts adds to complexity and it's usually best to keep things simple.
I don't need to elaborate on the Wire library. You are perfectly capable of going to the Arduino reference and reading about it. See what methods are available and read up on them to see if any of it is interrupt driven.
The system I am using need precise measurement of the pressure, I just gave the temperature function as an example of what my code is doing (since my pressure function is pretty much identical I didn't bother posting it).
No like I read through it and understand it I just don't see how that it relates to my problem since its just a handler. I am looking for a reason why my sensor may only be set to high, and never going to low even though I am using i2c communication and this should be setting it low (as specified by the I2C documentation that I linked in OP).
Delta_G:
Yeah, you said that before. But that statement is useless without some numbers. I mean what's the rate of change of the pressure?
If I had to guess that would be at worst 8.4ms for the start time to data ready (1st sample), and best time would be hard for me to guess since I'd have to consider system overhead. How would knowing the maximum amount of samples help though? Is there any other data that I can try to get that you'd think would be useful?
Delta_G:
And if you were going to use an interrupt you would write what exactly if not a handler? That's why I thought it might be the thing you needed. I just looked and it looks like it is not.
I agree that having an interrupt requires having a handler (otherwise why have the interrupt?). I will try writing a handler when I get back to my lab and see if there is any new changes, but I am kinda doubtful it will work.
Delta_G:
OK, I thought we were looking for the interrupt on the Arduino. What type of output does that chip have? Do you need to pull it up or down or anything? They don't give much info about it on the datasheet.
The sensor uses SCL/SDA for I2C and the INT pin which (I BELEIVE) is HIGH for having information for the arduino, and LOW after it gets read/doesn't have data for the arduino. Pull ups on the SCL/SDA, and I don't have any on the INT. Ya, unfortunately the data sheet has been annoying to use, I have been trying to talk to an applications engineer for a bit though to get some clarifications.
The sensor uses SCL/SDA for I2C and the INT pin which (I BELEIVE) is HIGH for having information for the arduino, and LOW after it gets read/doesn't have data for the arduino. Pull ups on the SCL/SDA, and I don't have any on the INT. Ya, unfortunately the data sheet has been annoying to use, I have been trying to talk to an applications engineer for a bit though to get some clarifications.
I don't think it can hurt to place a pull up or pull down on the int pin and see if you can watch it toggle. If you are always reading high on the scope, as you said in the first post, I'd try a pull down.
An interrupt for "data is ready" doesn't tell you anything about the data. It means that you asked it (via I2C) to take a sample and that sample is ready. So now you can read it by I2C instead of waiting for the 120ms or whatever the maximum sample delay might be.
The ADXL345 has an INT line that you can program to some extent but really it's not very useful for Arduino projects. And that's a good one that has configurable levels for activity detection and all the other things that might need an interrupt.
MorganS:
An interrupt for "data is ready" doesn't tell you anything about the data. It means that you asked it (via I2C) to take a sample and that sample is ready. So now you can read it by I2C instead of waiting for the 120ms or whatever the maximum sample delay might be.
The ADXL345 has an INT line that you can program to some extent but really it's not very useful for Arduino projects. And that's a good one that has configurable levels for activity detection and all the other things that might need an interrupt.
Ya in my code you can see that I request the data then read it, but for some reason after reading it the INT pin doesn't go low.
Delta_G:
That begs the question then, when you scoped that pin, were you sending it requests?
If my code that I posted in the OP is correct, then yes I beleive so.