Tach input to interrupt (help needed)

Hi,

I'm new to the board. Have an Arduino Duemilanove I've been toying around with for a while now.

At the moment I am trying to create a very basic tachometer using my Arduino (and I know many have made one before me).

The trouble is that I cant get a reliable signal from the interrupt 0 pin.
I'm using a "stimulator" for input (built to test my megasquirt DIY ECU). It has a microcontroller to generate a tach frequency (which is adjustable with some potentiometers).
This stimulator does not have it's own 5v regulator so I built a little input circuit using a PNP transistor to switch the interrupt (pin2) between Arduino's 5v and Gnd (with a pullup on the 5v side of things). I just apply the 12v tach output from the stimulator to the base to switch.
Yes I know it's a dirty circuit, but it was the best I could do with what I had lying around.

When I feed this input to some code that just increments a counter on every interrupt and then reads the number of pulses every 200ms (after which it resets the count) I get some very erratic numbers.
They look somewhat proportional to the frequency I set on the stimulator but it seems like the interrupt is triggered at least >10 times for every actual rising edge on the tach input.
The stimulator is working 100% correctly, I verified this on my megasquirt ecu.

Does anyone have some advice in this matter?
I strongly get the feeling I should be referencing the grounds of both boards to eachother, but since I havent got my head around getting them to share the same supply I'm not sure that would be wise.

Also: Just having a wire on pin2 that is not attached to anything also causes lots of interrupts, is this pin really that sensitive??

Thanks in advance for any usefull suggestions!

Regards Ivan
(from the netherlands in case anyone has problems with my english).

How do you know that there aren't multiple square waves each revolution output from the stimulator?
Maybe post some of your code so it can be reviewed.

  1. A floating(un-connected) input pin will go all over the place. putting a piece of wire on it will make a nice antenna for random rf in the environment.

  2. If you don't connect the grounds of your two circuits the arduino's pin is still floating(although the 5v pullup should mitigate it).

Anyway, I would suggest connecting the grounds and use a simple voltage divider to bring the 12v down to a 4-5 v level. like a 10K from the simulator to pin 2 then a 5k to ground from there.

good luck.

It's not just "wise", it's absolutely essential that you tie the grounds together. It's 99+% certain that's the reason you're having problems.

Thanks for the input guys. I added a wire connecting both grounds and my problems where solved.
I should have known better with my bachelors degree in electrical engineering but that's what you get when you turn to the dark side too long (software development).
Was way too worried of what might go wrong because the arduino is fed by USB and the stim from it's own 12v adapter.

I did skip making a voltage divider for the transistor base voltage for the time being, it should be able to take the punishment I would suspect.

Now onwards to make some staged shift lights..