0
\$\begingroup\$

I realize and understand the problem with arduino boards resetting whenever you open a serial connection as stated and answered here.

However, because of that I'm trying to figure out how various arduino-based clocks can actually handle a time sync over serial without just resetting every time.

For example, the BulbDial clock checks for a sync every time the loop comes around. But trying to sync via the processing sketch would just reset the controller and it would miss the sync. Granted, I do not have one of these clocks, but I based by design for the sync off of it and every time I open the serial connection to send the sync, the board just resets.

Is there something that I am missing?

Now, I have gotten it to work by placing a 10 uF cap between RESET and GND. But since others are able to do this without that cap I'd love to be able to do it without as well.

I've also written a python script that will set the time and I've tried all sorts of DTR, RTS configurations to try to force those lines to stay high and not reset the board during connection but I've had no luck. Code below:

    com = serial.Serial()
    com.baudrate = baud
    com.port = port
    com.timeout = 1
    com.rtscts=True
    com.dsrdtr=True
    print com
    com.open()

Any thoughts on how this is supposed to be done?

\$\endgroup\$
  • \$\begingroup\$ I have a bulbdial clock. Basically, in use, it's never connected to the PC at all. You set the time using the buttons on the clock. I assume that the auto-reset functionality wasn't an issue for the firmware development, since you can check the clock is working without having it set to the correct time, and you're not going to leave it connected to your computer when it's actually in use anyways. \$\endgroup\$ – Connor Wolf Sep 14 '13 at 2:19
1
\$\begingroup\$

In this case, I think you have to disable the reset-on-serial-connect function by modifying the board. Searching for 'arduino disable auto-reset' for how to do this to various arduino boards. It will be board specific but most involve adding a bleed resistor across the reset capacitor, removing a capacitor, or cutting a trace on the board.

\$\endgroup\$
1
\$\begingroup\$

There technically is no need to modify the board. The answers to the linked question are not quite correct in their assumption - in actuality this occurs due to software behavior (of the connected PC) rather than something forced by the hardware.

It is possible to configure the host operating system serial API to not automatically command set/clear of the DTR signal upon connection/release, and thus avoid the resetting entirely in software. For example on linux/unix, you want to disable the HUPCL setting in termios; not exactly sure how you do that in python, though running something else (such as the stty tool) might be an option.

However it remains susceptible to being reset by software which does not take care to avoid this, and perhaps by the first usage of the port after boot (unless the change of configuration is made more permanent). For those reasons, a special purpose design would likely not have the hardware to support auto-reset, or have a jumper to enable/disable it.

\$\endgroup\$
0
\$\begingroup\$

There seem to be 4 ways to set up an Arduino-based clock:

  • Once all the firmware is loaded, disconnect the clock from the PC and never connect it again. Use buttons on the clock to set the correct time (and to re-correct the time if it ever drifts).

  • Have a program running on the host PC that opens a connection to the clock and leaves the connection open. Occasionally (perhaps once a day?) that program sends time updates (perhaps derived from NTP). The Arduino gets reset once when that program first opens the connection, but then it should continue running indefinitely (weeks, months, years) as long as the connection remains open. There's no need to close and re-open the connection, which resets the Arduino -- just leave the connection open. (When the host PC shuts down, the Arduino will keep running as long as it has power. When the host PC powers back up and that program opens the port again, it will reset the Arduino, but then immediately update the time again, so perhaps no one will be looking at it and no one will notice the temporary glitch).

  • As JRobert mentioned, disable the hardware that does the auto-reset, so the Arduino never gets automatically reset no matter what happens on the serial lines. This means you have to remember to manually hit the reset button whenever you want to upload new firmware. Searching for 'arduino disable auto-reset', Arduino resetting while reconnecting the serial terminal , etc.

  • Use some other serial port on the Arduino (one of the other hardware UARTs on the Arduino Mega, or use the "Software Serial" library on pretty much any other Arduino) to send time updates to the Arduino or receive data back from the Arduino or both. Only use the "programming port" for actual programming of firmware updates.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.