Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: Make my ATmega 328 a stand-alone micro controller?  (Read 1683 times)
0 Members and 1 Guest are viewing this topic.
India
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Induino X is awesome!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For my project I wanted to make my 328 a stand alone one.I did not have the 16Mhz crystal, so i connected the ones connected to arduino board's 28DIP microcontroller base(pin 9 and 10).I have powered the board and also took the 5v from the board(without microcontroller) to power up the breadboard microcontroller.I initially had only one microcontroller and I programmed it keeping it on the board.After the program was uploaded, I removed it and put it on breadboard.I have connected even the reset,RX,Tx pins to the board fromy my breadboard.But it wont work.Is it the crystal or any other problem.If I burn its bootloader again selecting its internal 8Mhz crystal, will it work.If yes then how to do it, and what will happen to program which is uploaded in the 328.
Here's my code
Code:
#define HighLevel 2
#define LowLevel 4
#define Output 3
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);

  
 void setup() {
   pinMode(HighLevel, INPUT_PULLUP);
   pinMode(LowLevel, INPUT_PULLUP);
   pinMode(Output, OUTPUT);
       lcd.begin(16, 2);
   lcd.setCursor(0, 0);
   lcd.print("WELCOME TO");
   lcd.setCursor(0, 1);
   lcd.print("PRATIBA KARANJI");
   delay(5000);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("PROGRAMMED BY");
   lcd.setCursor(0, 1);
   lcd.print("KATHIR");
   delay(5000);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("PROJECT DETAILS");
      delay(4200);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("MICRO CONTROLLER");
   lcd.setCursor(0, 1);
   lcd.print("ATmega 328");
   delay(4000);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Rs.80");
        delay(3800);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("LCD DISPLAY");
   lcd.setCursor(0, 1);
   lcd.print("16x2 CHARACTERS");
   delay(4000);
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Rs.90");
      delay(3800);
      lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("RELAY");
   lcd.setCursor(0, 1);
   lcd.print("10 Amp - DPDT");
   delay(4000);  
    lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("Rs.100");
    delay(3800);
   lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("EXTRAS");
   lcd.setCursor(0, 1);
   lcd.print("Wires, etc...");
   delay(4000);
 lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("Rs.35");
      delay(3800);
  lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("TOTAL COST");
   lcd.setCursor(0, 1);
   lcd.print("OF PROJECT");
   delay(4000);
 lcd.clear();
    lcd.setCursor(0, 0);
   lcd.print("80+90+100+35");
   lcd.setCursor(0, 1);
   lcd.print("Rs.305");
   delay(5000);    
  
  
 }
  
 void loop() {
int Hval = digitalRead(HighLevel);
int Lval = digitalRead(LowLevel);


if (Lval == LOW && Hval == HIGH) {
 digitalWrite(Output, HIGH);
   lcd.setCursor(0, 1);
  lcd.print("PUMP STATUS- ON");
  
}
else if (Lval == LOW && Hval == LOW) {
  digitalWrite(Output, LOW);
    lcd.setCursor(0, 1);
  lcd.print("PUMP STATUS-OFF");
}
else if (Lval == HIGH && Hval == HIGH) {
  digitalWrite(Output , HIGH);
    lcd.setCursor(0, 1);
  lcd.print("PUMP STATUS- ON");
}
 if (Lval == HIGH && Hval == HIGH) {
   lcd.setCursor(0, 0);
  lcd.print("WATER LEVEL- MIN");
 }
 else if (Lval == LOW ) {
    lcd.setCursor(0, 0);
  lcd.print("WATER LEVEL-HIGH");
 }
 else if (Hval == LOW ) {
   lcd.setCursor(0, 0);
  lcd.print("WATER LEVEL- LOW");
 }
 }


Moderator edit: [code] [/code] tags added.
« Last Edit: January 06, 2013, 11:26:05 pm by Coding Badly » Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to be certain I'm understanding.  You originally had an Arduino that you've programmed with the above sketch, and now you've pulled the ATMega328 from the socket and are trying to get it to run on a breadboard as a standalone?

If so, does it run okay if you put the uC back into the socket on the Arduino?  If that works, your problem is possibly the clock source as you suggest, but without seeing your circuit it's too soon to rule out other factors.

There are many good tutorials for creating a bare bones board - like this one from Nick Gammon to cross reference your circuit from. 

It is possible for you to put a bootloader on the ATMega that doesn't require the external clock source.  Were you thinking of doing that, or was the plan to ultimately source a crystal from somewhere for this?

Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

India
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Induino X is awesome!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I insert it into my arduino board and burn bootloader with internal crystal 8Mhz, will the program presently in it be deleted?, or will the program(the above program) run properly?, or What will happen?
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5838
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I insert it into my arduino board and burn bootloader with internal crystal 8Mhz, will the program presently in it be deleted?

Yes.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

India
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Induino X is awesome!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I program it again, will my program work properly?
Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5838
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I program it again, will my program work properly?

Yes.
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

India
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Induino X is awesome!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then what's the use of an external 16mhz if an internal 8mhz would do by itself?
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 569
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then what's the use of an external 16mhz if an internal 8mhz would do by itself?
A microprocessor that runs at up to 16MIPS, instead of 8MIPS.

If your sketch is light load then maybe 8Mhz is fine for you. Maybe even lower, in which case there are power savings that can be made, since requirements are lower at lower speeds. You could go as far down as 1Mhz.
Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's quite a few pages in the datasheet dedicated to this.  One of the notes also states that the internal clock isn't as accurate as an external crystal, so the timer functions on your Arduino will drift away more from the real world time.
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 152
Posts: 5838
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then what's the use of an external 16mhz if an internal 8mhz would do by itself?

The internal 8MHz isn't very accurate. It might be 7.9 or 8.1 depending on temperature and voltage.

It's good enough to run programs but if you need accurate timing or high speed serial communications (for example) then it isn't enough.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: