# Which type interrupt for measuring square wave

First time poster here I hope I put this in the correct spot. I am also very green to the world of micro controllers and code.

The project at hand is for automotive application, using a mega 2560, sending all data to processing. Goal is to sample four voltages, and 10 channels of square waves.

So far I used firmata and have been able to setup, map, and read the analog nicely.

I setup a digitalread and read the square wave of a 555 timer all was fine until I bumped the frequency up then quickly found I need an interrupt.

Resin for this project is I think My distributor hall effect is intermittent so unfortunately I can not use the PIP signal for my interrupt. I was thinking of maybe a 555 timer with a POT to adjust the frequency of the interrupt?

If my math is correct at 1000 RPMs the frequency is 66.66~Hz distributor spins at 500 on an 8 cylinder that's 8 pulses per rpm 500*8/60?

If the 555 timer is the way to go what should the frequency be?

Thanks, Dom

If there are ten channels then pin change interrupts seem the only feasible technique. You'll have to make the interrupt routine mask out which pins have actually changed since the last interrupt, going to be rather complex.

Ok thanks at least I know I'm going in the right direction.

The only thing I forgot to mention was during the interrupt all I want to do is read and send the data off to processing of all 10 pins but fast enough so I do not miss any abnormality in the ignition signal. How much faster should the interrupt be compared to the 66.66hz of the ignition output?

You can determine which PCINT occurred in a matter of microSeconds. 66 Hz is 15000 microSeconds. If all you want is read 2 ports and send out 2 bytes so processing can determine which bit(s) changed, that will be the same small number of microSeconds.

You just record timings in the interrupt routine(s), the main loop code will need to work out the frequencies, grab the analog samples and send them back...