Hi,
I have heard that the arduino interrupt pins are not stable.
How to fix this issue?
Thanks!
Hi,
I have heard that the arduino interrupt pins are not stable.
How to fix this issue?
Thanks!
(deleted)
mparduino:
I have heard that the arduino interrupt pins are not stable.
You heard wrong.
I have no evidence at all.
I am trying to use the interrupt pin to read/calculate the tachometer of a fan.
If it is not stable, the result would be inconsistent. That's what I am afraid of.
What have you used the interrupt for? How do you know it is stable?
mparduino:
I have no evidence at all.
How about you find some, then worry?
mparduino:
How do you know it is stable?
Because millions of AVR chips are responding to interrupts as I type this.
Is the fan generating a 5V logic signal? Have you common grounds?
I find them stable lol.
Altough I do hardware debounce on the external interrupts pins using a schmitt trigger and a capacitor in paralel to the switch/trigger as a filter. Ive used both pins on Atmega328p at the same time with multiple interruptions and work very reliable. But if you are working with tachometer, make sure the filter frequency supports your desired rpms.
mparduino:
I am trying to use the interrupt pin to read/calculate the tachometer of a fan.
Why would you be wanting to use an interrupt to do that?
Debouncing may or may not be a concern, but is much easier and more appropriate to implement in software, and a fan tachometer is a slow process easily dealt with by a polling loop. It's all a matter of writing good code.
You'd want an interrupt routine to do that so you never miss pulses when
the processor is bogged down in calculation of course. Perfectly reasonable.
We need to establish if this signal is a logic signal or an analog one though,
if its analog then it will need proper conditioning which could explain
apparent unreliability.
The OP needs to post their code if we are to find bugs in it too (lack of
volatile declarations, unprotected access to multibyte variables, etc).
MarkT:
You'd want an interrupt routine to do that so you never miss pulses when the processor is bogged down in calculation of course. Perfectly reasonable.
Actually, no!
Counting pulses consists of two parts, counting the pulses and counting the time because you are wanting to determine a speed - the number of pulses per time. And you cannot count the time while you are "bogged down in calculation of course", so there is no point counting pulses at that time anyway.
OK, so you argue that your interrupt routine can count the time as well. Really? Presuming you do, what then happens when the counting period expires and you have to stop counting? If you are going to stop counting, you might as well wait until you stop counting to do the calculations and display.
Fancy taking it up a notch? At the end of the counting period, you will save the count (and the time) in a FIFO and start counting again? Really? Is your processing (and I use the term without capitals) routine going to take less time than the count interval in order to keep up with that buffer? Well, if you knew that for sure then I suppose you can count in interrupts and sit and wait for the time to expire after each pass of the "bogged down in calculation of course".
In general, it is most unlikely that you will need to simultaneously count and process the last result, and certainly not for a mere visual display. A slightly different situation if you are implementing a PID loop but even there the benefit of more frequent samples is fairly negligible unless you are working at close-to-limiting speeds.
MarkT:
You'd want an interrupt routine to do that so you never miss pulses when
the processor is bogged down in calculation of course. Perfectly reasonable.
It all depends on how clean your signal is and how "bogged down" the CPU is.
If it's too "bogged down" then maybe you need better code.
Doing things like this with interrupts sounds nice/cosy but it can easily cause as many problems as it solves (both from the programming point of view and if the input signal is anything less than perfect).
PS: Timer1 on a Mega328 has a hardware pulse counter with a selectable noise cancelling unit on the input. I'd use that before using interrupts.
Hi all,
Appreciate your help!
You are all flying up there, please come down so I can reach you ![]()
What I am doing is to design a fan tester that calculates the fan rpm(s). It works fine. However, there are two things that I am considering:
I heave heard that the interrupt pin of arduino is unstable. Just heard but have no prove! If it is true, how to fix? If not, just tell me. I will listen to you and no more worry about it.
As I posted on the previous mail that, with a certain bad fan which doesn't even spin, it gave a strange sawtooth noise, then gave a wrong result. How to recognize that "weird" signal and how to filter it?
We told you, interrupts work, they've always worked, there isn't an issue.
Replace the bad fan with a working one.
[ and where's the datasheet / info on your particular fan(s) ??? ]
TOO SIMPLE!
A saw-tooth waveform is not a logic signal. So it can't go to any digital input, interrupt
or otherwise without conditioning.