Pages: [1]   Go Down
Author Topic: LCD on tractor mounted sprayer intermittently showing strange characters  (Read 1051 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

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.



Thanks!

Code:
#include <LiquidCrystal.h>

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;

void setup()
  {
    attachInterrupt(0, countPulse, FALLING);
   
    pinMode(10, OUTPUT); // backlight
    digitalWrite(10, HIGH);
    pinMode(pulseIn2, INPUT);
    digitalWrite(pulseIn2, HIGH);
    pinMode(resetButton, INPUT);
    digitalWrite(resetButton, HIGH);
   
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("DNS Farms");
    lcd.setCursor(2, 1);
    lcd.print("flow totalizer");
    delay(2000);
    lcd.clear();
  }
                 
void loop()
  {
    uint8_t oldSREG = SREG; // save current interupt status
     
    cli(); // disable interupts (can also use noInterrupt())
    if(pulses >= kFactor)
      {
      gallons++;
      pulses = (pulses - kFactor);
      }
    SREG = oldSREG; // restore old interupt status
   
    lcd.setCursor(5, 0);
    lcd.print(gallons);
    lcd.setCursor(3, 1);
    lcd.print("Gallons");
   
    if(digitalRead(resetButton) != HIGH)
      {
        lcd.clear();
        lcd.setCursor(3, 0);
        lcd.print("*RESET*");
        delay(1000);
        lcd.clear();
        gallons = 0;
        uint8_t oldSREG = SREG;
        cli();
        pulses = 0;
        SREG = oldSREG;
      }
  }
                 
void countPulse()
  {
    pulses = (pulses + 100);
  }
                 
                 
   
Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2624
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps adding a clear will erase any bad characters (may need a delay too):

Quote
SREG = oldSREG; // restore old interupt status
    lcd.clear(); 
    lcd.setCursor(5, 0);
    lcd.print(gallons);
    lcd.setCursor(3, 1);
    lcd.print("Gallons");
    delay(2000);
    if(digitalRead(resetButton) != HIGH)
Logged

The way you have it in your schematic isn't the same as how you have it wired up!

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply Larry.

Do you have an idea what the root cause of the bad characters is, or is it normal to have to put in a lcd.clear() function as you have shown?


Thanks again!
Logged

Sugar Grove, Illinois USA
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not an expert but have seen feed back issues from motors, solenoids, and servos, usually on a different power supply from the arduino.

Since your issue is only when the motor is running, maybe the alternator.

You can experiment with automotive chokes or filters. The same type of feed back is an issue for radios aka speaker hum or hiss.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Do you have an idea what the root cause of the bad characters is...
Probably electrical interference from your tractor or other devices.  Welcome to the real world.

Quote
... or is it normal to have to put in a lcd.clear() function as you have shown?
Generally speaking it is better to avoid using lcd.clear within loop() if you can.  That particular instruction takes much longer to execute that most of the other instructions and it's use can cause the display to flicker if you run around the loop too quickly.  

Putting a delay in the loop can help clear up problems such as flicker but I don't see how it can fix up problems created by electrical interference from your tractor or other devices.


Don
« Last Edit: June 17, 2013, 09:00:02 am by floresta » Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a look at possible earth loops between your supply ground and maybe the sensor ground.
I've got a similar problem with garbage characters being displayed when a relay switches. I've not investigated yet and it does not happen all the time. My application is linked to my solar PV system and the relay only operates when there has been a lot of sun in the day.

Bob
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Welcome to the real world.

Thanks for welcoming me!  smiley

Now I would like to find a real world solution smiley

Actually, I don't think it is an electrical noise issue any more. When I took the screws off the enclosure cover recently, I grabbed the handiest tool, which was a small cordless impact driver. When the driver impacted on a screw I was removing, the display all of a sudden threw some bad characters. I then cleared it and tapped the side of it which threw some more bad characters.

Here is the LCD normally




Here it is after a little thump on the side of the enclosure



Are LCD displays usually this sensitive to jarring or vibration or is their probably a poor connection somewhere on the shield?

Thanks for all the help!

Jon
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 35
Posts: 4299
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are LCD displays usually this sensitive to jarring or vibration or is their probably a poor connection somewhere on the shield?
Possibly between the 'glass' and the pc board on the LCD module.  That's just a pressure fit with the pressure supplied by the black bezel around the glass.  Try monkeying around with that.

Don
Logged

Australia Mate!
Offline Offline
Sr. Member
****
Karma: 3
Posts: 284
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

L.C.D.

Liquid
Crystal Displays, where not designed for what you are doing, they where designed to be stationary or non moving environment.
TFT & Oled displays overcame these disadvantages.

While segment & higher priced QCD Quart Crystals Displays (exstinct) filled this niche.
Logged

Pages: [1]   Go Up
Jump to: