Dear mem and all Arduino Forum folks,
I am trying very long to input four digital inputs to Arduino Diecimila clon, from my diesel engine car.
It handles well two signals, but seems to be unable to cope with four.
Member “Mem” (knows a ton) has helped me a lot and suggested to INPUT two sensors vía DigitalRead() and two vía pulseIn() commands.
Clever solution. The first two work reasonable well. However, the last two aren´t working acceptably well for me.
There is more than 2 months I am working in this project. Should I throw away my Arduino board? Hope not. I like it. Much.
Here is the sketch:
/* ============= Millis per Pulse counter ============*/
// ---------------- using PulseIn ---------------------------
/* ------------- reset pins, define pins, variables ---------------- */
int resetPin = 3; // pin 3 resets the time
int pin = 3;
/* ------- create object to control an LCD GMD1602K -------*/
LiquidCrystal lcd(12, 11, 6, 7, 8, 9, 10);
/* ============== SETUP ==================== */
lcd.clear(); //cleans display
pinMode(pin, INPUT); // a button on this pin resets the time
digitalWrite(resetPin, HIGH); // enables pull-up
DateTime.sync( 0 ); // set time to zero
/* ========= Execute program over and over ===========*/
duration = pulseIn(3,HIGH,1000); //counts milliseconds between two pulses
rpm = 200*(60000/duration); //converts milliseconds to rpm. The “200” figure is empirical.
lcd.print(duration); // pints duration of pulse in millis
delay (500); // delay to allow printing
lcd.print(rpm); // prints rpm
delay(500); // delay to allow printing
Results are printed on lcd. Both, millis and rpm.
However, the problems:
Reasonable figures at idle (around 830 rpm), but not stable at all.
The tachometer of the car with the same input, is very stable. However, it displays rpm figures in an analog gauge.
If I accelerate, results may vary about 200% around “center values” but very unstable. Like dancing.
Values for millis and rpm turn zero from time to time.
Every time I plug the board in the car or in the PC, I have to reset Arduino manually, sometimes, repeatedly, to make it work.
Otherwise, nothing is displayed.
Analog inputs are working well and stable.
I have a voltage dividers with a filtering capacitor to earth at the pin at entrance of each sensor signal.
I have tested several time lapsus for pulseIn(3, HIGH, 1000), like 500, 2000 milliseconds sample time lapsus.
I have tested several delay() commands to better seen results, have tested with no voltage divider at the entrance, but results are more or less unstable, not stable.
Anyone had succeded with more that 4 pulse input signals in Arduino diecimila?
If so, please help with this. Please try to run the sketch, enter a pulse signal, and tell me what you get.
Thank you folks in advance.