Pages: [1]   Go Down
Author Topic: Interrupt not seeing all pulses  (Read 722 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there, I am pretty new to Arduino, so I might be missing something obvious here.

My goal: Read PPM input generated by a PPM Encoder (attached to a 2.4GHz RC receiver) with an Arduino Pro Mini (16MHz, 5V).

Decoding of all the channels is working when using pulseIn(), but I need more processor time in between so I am trying to use an interrupt.

When attaching an interrupt handler on pin 2 (interrupt 1) I am only seeing the frame pulses. Because PPM frames are 20ms, I only get 50 interrupts per second, which should in my opinion be 450/second.

My Logic Analyzer is seeing all the pulses (450/second), and pulseIn was also seeing them, so my main question: Is it possible the interrupt handler is not working correctly?

I already now the PWM-out pins 9 and 10 are not available when using Timer 1, so I have made sure they are disconnected.
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3487
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe your interrupt handler is just to slow. While the interrupt handler is busy you can not see any further interrupts. It all depends on what you coded inside of it.

Udo
Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Udo. thanks for you suggestion, the only thing in the interrupt handler right now is one expression that simply increments the counter I use to determine the amount of interrupts being called. I also added a 10ms delay in the main loop to give the processor time to process the interrupts (not sure if it works that way, but anyways can't hurt I guess).
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3487
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Remove the delay! It does hurt.
« Last Edit: October 15, 2010, 03:52:01 pm by udoklein » Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

An image for clarification:



The small and equal downs+ups are 0.3ms wide.
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3487
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Some implementations of delay will block interrupts. Remove the delay.
Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just added the delay in the main loop to test whether it would give space to the interrupt, but I have removed it now, the interrupt is still not called more times.
Logged

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3487
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Strange, post your code.
Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ah I found the problem. I was listening to interrupt 1 (pin 3) which should have been interrupt 0 (pin 2). I still don't understand where the 50Hz pulse was coming from (maybe pin 3 was picking up the 'average' values from pin 2?

Thanks for your help Udo, you question about posting the source made me create a small version of the problem which made me find my own mistake smiley
Logged

Pages: [1]   Go Up
Jump to: