Interrupt question

Hi,
Can I change the voltage reference for the 2 interrupt pins (0,1) on Arduino? (pins 0, 1)
The sensor is working at approximate 3V and I need the interrupts to be working at this voltage.

So, is there any option of doing this, excluding using a logic convertor?

Thank you,
RobertEagle

Can I change the voltage reference for the 2 interrupt pins (0,1) on Arduino? (pins 0, 1)

No. The pins are digital pins, which have a hard-wired reference voltage. That reference voltage, though, is 0.6 times the Arduino voltage. So, an Arduino running at 5.0V will see 3.0V as HIGH.

Tell us which Arduino you are using, and what the minimum voltage level is for the HIGH state of the sensor.

I'm using an ArduPilot Legacy and the voltage for the HIGH state of the sensor is 630.

I assume 630 is the ADC value.

You didn't have to use a level shifter IC. You can use a transistor.

I don't want to start another topic, since it's about the same thing(interrupt), to overload pages, so I'll post here.

I've connected the INT1 of the accelerometer ADXL345 on the Arduino pin 0, and I tried an interrupt function. First of all, I've wrote the registers to the ADXL345(rate samples, data format) and then the Interrupt Map register(activating just the DATA_READY) ,Interrupt Enable register (interrupt set on 1st pin) and finally the Power register.

I can tell that data is all the time ready because I can get on the Serial data about the sensors.(when is loaded other sample program) But the problem appears now: I don't receive anything on the INT1. It's a constant voltage on the pin coming from the sensor in both the situations: when the interrupt is off or on.

I measured the voltage and I get a 3.32V(the input on the sensor is the same). Then I measured in the AC mode with the multimeter, and what I get is just 0.001V (thinking that there would be a difference in voltage)

It may help to post a small example sketch where it should work but doesn't.

It seems like the interrupt on the ADXL345 is set but never cleared. I haven't read the datasheet, so I cannot help much in this regard. There must be a way to clear the interrupt state.

It isn’t just the sketch, it’s also the ADXL345’s library.

The sketch:

#include <Adxl345.h>
#include <Wire.h>
adxl345 accel;

int acc[2];

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  accel.initBasic();
  attachInterrupt(0,sample,CHANGE);
}

void loop()
{
}

void sample()
{
  accel.getValues(acc);
  Serial.println("it works");
}

The .h file:

#ifndef Adxhl345_h
#define Adxl345_h
#include <Arduino.h>

/* Basic functions */
#define ADXL345     0x53 //ADXL345 address
#define BW_RATE     0x2C //Data rate and power mode control
#define DATA_FORMAT 0x31 //Data format control
#define OFFSX       0x1E //OFFSet
#define OFFSY       0x1F
#define OFFSZ       0x20
#define POWER_CTL   0x2D //Power-saving features control
#define DATA        0x32 //to 0x37 address, XYZ axis data (16-bit)

/* Unused functions - Advanced functions*/
#define THRESH_TAP    0x1D
#define DUR           0x21
#define LATENT        0x22
#define WINDOW        0x23
#define THRESH_ACT    0x24
#define THRESH_INACT  0x25
#define TIME_INACT    0x26
#define ACT_INACT_CTL 0x27
#define THRESH_FF     0x28
#define TIME_FF       0x29
#define TAP_AXES      0x2A
#define ACT_TAP_STAT  0x2B
#define INT_ENABLE    0x2E
#define INT_MAP       0x2F
#define INT_SOURCE    0x30
#define FIFO_CTL      0x38
#define FIFO_STATUS   0x39

class adxl345
{
protected:
	byte rate;
    byte format;
    byte offs;
    byte power;
	byte int_map,int_enable;

	byte tab[5];
	int out[3];
	void write(byte address, byte val);
	void read(byte address, int num);
public:
	void initBasic();
	int getValues(int* out);
private:
};

#endif

The .cpp file:

#include "Adxl345.h"
#include <Wire.h>

void adxl345::write(byte address,byte val)
{
	Wire.beginTransmission(ADXL345);
	Wire.write(address);
	Wire.write(val);
	Wire.endTransmission();
}

void adxl345::read(byte address, int num)
{
	Wire.beginTransmission(ADXL345);
	Wire.write(address);
	Wire.endTransmission();

	Wire.beginTransmission(ADXL345);
	Wire.requestFrom(ADXL345,num);

	int i=0;
    while(Wire.available())
	{
		tab[i]=Wire.read();
		i++;
	}
	Wire.endTransmission();
}

void adxl345::initBasic()
{
	/*register values*/
	int_map=0b00000000;
	int_enable=0b10000000;
	rate=0b00000110;
	format=0b00001011;
	power=0b00001000;

	/*initialization procedures*/
	write(INT_MAP,int_map);
	write(BW_RATE,rate);
	write(DATA_FORMAT,format);
	write(INT_ENABLE,int_enable);
	write(POWER_CTL,power);//3200Hz samples, Normal operations, Full Res, No sleep

}

int adxl345::getValues(int* out)
{
	read(DATA,6);
    out[0] = (((int)tab[0]) << 8) | tab[1];
    out[1] = (((int)tab[2]) << 8) | tab[3];
    out[2] = (((int)tab[4]) << 8) | tab[5];
}

And the INT1 pin from the accelerometer is connected to the A0.
And ignore the fact that are some ,errors" in the library. (i.ethe device is actually working at 6.25Hz, not 3200)

I'm assuming reading the values clears the interrupt on the ADXL345, so modify the setup function like I show below.

void setup()
{
  Wire.begin();
  Serial.begin(9600);
  accel.initBasic();
  attachInterrupt(0,sample,RISING);
  accel.getValues(acc);
}

No. It doesn't. I don't understand how could this configuration be different from what I have posted?

You had the Arduino interrupt set to happen on both the RISING and FALLING edges. I has hoping reading the values would clear the ADXL345 interrupt, so the second interrupt would be caught be the Arduino.

Try disconnecting the ADXL345 interrupt line to the Arduino and manually connecting and disconnecting 5V (Vcc) to interrupt line of the Arduino. Does the interrupt happen?

I've already made this test and the Arduino doesn't seems to respond. And I'm sure that those are the pins. Checked in the datasheet and with a multimeter.

I noticed an error in your first post of this thread. “Interrupt 0” is for Arduino digital pin 2, and “Interrupt 1” is for Arduino digital pin 3. Does this help?

Here I'm in doubt. I'm not sure which are the good pins. I've looked in the datasheet, but I don't quite understand very clearly.

On the ATmega168 with the 32TQFP package, pin 32 is INT0 ("Interrupt 0"), and pin 1 is INT1 ("Interrupt 1").

Yes, man, it worked. You were right. Who the *** would have imagined that interrupts sensor are actually the Radio RC pins? =(

But, Thanks A lot, this was the time consumer of the day, this topic :D