Nano: Problems using Interrupt Pin

I have a very frustrating problem.

I am using an Arduino Nano to control the speed of an engine based on the hall sensor trigger. I need to work in microseconds.

I used a Nano before on a Cruise Control that I build for my Land Rover, and it is now in service for many years, so I know it has to work.

When I use the Interrupt routines, both INT0 or INT1 are constantly triggered. Yet, if I change the program and just check for a change of state of the input in the main loop, it works very well, although some accuracy is lost in the timing due to not using the hardware interrupt. No why would it work one software way but not the other.

I have checked the input signal with my oscilloscope and it is IMHO a clean square wave signal switching positively between 0 and 5V. The power supply from VCC also looks good. Yet, it gives trouble at the application but when I remove the Nano and take it to the bench, there seems to be no problem with the interrupt routine - although I cannot trigger it that fast by hand. Using a signal generator, give no problems. I went through some great pains to ensure there are no floating earths.

I have used this exact same input on an Attiny85 and on the Attiny the interrupt works well, but it is a pain to change the program hence my change to the Nano. Also the Nano runs at double the speed so it should handle this routine with no effort.

I tried to manually reset the Interrupt flag of the Nano, but it makes no difference. I tried both Rising ang Falling edge, no difference. It seems like it triggers on LOW value all the time. I even changed Nanos.

I tried using different Arduino IDE versions for compiling and uploading if perhaps there was a bug in the interrupt routine. Bear in mind I am not an expert coder.

What else can I check or try?

1 Like

I have had problems as well but mine turned out to be background interrupts from another source and interrupt such as the mills interrupt.

That's a requirement only for catching the hall sensor ticks, not for further processing.

You can use the faster PCINT interrupts instead of the INT0/1 callbacks.

1 Like

Will give it a try!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.