An arduino enigma

An arduino enigma

Home Forums Electronics in the Workshop An arduino enigma

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #854350
    duncan webster 1
    Participant
      @duncanwebster1

      My current project is to modify the software of an arduino driven clock chime so that it doesn’t keep SWMBO awake at night. The whole thing is driven from a 12v power supply which powers a stepper motor direct, and the arduino via a 7805 regulator. It is very boring to sit and watch to make sure it’s doing its thing, so I set up the serial monitor to display the minutes as they tick over. This of course requires a USB connection to the PC. All worked very nicely as long as I was doing something else on the PC, but if I went away for more than 15 minutes, the PC went to sleep, and when I woke it up the minutes count always began again at 1. It appears that the PC waking up resets the arduino. It might be that going to sleep does likewise, can’t tell. This is despite having the 7805 source of 5v continuously.  Solution is simple, tell the PC never to go to sleep,  but will I remember? Probably not, I’ll waste another hour or so working out what is going on.

      #854374
      Stuart Smith 5
      Participant
        @stuartsmith5

        Duncan

        If you start the serial monitor function in the Arduino programming software, it restarts the Arduino ‘sketch’. I suspect this is what is happening.

        I wonder if you disconnected the serial pc to Arduino pin and just had the Arduino to pc pin connected it would be ok.

        The other way would be to connect a display to the Arduino.

        Stuart

        #854375
        John Haine
        Participant
          @johnhaine32865

          This is a PITA with the Arduino, and for example it stops you connecting a serial lead to the USB port if you just want to send some data or special commands to your code.  The device is designed with a capacitor that sends a reset to the processor when a physical USB connection is made.  A workaround is to add another cap and switch to some specific pins so that wen the cap is switched in it suppresses the reset and this works well.  I use it on my Arduinome so that I can connect a PC and send commands from the serial monitor to configure various running parameters on the fly.  Details are on the Arduino support forum

          #854376
          duncan webster 1
          Participant
            @duncanwebster1

            Thanks John that’s this evening’s mod sorted as long as I can find a 10uF cap

            #854378
            SillyOldDuffer
            Moderator
              @sillyoldduffer

              Easy enough when you know how, but stopping desktop Windows from timing out has long been a problem.  There are good security, power saving and other reasons why a desktop computer should time-out, but the behaviour is wrong when the computer is logging.   Linux and Apple support no-timeout because they started as servers, designed to run non-stop, and the desktop is an add-on.  Windows-Server stays awake too, but not cheap or easy, spartan, and not good at running desktop applications.

              Good news: I see a new Windows application makes staying awake easier to do on a desktop. Can’t try it because my main Windows laptop broke last month and I’ve lent the spare out.   However,  the app is  PowerTools Awake and it seems straightforward.  Or, you can achieve what’s needed by ploughing through the windows control settings as described here.  Stop here If only Windows is available.

              I prefer RaspberryPi for logging.  The Pi3 is fast enough, small, naturally air cooled, uses tiny power compared with a laptop, and runs headless (ie no need for a keyboard, mouse or screen.)  ‘Stay awake’ is fully supported – the program keeps going if the user logs out.

              Example:

              dave@condor:~/devel/python$ nohup python3 serialread.py > logfile.txt &

              Gobbledygook explained:

              dave@condor:~/devel/python$ – means I’m logged in on the command line as dave on a computer called ‘condor’ and I’m working in the  folder “devel/python”.

              nohup – Run COMMAND ignoring hangup signals

              python3 serialread.py is the COMMAND that nohup keeps running (serialread.py was written by me.  It reads the default USB serial port used by Arduino Nano and copies whatever arrives to standard output.  System commands work the same way – putty, cutecom, or another terminal emulators might well be preferred.)

              > logfile.txt defines standard output to be the file “logfile.txt”

              & tells the computer to run the whole job in background, i.e. no screen or keyboard.  The user gets the command line back so more commands can be issued, thus multiple nanos can be logged.

              Once running, the user can walk away, and can even log out.  Nothing times-out, and when he logs back in, he will find serialread.py is still chugging away.  The logfile will be bigger…

              Last time I tried, Apple worked in exactly the same way as Linux, but it was at least 5 years ago.  Doubt it’s changed.

              There’s always a booby trap!  Here, the operating system buffers output, and nothing appears in the logfile until something flushes the buffer.  As buffers can store a lot of data, it might appear that logging has failed, when actually the data is accumulating in a private queue. Be patient.

              Dave

              PS.  Just read Stuart and John’s posts.  They’re right that plugging USB in and out resets the Arduino.  It’s because the Arduino assumes USB being plugged in mid-flight means the programmer is updating the firmware, and it switches into that mode.   However, that’s not wanted when the program is finished.   Fortunately the cure is simple – connecting a 10uF capacitor from RESET to GND as described by John, fools the firmware loader, allowing the USB to be plugged in willy-nilly.  Don’t forget to unplug the capacitor next time firmware is upgraded though – as Duncan says “but will I remember? Probably not, I’ll waste another hour or so working out what is going on.“.

              Duncan describes a different problem I think:  “All worked very nicely as long as I was doing something else on the PC, but if I went away for more than 15 minutes, the PC went to sleep, and when I woke it up the minutes count always began again at 1. It appears that the PC waking up resets the arduino. It might be that going to sleep does likewise, can’t tell. This is despite having the 7805 source of 5v continuously. Solution is simple, tell the PC never to go to sleep“.  I think he’s right “tell the PC never to go to sleep“.

              No harm done fitting a capacitor, provided one remembers it’s there.  And as it’s easier to plug in a 10uF cap than mess with Windows, well worth trying first, or as well.  Though the capacitor value isn’t critical, 10uF seems reliable.

              Setting up a second SerialPort is an alternative to the capacitor, but it’s hardware and software fuss.

               

              #854400
              Charles Lamont
              Participant
                @charleslamont71117

                Somewhere around here on windows 11:

                Settings > system > power >

                screen sleep and hibernate timeouts > plugged-in > make my device sleep after : never

                energy saver > off

                 

                #854420
                duncan webster 1
                Participant
                  @duncanwebster1

                  Yipee, the 10uF solution worked, or at least it did when I remembered to solder the rst pin on on the Nano.

                   

                  Thanks everyone

                   

                  Dave’s linux solution probably convinced plenty of people to avoid Linux, although it’s something to challenge myself with!

                  #854426
                  Michael Gilligan
                  Participant
                    @michaelgilligan61133

                    Just a thought … Would a ‘mouse wiggler’ [USB hardware dongle] suffice to keep Duncan’s PC awake ?

                    or would it upset the Arduino ?

                    MichaelG.

                    #854430
                    SillyOldDuffer
                    Moderator
                      @sillyoldduffer
                      On duncan webster 1 Said:

                      Yipee, the 10uF solution worked, or at least it did wehen I remembered to solder the rst pin on on the Nano.

                       

                      Can’t confirm myself due to my Windows computer being on loan, but Duncan should check the logfile collected data whilst Windows was asleep.  I’m fairly sure there will be gaps, unless only the screen is switched off.

                      When Windows times out, user processes are suspended, so any logging app will stop logging.  The USB hardware is also suspended, or even powered off entirely if nothing else is using it.    Then anything the Arduino sends is ignored because the COM port it was using isn’t available, and neither is the logging process.

                      When Windows wakes up, it reconnects the COM port, causing the Arduino to loses data until it decides a firmware download isn’t coming.  The 10uF capacitor fools the firmware installer, so the Arduino resets immediately, but this still loses data.

                      Calls for an experiment.  Download this program to a Nano:

                      unsigned long counter = 0;

                      void setup() {
                      Serial.begin(57600);
                      }

                      void loop() {
                      delay(1000);
                      Serial.println(counter);
                      counter++;

                      }

                      Then start the Windows emulator of your choice and confirm it logs a count incrementing once per second with no breaks.  Next, let Windows go to sleep for an hour. Then wake it up and check the output for gaps in the logged sequence – there shouldn’t be any.  If there are, the problem lies within windows and the 10uF solution isn’t the answer.  If that’s the case look at the Awake application or twiddle the Window control settings to stop Windows going to sleep.

                      Dave

                       

                      #854431
                      duncan webster 1
                      Participant
                        @duncanwebster1

                        I’m sure Dave’s correct, but stopping the Nano re-booting answered my problem, I can see that the minutes count increments in phase with real time and that bells ring at appropriate moments. If it was right at half past and on the hour I’ll trust it was right at 1/4 to. I’m not bothered about a few gaps, although I’m fully intending to look into the RPi solution

                        #854692
                        Alan Wood 4
                        Participant
                          @alanwood4

                          Slightly relevant.  Tera Term v5 is a freeware logging tool that I recently discovered.  You can set it up to display the Arduino serial port output and log it to a file on the PC.  It saves a lot of hanging about watching the IDE window.  Whether it stops a reboot or not I can’t say but my laptop seems to stay alive while it is running.

                          #854694
                          John Haine
                          Participant
                            @johnhaine32865

                            Alan, do you have any documentation on this app please?  I can find the Github project page but it doesn’t appear to have anything approximating to a manual, and the Wiki is empty!

                            #854696
                            Michael Gilligan
                            Participant
                              @michaelgilligan61133

                              For what little this might be worth, John

                              I’ve had an old version of Tera Term on my XP laptop for donkey’s years

                              The inbuilt |Help| button provides all the documentation one might  reasonably require.

                              MichaelG.

                              #854704
                              John Haine
                              Participant
                                @johnhaine32865

                                Aha!  Thanks Michael, in the absence of documentation I hadn’t got as far as installing it.

                                Edit: but now a manual has popped up! https://teratermproject.github.io/manual/5/en/

                                #854738
                                Alan Wood 4
                                Participant
                                  @alanwood4

                                  Sorry late back to this.   I downloaded the Windows 64 bit exe file and bubbled along with the only settings I changed were in Setup\Terminal where I changed the New-Line dropdowns to CR+LF and ticked Echo.   I was confused that the viewing window seemed to have limited line capacity and was concerned leaving it on overnight that I would lose data but the record to disc function stores everthing from Recording start.   There are a lot of other things you can tweak in Setup but terror set in and I left it alone … Incredibly useful app.

                                  #854739
                                  Alan Wood 4
                                  Participant
                                    @alanwood4

                                    Forgot to say that if you leave the IDE connected to the sketch in question there will be a conflict and Tera won’t connect.  Fairly obvious but I missed that I had left a window open …

                                    #854782
                                    Joseph Noci 1
                                    Participant
                                      @josephnoci1

                                      Cool term is another very useful Terminal program. Nicely configurable and reasonably intuitive – I use it to log all sorts of miscellaneous I/O from the Pendulum. It can also handle multiple concurrent connections to different serial ports so can log different sources simultaneously. About 10MB download.

                                       

                                      Cool Term Download

                                       

                                      #854791
                                      John Haine
                                      Participant
                                        @johnhaine32865

                                        Going back to Duncan’s original purpose, here are a couple of photos of the “Civil Time Unit” of Professor Robertson’s Clock at Bristol University.  The clock controlled the timing of Great George, in the bell tower of the Wills Building, chiming the hour.  To avoid annoying the good citizens of Clifton too much the chiming was inhibited between 2100 and 0700 and all day Sunday by this mechanism which is stepped every 30s by pulses from the pendulum.  Basically an electromechanical counter inspired by early telephone switches.  A similar mechanism controlled a phase lock system to trim the pendulum rate by syncing to a time pulse from Greenwich every morning at 10.00 GMT. An Arduino Nano is just a tad smaller – these units are ~250mm high! Nowadays the bell is chimed by some electronic system though I think it still uses Robertson’s chiming machine. Robertson’s own description of the clock and the machine is available at https://clockdoc.org/new/index.aspx/?moid=62981

                                        Screenshot 2026-07-05 101541Screenshot 2026-07-05 101701

                                      Viewing 18 posts - 1 through 18 (of 18 total)
                                      • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                      Latest Replies

                                      Viewing 25 topics - 1 through 25 (of 25 total)
                                      Viewing 25 topics - 1 through 25 (of 25 total)

                                      View full reply list.