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.
Run the given program(below)
Open the serial monitor -> you will see the LED goes HIGH and then LOW and then printing values 1, 2, 3 etc
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/ ?
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...
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.
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.
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.
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.
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!)
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..........
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.