I'm trying to implement an arduino to control a LED RPM histogram and trigger a shifter relay for automatic upshifting. The engine control unit (ECU) is able to output the RPM data in two forms: PWM or tachometer output. The PWM is configurable to different frequencies (~6Hz-980Hz range, I have it currently set at 189.5Hz) and adjusts the duty cycle based on the RPM. The tachometer output gives a Hz/RPM signal.
So far I haven't had any luck with using the PWM output and using the pulseIn() function to interpret the duty cycles. I haven't gotten around to using filters to smooth out the signal into an analog function.
Any suggestions on how to approach the challenge? Both the arduino and ECU are on the same battery, thus referencing the same ground.
Cheers,
You can use an interrupt and capture the time using millis() or micros(). If you only interrupt on one edge you will get frequency and if you interrupt the change in pin state you can measure the pulse width by subtracting the rising edge time from the falling edge time. The PulseIn() function should do it also.
I have a sketch here that measures the width of a pulse. If you adapt that a bit you might be able to measure the length of the duty cycle. Since the frequency is known, you only need to know the width of either the on or off pulse.
Hi,
If you have a look at the 'how to read an RC receiver' example on my blog it's basically doing what you want, as is Nicks.
Duane B
rcarduino.blogspot.com
Doing it in the Arduino should be possible and fun to do, but have you considered that you could achieve what you're asking for just using the tacho output and a standard shift light?