Random characters on LCD while using a DC Motor

Hi

I’m currently working on a water level indicator project. I’m using an ultrasonic distance sensor( HC-SR04) to compute the level of water in the tank and display the same on an LCD. (16X2) This part of my project works fine. However, I’m having problems when I connect a DC water pump to Arduino Uno, interfaced using a MOSFET transistor. ( IRF530) If the water level is below the minimum mark (specified), the pump is switched ON and is switched OFF when the water level reaches maximum height. (specified) The pump is powered by a 9V DC source.

When the motor is activated, my LCD shows random characters. Why does this happen? How do I fix this?? It’s kinda urgent. Please reply ASAP.
The source code and circuit diagram have been attached for your reference. I’ve used the LiquidCrystal header file.

Thanks in advance. Cheers.

WLI.ino (1.79 KB)

How is your Arduino being powered?

I see you have AA batteries to power the motor, but how is the Arduino board powered?

Also, you never set your cursor to (0, 0) initially. Make your void setup look like this:

void setup() {
  // put your setup code here, to run once:
  pinMode(TRIG, OUTPUT);   
  pinMode(ECHO, INPUT);
  pinMode(MOTOR, OUTPUT);
  Serial.begin(9600);       
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);       
  lcd.print("LEVEL= ");

and tell me if that helps.

Also, you never set your cursor to (0, 0) initially. Make your void setup look like this: . . .

That's already done by the initialization routine so why duplicate it?

Don

When the motor is activated, my LCD shows random characters. Why does this happen? How do I fix this?? It's kinda urgent. Please reply ASAP.

Why not take the time to look through some of the previous posts on this topic? Use the search box at the upper right and look for LCD Weird motor.

Don

AQUSENS_bb.png

floresta:
Why not take the time to look through some of the previous posts on this topic?

Eminently sensible advice.

I may just cheat however, and point out two things to start with.

One is that you need two extra capacitors, one an electrolytic of between say 22 and 100 µF between the logic supply pins on the LCD module, presumably pins 1 and 2, and something in the range of 0.1 to 0.47 µF ceramic between the motor terminals.

Secondly, you are using the wrong FET to control the motor with an Arduino.

@Chummer100 The Arduino is powered by my PC/laptop.

@Paul__B That totally solved the problem. Thanks a ton!
And thank you everyone for your valuable inputs.

Two more question though… Why did the problem arise and how did the capacitors fix this?? I need to make a presentation in front of profs. So, I need to explain the purpose of the components used.

And what’s wrong with this MOSFET? Please suggest a model that would be appropriate for this project…

Thanks in advance. Regards.

Brathindra: Two more question though... Why did the problem arise and how did the capacitors fix this?? I need to make a presentation in front of profs. So, I need to explain the purpose of the components used.

And what's wrong with this MOSFET? Please suggest a model that would be appropriate for this project...

Sure!

Firstly, the FET does not properly turn on with only 5 V on the gate. You need a "Logic Level" FET which in this case would be the IR*L530 instead of the IRF*530.

The motor in operation (its commutator) produces voltage/ current "spikes" which are coupled back through the common power supply or even simply by inductive effects from one part of the wiring to another. The capacitor across the motor reduces these at the source, while that across the display provides some immunity against them actually getting to the display driver and interfering with its operation.

You also have to be careful with "lead dress" - keep all wires from one unit to another together and avoid power and return wires at any part from forming an open "loop" which can form a single turn inductor/ antenna/ transformer "winding" to couple to another such loop.

Okay. Will change the transistor. Thanks a lot! :)

I think there is a flyback diode (across the motor pins) missing.

Paul__B:
AQUSENS_bb.png
Eminently sensible advice.

I may just cheat however, and point out two things to start with.

One is that you need two extra capacitors, one an electrolytic of between say 22 and 100 µF between the logic supply pins on the LCD module, presumably pins 1 and 2, and something in the range of 0.1 to 0.47 µF ceramic between the motor terminals.

Secondly, you are using the wrong FET to control the motor with an Arduino.

Hi Paul
I tried the same thing for my project with cap and all , but still when motor runs I get wrong values . Plz help

Perhaps this is due to motor noise?

chummer1010: Perhaps this is due to motor noise?

Yeah I think