Go Down

Topic: Make my ATmega 328 a stand-alone micro controller? (Read 1 time) previous topic - next topic

InduinoX

Jan 07, 2013, 04:01 am Last Edit: Jan 07, 2013, 05:26 am by Coding Badly Reason: 1
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: [Select]
#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.

strykeroz

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
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

InduinoX

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?

fungus


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


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

InduinoX

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

fungus

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

InduinoX

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

tack


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.

strykeroz

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.
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

fungus


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.

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

Go Up