Pages: [1] 2   Go Down
Author Topic: Arduino program problem with DC input  (Read 1945 times)
0 Members and 1 Guest are viewing this topic.
Singapore
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I'm having problems when my arduino uno is plugged in with a 9V DC input.
When plugged with the USB cable, everything works fine.

Here is what my program is suppose to do:
(1) LCD monitor displays: RECYCLE BIN
                                  Let's Recycle
(2) When Capacitive proximity sensor is HIGH, display: Thank You!
                                                                        Cans: (no. of count)

When the arduino is powered by 9V DC:
step(1) is excecuted properly
but when sensor is HIGH, the whole LCD monitor is filled with black squares
when sensor is LOW, sometimes it goes back to what is shown in step(1), sometimes there are black squares on the first row, and sometimes nonsensical things come out.
I also noticed sometimes that the LEDs labled tx and rx lights up.

My program is as shown below:

Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
const int sensorPin = 7;
int sensorProxCounter = 0;
int sensorState = 0;
int lastSensorState = 0;

void setup()
{
  pinMode(sensorPin, INPUT);
  Serial.begin(9600);
  
  lcd.begin(16,2);                      
  lcd.clear();                          
  lcd.setCursor(0,0);                
  lcd.print(" RECYCLE  BIN");    
  lcd.setCursor(0,1);
  lcd.print(" Let's Recycle");
}
void loop()
{
  sensorState = digitalRead(sensorPin);
  if (sensorState != lastSensorState)
  {
    if (sensorState == HIGH)
    {
      sensorProxCounter = sensorProxCounter + 1;}  //count increases by 1 when sensor is high
      lcd.setCursor(0,0);                
      lcd.print("Thank You!      ");    
      lcd.setCursor(0,1);                
      lcd.print("Cans:           ");
      lcd.setCursor(5,1);                
      lcd.print(sensorProxCounter);      //lcd displays number of counts
    }
    lastSensorState = sensorState;
  }
Could there be a problem with the board? Or is it just my program? Please assist. Thanks
« Last Edit: October 02, 2012, 04:59:08 am by Analog_M0n » Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks to me like the 9V DC input is not stable enough.

You should provide the circuit schematics and some more details about the power supply you're using.

BTW, please use code tags.
Logged

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

I have attached a diagram for my power supply circuit, hope it is acceptable.


* Circuit.jpg (92.5 KB, 1311x661 - viewed 27 times.)
« Last Edit: October 02, 2012, 05:39:27 am by Analog_M0n » Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only thing I noticed in your code is an unindented closing brace right after counter increment. But I don't think this has something to do with the behaviour you described.

The diagram looks good to me. Maybe someone here with hw-fu can give you a hint about where to look for potential problems. I would start by checking the 9V line both before and after the regulator with a multimeter when Arduino is running without the usb cable.
Logged

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

Could high current be the cause? There is a current of about 1A when I checked
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could high current be the cause? There is a current of about 1A when I checked

Where did you measure that current ?
Logged

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

At the output of the voltage regulator (Arduino DC input)
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-eek

IIRC the USB bus can provide 500mA max. current. If the Arduino is drawing 1A off the 9V regulator, how can it function correctly when running on on USB cable only ?
Logged

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

I see, is there a way to reduce the current supplied to the Arduino?
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see, is there a way to reduce the current supplied to the Arduino?

Dunno. Someone with higher hw-fu must step in at this point. I suspect you must supply Arduino with as much current as it needs, otherwise there will be problems. If the Arduino draws too much current the solution is not to give it less, but to understand why and see if it's possible to reduce consumption.
What puzzles me, though, is why it seems the board is consuming more current when running on 9V than when running off of usb power... ?-|
Logged

Maine
Offline Offline
Sr. Member
****
Karma: 14
Posts: 417
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I see, is there a way to reduce the current supplied to the Arduino?

That would be like draining a patient of blood to prevent them from bleeding to death from a cut. If your Arduino is drawing 1A, then you have a short somewhere. Since that much current would burn out the on board regulator (and the regulator of your computer's USB ports), you probably measured it wrong. You need to put the multi-meter in series with the power supply. For example, disconnect the +9v wire (but leave the ground wire attached), attach it to the negative lead of your multimeter, and then attach the positive lead of your multimeter to the Arduino. It will now tell you how much current the Arduino is drawing.

What type of battery are you using? The 9v smoke detector type batteries are not a good source of power. They are designed to provide all their power in a short period of time. What is the voltage of the battery as measured by a voltmeter?

You are better off using a 6xAA battery pack to give you 9v.

Scratch that, college wifi is terrible, your image just loaded.

What is the voltage going into the regulator (check with a multimeter) and what is the part number on the regulator? Just looking at the LM7809 regulator, the min. supply voltage is 11.5v, you could be dropping below that.
« Last Edit: October 02, 2012, 10:41:13 am by wizdum » Logged

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12179
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

We need the circuit you built, not just part of it!   Arduino, sensors and all - a photo may be easier.

1A sounds _drastically_ wrong.  You are feeding 9V to the barrel jack?  How are the LCD and proximity sensor powered?  What current do each of those take?

[ BTW that circuit has a serious flaw - there should be a fuse on the +ve lead to the accumulator, preferably close to it - shorting out a large lead-acid battery is a recipe for burnt out cabling, buckled plates, large bangs and can start a fire ]
« Last Edit: October 02, 2012, 12:21:15 pm by MarkT » Logged

[ I won't respond to messages, use the forum please ]

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7197
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can't actually measure the current of the 5V output on arduino voltage regulator. What you did with a multimeter was probably causing 1A flowing down the meter. How did you make that measurement?
Logged


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

The LCD connections are stated below
Quote
1|VSS| -> Arduino GND
  2|VDD| -> Arduino +5v
  3|VO | -> Arduino GND pin
  4|RS | -> Arduino pin 12
  5|RW | -> Arduino GND - pin can be conected to 11. But Ground was used here.
  6|E  | -> Arduino pin 10
  7|D0 | -> Arduino - Not Connected
  8|D1 | -> Arduino - Not Connected
  9|D2 | -> Arduino - Not Connected
 10|D3 | -> Arduino - Not Connected
 11|D4 | -> Arduino pin 5
 12|D5 | -> Arduino pin 4
 13|D6 | -> Arduino pin 3
 14|D7 | -> Arduino pin 2
 15|A  | -> Not Connected
 16|K  | -> Not Connected

Updated circuit diagram.

Capacitive proximity sensor requires 12V to operate.

The 1A measurement was made using a multimeter at the 9V output when it is not connected to the Arduino


* Circuit.jpg (126.11 KB, 1448x734 - viewed 16 times.)
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The 1A measurement was made using a multimeter at the 9V output when it is not connected to the Arduino

 smiley-eek-blue

Nonono! When the multimeter is in amp-mode it behaves like a straight wire. If you connect the multimeter terminals to the power supply + and - like you would when measuring voltage, you're basically making a short circuit! Luckily the 9V regulator can't give more than 1A and the multimeter could cope with it. Had you made this "measurement" on the battery you would've damaged the multimeter or at least burnt its protection fuse!

What you need to do is connect the multimeter like it was a simple wire going from the 9V regulator to the Arduino. For example, multimeter + to supply +, multimeter - to Arduino +.
Logged

Pages: [1] 2   Go Up
Jump to: