Pages: [1]   Go Down
Author Topic: Duemilanove Restarts Automatically?!  (Read 2308 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have got my Duemilanove recenlty. I wrote a simple program to print the data to the Serial Port. The problem is that my program restarts whenever the Serial Moniotr or any such tool is opened(Hyper terminal or any custom application that uses the same COM port).

Steps to reproduce the issue:
 
Get a Duemilanove which is connected to the PC through USB Cable.

1. Run the given program(below)

2. Open the serial monitor -> you will see the LED goes HIGH and then LOW and then printing values 1, 2, 3 etc

3. Close serial monitor and reopen it

Expected result:
a) Serial Monitor should display the values from somewhere 7 , 8 ,9 and then go on.
b) The LED on pin 13 should not blink.

Actual result:
a)Serial Monitor displays the values AGAIN FROM 1,2,3...
b) LED on13 blinks again.

My questions:
a) is it intented behavior?
b) can I make it NOT to restart my application whenever Serial Monitor(or any app that opens the same COM port) is invoked/ ?



Here is the program that tried with:

int ledpin = 13;
int counter = 0;
void setup()
{
Serial.begin(9600);
digitalWrite(ledpin,HIGH);
delay(100);
digitalWrite(ledpin,LOW);
delay(100);
}
void loop()
{
counter++;
Serial.println(counter);
if(counter >=255)
counter =0;
delay(1000);
}

Logged

Bonn, Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

this is an intended behavior. It's called Auto-Reset, makes life much easier when uploading.
I dont know how to 'hack' the duemilanove in order to get rid of that, but basically you would have to discunnect the DTR line from the Reset Pin (1) of the Atmel, but uploading would be a matter of patience with that.

You could as well, if this is now a life threatening situation, go for a Seeeduino that has a switch to turn Auto Reset on or off...
Logged

Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah.. did you mean to say that my program will restart  **whenever ** a serial Monitor or similar program is opened.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
ah.. did you mean to say that my program will restart  **whenever ** a serial Monitor or similar program is opened.

Yes, the opening of a serial monitor or terminal program will activate the DTR control signal, which the Arduino design has wired to the reset pin via a series capacitor. There are a couple of ways to modifiy the board to prevent this action but unless easily undone it can make uploading new sketches difficult as activating the Arduino reset is how the Arduino IDE forces the Arduino to activate the bootloader program on the AVR chip.
 And yes, the Seeduino clone design has a switch to activate or deactivate this feature, as well as a switch to force power selection from the USB or external voltage source, also handy at times.

Lefty.
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset



To disable this feature, take a craft knife and cut the little track between the two solder pads. If you do , you'll need to press reset manually when you upload a sketch.  The solder pads are there so you can re-enable it if you get fed up of losing the auto reset.   smiley

If you can disable DTR in your serial terminal, it saves you having to butcher your arduino.  

You could at a push solder some tiny wires to a toggle switch or something to be able to switch it on and off, but it would be easier to buy a seeeduino.
« Last Edit: September 22, 2009, 12:01:17 pm by stephen_t » Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You could at a push solder some tiny wires to a toggle switch or something to be able to switch it on and off

Just cut the little trace between the pads then solder a 2 pin male header strip into the pad holes. Then you can slip on a shorting clip when you want the auto reset enabled or remove the clip when you don't want it.

http://www.sparkfun.com/commerce/product_info.php?products_id=9044

http://www.sparkfun.com/commerce/product_info.php?products_id=116

Or get a Seeeduino, they are great.  8-)

Lefty
« Last Edit: September 22, 2009, 01:24:52 pm by retrolefty » Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to thwart your plan RL, there aren't any holes........  smiley

Back to the seeeduino.
« Last Edit: September 22, 2009, 03:33:08 pm by stephen_t » Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Just to thwart your plan RL, there aren't any holes........  


Holes?, holes?, we don't need no stinkin holes. Just tack solder the two header pins to the pads.

Or get a Seeeduino, there great.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah..hard to believe!.. bye the way, is there anything that I can do in the software side to bypass this issue?

And yes..I am running data logger in the board ...so I can no way loose the data!.
Logged

Bonn, Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 903
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If possible you could try to 'turn off' DTR in your serial communications.. that'd doable...

the harder way, i havent even thought of before could be using a SoftSerial Library, attaching a com port to it and reading that one..

In the end the best way for you would be either to cut the pads (seems to be easy enough) and bridge them for uploading (as this is easier than the timing game) or get yourself a Seeeduino from nkcelectronics.com (which i would prefer!)


*edit*
Here they were talking about various ways of turning off autoreset as well:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1213719666/28
« Last Edit: September 23, 2009, 02:31:25 am by Nachtwind » Logged

Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Holes?, holes?, we don't need no stinkin holes. Just tack solder the two header pins to the pads.

Or get a Seeeduino, there great.

Lefty

Well, it could be done, with the right shaped midget soldering iron, very steady hands and seriously better eyesight than mine.



Coo, my Duemilanove looks tatty under extreme closeup.

On the software front, I have a butchered version of this mans Linux communications software :

http://todbot.com/blog/2006/12/06/arduino-serial-c-code-to-talk-to-arduino/

which works without resetting the Duemilanove, it also sets up the comms port so that subsequent reads from bash ( cat /dev/ttyUSB0|tail ) doesn't reset it either. Not much use if you don't use Linux though.

 Pity stuff from Seeed studios takes an age to get here..........
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Guys! . It was very helpful. smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At last I found a solution from the software side. FYI, I use .Net platform to talk to Serial port. So here is the code which does not restart Arduino .
Serialport sp = new new SerialPort("COM1", 9600, Parity.None);//Paramters does not matter.

_sPort.DtrEnable = false; // ** Here is the Key!

_sPort.Open();

Hope it will be helpful for some one .

Logged

Pages: [1]   Go Up
Jump to: