Posted by Max Power | Posted in Arduino | Posted on 29-11-2011-05-2008
Edit: I gave up on trying to disable the auto reset through software. The capacitor method works but is cumbersome. The easiest solution is to use an external FTDI as I show in this post.
To test the following solutions I am using the LED example included with the Arduino software to test it. Using your computer, upload the PhysicalPixel sketch from File > Examples > Communication > PhysicalPixel to the Arduino. After you upload the sketch, plug it into the WGT634u and lets test it out. In this example when we send a “H” the LED on the Arduino will light and when we send a “L” the LED will go off. However, you might notice that the LED blinks a bunch of times and does not stay light. This is because the serial port resets. When we are trying to communicate with it via the COM port this is annoying. However there are ways to fix this.
Here are some hardware solutions that you might want to try: http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection. I was able to make it work by adding a 10uF capacitor between the RESET and GND. One note though, you need to plug in the Arduino first to let it start, then you can add the capacitor. If you have the capacitor connected before you connect the USB cable it will not work. Here is a reference: http://tushev.org/articles/electronics/38-preventing-arduino-from-auto-reset-when-com-port-openscloses
The other option is to set Data Terminal Ready (DTR) to false or disabled for the port that hosts your Arduino.
Here is an example of how to do this in Python. I downloaded the pySerial package and modified it as follows:
- Copy the folder c:\Python27\Lib\site-packages\serial to c:\Python27\Lib\site-packages\arduino
- In the arduino folder, delete the file serialwin32.pyc
- Edit the file serialwin32.py, replace the line self._dtrState = win32.DTR_CONTROL_ENABLE to say self._dtrState = win32.DTR_CONTROL_DISABLE
- Save the file and use import arduino to use the modified package
Here is the code that I am using to turn on the LED on pin 13. This uses the PhysicalPixel sketch mentioned above.
import arduino ser=arduino.Serial('COM4',9600) ser.write('L')