I have a Arduino Uno R3 with a 16*2 Linksprite http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino
LCD display shield that is hooked up to a flow meter to read pulses and totalize flow. This is mounted on a farm sprayer that is pulled behind a tractor.
Initially I had the Arduino hooked directly up to the DC battery power on the tractor. While I knew I was pushing the limits with the Arduino voltage regulator only rated for 15 volts and the alternator on the tractor outputting 13-14 volts, the power draw was very low so I thought it might be OK. Initially it appeared that the display worked fine, but I noticed that sometimes I would get strange characters showing up on various parts of the display. Sometimes the data I was displaying would show up in a different part of the display in addition to where it was suppose to be. If I would push the reset button, (which executes a lcd.clear function) the display reads correctly and the extra characters go away.
I then tried to power the project with it still hooked up to the tractor, but the tractor not running. I left it powered on this way for a day with no problems. I figured there must be some type of electrical noise or spike in the power that was causing my problems, so I hooked up a small DC to DC converter out of an old cell phone car charger. The converter is a switching type based on this IC http://www.datasheetcatalog.com/datasheets_pdf/M/C/3/4/MC34063.shtml
. It is set up to output 8 volts. After powereing thru this converter I still have the same problem, not only when the tractor is running, but all the time.
I don't believe the issue is in the sketch, but I will post it below.
In looking around the forum a little I picked up that repeatedly using the lcd.print function may not be a good idea if what it is printing doesn't change. I also saw delays being added in another post. Because it worked fine with the tractor shut off and powered directly from the battery, I am still thinking it is a power issue, but I don't know for sure. If anyone would know what is causing this problem and how to rectify it, I would appreciate the help.
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
const int pulseIn2 = 2; // interupt number 0
const int kFactor = 1358; // calibration constant with two implied decimals
const int resetButton = 3;
volatile int pulses;
unsigned int gallons;
attachInterrupt(0, countPulse, FALLING);
pinMode(10, OUTPUT); // backlight
uint8_t oldSREG = SREG; // save current interupt status
cli(); // disable interupts (can also use noInterrupt())
if(pulses >= kFactor)
pulses = (pulses - kFactor);
SREG = oldSREG; // restore old interupt status
if(digitalRead(resetButton) != HIGH)
gallons = 0;
uint8_t oldSREG = SREG;
pulses = 0;
SREG = oldSREG;
pulses = (pulses + 100);