Interrupt PIN Bouncing

OP #5642495
Hello,

I am posting this in this category because I think its a hardware/ 
electronic problem.

short summary:
I am using Raspberry Pi 3 with a ADXL345 Accelerometer. I want to read 
data only if the DATA_READY bit is set and a Interrupt is thrown.
The data sheet of the sensor says: If new data is ready, the Interrupt 
is thrown and sets the PIN (which is mapped to the interrupt) to high. 
Its high until I read data from the data registers. If new accel data is 
available, the interrupt stays high (dont jumps to low and high again).
I connected the INT1 PIN with PIN17 of my GPIO.

As you see in the attachment, the four PINS on the top are the CS, MISO, 
MOSI and the SCLK. The lower one is PIN17, which is the interrupt. As 
you see it jumps up and down, changes its state every 450 us. (my 
sampling rate is just 0,78 Hz).

I think there no problem with my code, but I will post it below.
For the SPI comunication I am using the spidev.h and ioctl.h. For the 
interrupt handler I am using the wiringPi package, which works fine 
(obviously it calls my ISR way to often).

Thank you very much in advance.

Code is in the attachment.
Attached files:
Moderator (Company: Titel) #5642520
Manuel M. schrieb:
> I think there no problem with my code, but I will post it below.
I think you better done this way:
1
Reply
2
Rules — please read before posting
3
    Post long source code as attachment, not in the text

> As you see it jumps up and down, changes its state every 450 us. (my
> sampling rate is just 0,78 Hz).
What happens when you don't read the sensor?
OP #5642565
Lothar M. wrote:
> I think you better done this way:Reply
> Rules — please read before posting
>     Post long source code as attachment, not in the text

Thank you for your answer.
I attached the code.

Lothar M. wrote:
> What happens when you don't read the sensor?

Actually I am not reading it right now. The sensor measures but I am not 
reading the data.

If I disable the interrupts (cli()) or go in STAND_BY mode, the 
Interrupt PIN is at low (and stays low).

If I try to read data if a interrupt is thrown, what happens is:
Until my programm reads the data (in the ISR), the Interrupt jumped 
already up and down several times. So my ISR is called at least 2-3 
times until I print out the measurements.
OP #5642666
Here you see how I tryed to sample with 25 Hz. I used a stopwatch to 
measure the time. I stopped it after 250 samples, so normally after 10 
seconds. But the stopwatch measured 9,2 seconds. Thats because the 
interrupt was thrown too often (and counted the interrupt counter).

Maybe on the picture it looks like it, but the clusters happens also 
during the programm, not only at the beginning.
Attached files:

Reply

A question of your own? This thread is over 7 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.