You don't need to convert it to a square wave, but it looks like the signal is an inductive pickup. You are going to have to limit the voltage to the Arduino's range 0..5V.
I could not see the voltage range from the Oscilloscope. Was the voltage symmetric about the 0V level?
You could use some resistors and diodes to clamp the voltage between 0..5V.
Here is a simple circuit. It is just a guess it should not damage the tach. Wire it up and see what the waveform between GND and INTERRUPT.
The waveform should be a chopped copy of your sine wave. limited from 0 to about 4.5v
when you say:
"was the voltage symmetric about the 0V level"
do you mean the waveform goes above and below the 0V level ?
Ill have to get another better screenshot of the waveform.
does the circuit you outline isolate the ground in this sensor circuit ?
because when I connect my tap on the black sensor wire to arduino ( and motorcycle common ) ground
the sensor does not work properly, and engine stops running.
375k red sensor wire resistance to GND
365k black sensor wire resistance to GND
0.98K across red/black terminals of sensor
and in the attached drawing, am I clarifying the connections correctly ?
What type sensor is on the engine? It appears it is a missing tooth sensor. Can you verify that. A pic of the sensor mechanism might help.
edit: The reason I say that is if you watch the o-scope display closely, every now and then you will see a gap between pulses that is missing a positive pulse.
This should be somewhat like your crankshaft. Note the missing teeth.
You will need to determine the normal time between pulses, then wait for the missing pulses. The time between pulses in that gap will be much longer (4 times?) than the normal duration.
edit: I would use interrupts and save the microsecond reading for this pulse, and compare it to the last pulse microsecond reading, then check the average time. If that gear has 36 teeth with some missing (10 degrees between non-missing teeth), the time between non-missing teeth should be 1388 microseconds at 1200RPM. If the time between those is more than twice (greater than 2700us), you just went by the gap (missing teeth).
I recommend checking my math. I think that is correct.
oelbrenner:
so this is how I have it hooked up ( see attachment )
but I cannot read the pulses with arduino
here is my code:
The sensor is giving multiple pulses per revolution. I agree with others, that you need to write a 'missing pulse' interrupt routine something like this.
Try changing your countRPM()
// counts tach pulses
static volatile unsigned long shortPulse=0;
static volatile unsigned long lastPulse=0;
void countRPM()
{
unsigned long now = micros(); // current microsecond counter
unsigned long nowPulse = now - lastPulse; // microseconds since last pulse
lastPulse = now; // new starting point
if((nowPulse >> 1)>shortPulse){
/* if nowPulse was over twice as long a short pulse then must be Top Dead Center
count as one revolution
*/
RPMpulses++;
shortPulse = nowPulse;
/* since shortPulse starts at 0, any value greater than 1 is more than twice a large as zero.
so if I assume the current pulse is the 'long' pulse and set the short pulse that long,
the next pulse should be the shorter pulse. If it is not, the else case will correct it.
*/
}
else { // just another short pulse, engine may be changing speed so update current shortPulse
shortPulse = nowPulse;
}
}
Can you describe your scope settings?
What is the Purple ringing Wave?
What is the blue trapezoid wave?
What are the time periods, what are the voltages (milliseconds per division, volts per division, where is the 0v reference line?)
Ill try the missing pulse code tomorrow, but I am getting nothing at all
zero pulses.
even with the gap in pulses I should get some count right ?
getRPM is always returning zero.
the purple wave on the scope are because I have no idea how to use that scope beyond how its working.
I was able to turn off the display of that purple wave at some point, but neglected to on this run.
I have it on a 5V range, with 1ms refresh
with a 1.0V falling trigger ?
my RPM calculation is a bit off tho, showing idle RPM around 1120 to 1150
when its supposed to be closer to 900, but I need to verify with a real calibrated tachometer.