element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Question for Dr Simon Monk re Timer Library
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 5 replies
  • Answers 1 answer
  • Subscribers 402 subscribers
  • Views 721 views
  • Users 0 members are here
  • timer_library
  • arduino
Related

Question for Dr Simon Monk re Timer Library

neilk
neilk over 13 years ago

Hi Simon

 

I think your Timer library is a great piece of work. However, I do have a little problem with the "every" function. I would like to use it to do execute a callback routine every 5 minutes, but it seems to be limited to 32,767 mSec. I guess it's an issue with int and long declarations. Is there a simple way of changing the defnitions in the library?

 

Manny thanks

 

Neil Kenyon

  • Sign in to reply
  • Cancel
  • simon.monk
    0 simon.monk over 13 years ago

    Yes, indeed it is a member that's an int and should be a long.

     

    I believe that this is something Jack has fixed on his fork of the project which is here:

     

    https://github.com/JChristensen/Timer

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • R_Phoenix
    0 R_Phoenix over 13 years ago in reply to simon.monk

    I have found that a lot of Serial.print() commands, or using delay() inconjunction with the time.h lib will cause the timers to "miss" and never fire again. Not sure which version of the timer.h lib I am using however.

     

     

    More Detail here

    http://www.element14.com/community/message/53410#53410/l/re-question-for-simonmonk

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 13 years ago in reply to simon.monk

    I looked at the modified files on Jack Christensen's blog. There are indeed significant changes, from your originals. I have incorporated the changes, but. sadly, both "every" and "after" still fail to work above 32 seconds.

     

    I am using you kitchensink sketch, modified for longer times, as my test.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • neilk
    0 neilk over 13 years ago in reply to neilk

    I have resolved this issue. It's not a problem with the library, but how I was using it:

     

    One of the examples supplied with the library passes the time interval parameter directly in the function call as (for example):

     

         10 * 1000     representing 10 seconds and this works

     

    In my innocence, I inferred that the same approach could be applied to all the functions in the library, which they can. Except that 30 * 1000 works, but 40 * 1000 doesnt.

     

    I am sure there will be some C/C++ experts nodding sagely to themselves, saying "Well it's obvious!"  Sadly, it wasn't to me.

     

    When I eventually - yesterday - discovered that, whereas 40 * 1000 didn't work but 40000 did, I started to understand it!

     

    So, in order to preserve the readability of the code, I now use the following construct:

     

    unsigned interval = 40 * 1000;

    int afterEvent = t.after(interval, doAfter);

     

    The only bit I don't understand is that the time intervals are declared within the library as unsigned long, but must be declared merely as unsigned in the external code in order for it to work.

     

    Perhaps someone can explain that to me.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • neilk
    0 neilk over 13 years ago in reply to neilk

    In fact, just a thought, consider this:

     

    // test arithmetic

     

    void setup()

    {

      Serial.begin(9600);

      Serial.println(40000);

      Serial.println(40 * 1000);

    }

    void loop()

    {

    }

    which gives:

    40000

    -25536

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube