Hi everyone,
I'd like to know the sensitivity of the interrupt.
Say if I use attachInterrupt(INT0, ISR, CHANGE)
What is the bandwidth based on which the Arduino can tell if there is a change?
Thanks.
Hi everyone,
I'd like to know the sensitivity of the interrupt.
Say if I use attachInterrupt(INT0, ISR, CHANGE)
What is the bandwidth based on which the Arduino can tell if there is a change?
Thanks.
Unictu:
I'd like to know the sensitivity of the interrupt.Say if I use attachInterrupt(INT0, ISR, CHANGE)
What is the bandwidth based on which the Arduino can tell if there is a change?
In this context, what do you mean by bandwidth? Basically, if a rising edge or falling edge is detected, the interrupt will happen.
Say if I use attachInterrupt(INT0, ISR, CHANGE)
with a change, I think there should be a +/- tolerance before Arduino decide that's a change
Unictu:
with a change, I think there should be a +/- tolerance before Arduino decide that's a change
Well, it's a digital signal, so mostly, a change would be either 5V dropping to GND or GND rising to 5V. If the rise or fall time is slow, the transition point will be somewhere in between. Is this what you meant?
All signals have a rise time and a fall time, but in this context they are (or at least should be) so fast as not to matter or even be measurable without a good scope.
If your signal-generating device does not produce such fast pulses then you should clean the signal up, digital inputs don't like signals that are neither Arthur nor Martha.
So what is generating the interrupt signal?
Rob
Unictu:
Say if I use attachInterrupt(INT0, ISR, CHANGE)
with a change, I think there should be a +/- tolerance before Arduino decide that's a change
The interrupt is triggered based on whether the signal is a logical HIGH or LOW i.e. the same criteria that determines the result of digitalRead() for that pin. If I remember correctly, anything over 60% of your logic voltage is considered HIGH.
If you have a short pulse, this has to be in the changed state for longer than one clock signal of the processor to trigger the interrupt. The interrupt service routine must then finish before the next interrupt. With an irregular interrupt signal you can get one to register when the previous ISR is being done and the ISR will be called again.
All this assumes that when the OP says sensitivity he means time dependance.
Hi Graynomad, those are signals from an encoder, 200us ON-OFF squared wave .
Signal appears to be clean and consistent on the oscilloscope (paused, count & zoomed to check) but occasionally I had an extra value to the interrupt counter.
So I may try it again with a debouching circuit like the below.
That was also why I want to learnt the threshold of digital input pins.
lar3ry & PeterH, thanks mate. I think I found it here.
http://arduino.cc/en/Reference/Constants
When a pin is configured to INPUT with pinMode, and read with digitalRead, the microcontroller will report HIGH if a voltage of 3 volts or more is present at the pin.
When a pin is configured as an INPUT with pinMode, and read with digitalRead, the microcontroller will report LOW if a voltage of 2 volts or less is present at the pin.
When a pin is configured to OUTPUT with pinMode, and set to HIGH with digitalWrite, the pin is at 5 volts.
When a pin is configured to OUTPUT with pinMode, and set to LOW with digitalWrite, the pin is at 0 volts.
Well noted & hopefully Arduino interrupts work with the same threshold.
Check the datasheet! I hear it contains data like this.
Arduino Uno uses an ATMega328, Leonardo uses an ATMega32u4. Look at the info on your Arduino board (See Products Above) and then look up the chip on Digikey's or Atmel's site. If you look at the digital inputs section they should be able to give you the minimum time/voltage required. That being said, I would guess it is somewhere in the Megahertzs range based on experience and there is a good chance the connected circuit will limit your bandwidth more than Atmel's chip.
Unictu:
Hi Graynomad, those are signals from an encoder, 200us ON-OFF squared wave .Signal appears to be clean and consistent on the oscilloscope (paused, count & zoomed to check) but occasionally I had an extra value to the interrupt counter.
That was also why I want to learnt the threshold of digital input pins.
You haven't said, but I gather you tried an attachinterrupt() and couldn't get it working. If that's the case, I would ask you how you know it isn't working. You could post your code here for further discussion.
Putting in an RC filter circuit is a mistake, IMO.
Hi lar3ry,
void iniServos()
{
iniServo = 0;
getCountA(); //update & print counters from ISR if changes occur
getCountB(); //update & print counters from ISR if changes occur
//check phase A
if (countA == 13)
{
if (phaseA1 == 0) //not passed yet
{
phaseA1 = 1; //ok, this phase done
resetCountA(); //reset counter now
Serial.println("Initialization Phase A1 Done");
}
else if (phaseA1 == 1)
{
phaseA2 = 1;
resetCountA();
Serial.println("Initialization Phase A2 Done");
}
}
//check phase B
if (countB == 13)
{
if (phaseB1 == 0)
{
phaseB1 = 1;
resetCountB();
Serial.println("Initialization Phase B1 Done");
}
else if (phaseB1 == 1)
{
phaseB2 = 1;
resetCountB();
Serial.println("Initialization Phase B2 Done");
}
}
//check first stage
if (phaseA1 == 1 && phaseB1 == 1)
{
phaseIni1 = 1; //this phase done
}
//check second stage
if (phaseA2 == 1 && phaseB2 == 1)
{
phaseIni2 = 1; //this phase too
}
//check for completion
if (phaseIni1 == 1 && phaseIni2 == 1)
{
iniServo = 1; //ini done
phaseA1 = 0; //reset for next time
phaseB1 = 0;
phaseA2 = 0; //reset for next time
phaseB2 = 0;
phaseIni1 = 0; //reset for next time
phaseIni2 = 0;
}
void loop()
{
iniServos();
if (iniServo == 1)
{
Serial.println("Initialization Done");
Serial.println();
}
}
}
Ini stage includes 13 counts (LOW) of each pulses A & B forwards then backward.
iniServo = PhaseIni1 && PhaseIni2
with PhaseIni1 = PhaseA1 && PhaseB1
and PhaseIni2 = PhaseA2 && PhaseB2
original post here
http://forum.arduino.cc/index.php?topic=204759.msg1508598#msg1508598
If I used Nick Gammon suggestion to accept countA >=13 instead of countA ==13 then force reset all counter, I'd have more reliable outcome. However, occasionally I still have an extra counter although signal are clean, that was why I asked in this topic about filtering & input threshold.
Another question is how often one should update the global variable (CountA) that get its value from a shared ISR's variable? Only when needed or every loop?
I don't see any ISR or attachInterrupt () there, or any global variables, and that code makes absolutely no sense at all. loop() is inside iniServos(), etc. Won't compile.
I can't answer your other question until I look at that other thread. The question I have for you: Is that other thread your latest code, including the ISR? If not, pehaps you could post the latest, failing code in one thread or the other.
Unictu:
Hi everyone,I'd like to know the sensitivity of the interrupt.
Say if I use attachInterrupt(INT0, ISR, CHANGE)
What is the bandwidth based on which the Arduino can tell if there is a change?Thanks.
Looking at the synchronization circuit in the datasheet section 12.1 it looks as
a pulse of 1 clock cycle or more is guaranteed to be detected, shorter ones may
be detected (depending on when they fall compared to clock edges).
There is no noise-filtering so you have to provide a clean logic signal to the pin
to avoid spurious triggering.
Sorry I trimmed off the codes to make it short. I can only repost the whole thing after the new year as the laptop is far far away from me already.
Hope the festive season do not wipe everyone out until Feb.
Have a great holiday!