Hello guys!
Since I'm new in the forum let me introduce myself: My name is Felipe, and I'm writing from Bogotá Colombia. I have some experience with electronics and programming languages, but Arduino is my first approach to the world of micro controllers.
If I can help you with something, I'll be glad!
Regarding my question, my project is a custom dashboard for my motorcycle. The plan is capturing speed, RPMs, fuel quantity and engine temperature, and then using that data to make a more complete and visually-appealing dashboard (hopefully that will come later).
On the hardware side, I've intercepted the wiring loom going to the OEM dashboard. The RPMs signal comes from the ignition circuitry, and are fed to Arduino's Analog input # 5.
The speedometer is installed on the front wheel, and sends eight +5V pulses for each wheel rotation. Naturally the pulse frequency is directly proportional to the wheel's rotation speed.
Fuel measurement is done with a potentiometer inside the fuel tank. The sensor is shorted to ground, and a full tank means almost zero resistance to ground. Fuel sensing is done with Arduino's #1 analog input, and it goes in series with the OEM fuel sensor.
On Arduino's analog Pin 0 there's a connection from an Dfrobot LCD + keypad module.
Temperature has not been implemented yet, I'm planning to do it using a LM35 sensor.
Now, the software side. The code is powered by the "elapsedMillis" library by John Ploche, and it works as follows: The RPM and Speedometer pulses are collected. Everytime the counter reaches 500 ms the rpm calculation is made from these pulses, and counter resets to zero (getting ready for a new stream of pulses). The speedometer, works the same way, but every 1000 ms.
Other functions are an odometer, an elapsed duration of travel indicator, and the fuel indicator showing % and litres available.
I was very happy with the code, it was even more accurate than the OEM dashboard. But then I made a dumb change and I spoiled it! It looks like this:
REAL RPM INDICATED RPM
1200 2100
2000 3000 - 3200
3000 4200 - 5000
and so on...
My suspicion is that some new instruction is stealing precious processor time, but after hours and hours trying I couldn't figure what was the change and why it doesn't work.
Please, if you can give me some light about the problem, I'll be extremely grateful. Attached is the code and some pics of the project.
Best regards
Panel_Hanna_OP04_7.ino (5.78 KB)