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 Simon.monk
  • 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
  • Replies 3 replies
  • Subscribers 402 subscribers
  • Views 242 views
  • Users 0 members are here
Related

Question for Simon.monk

R_Phoenix
R_Phoenix over 13 years ago

For some reason I can not send private messages, so hopefully you will see this.

 

Hello Simon

 

I am using you timer lib for the Arduino. Nice job.

I am having and issue with the t.update(). After a few Serial Sends (not included in the call back), the timer fails to update and the callback is skipped. I am going to try and move those serial sends inside the callback and see if that fixes it, but was curious if you knew of any issues where the callback can get skipped or the timer gets dropped?

 

Thanks.

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

    Hello R_

     

    Well, the timer library uses millis() and only checks if anything needs doing when you call update(). So its not anything weird with timers etc. However, if you take too long in the loop to do other things (like serial which is slow) then the next update might not get called until after the due time of the next event. Which would lead to that event being skipped.

     

    How frequent is the timer causing the problem?

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

    Thanks for the reply!.

     

    Once the call back is skipped it never executes again. I'm not sure if the call back isn't getting called or the timer simply isn't updating.

     

    Basically I have 3 function calls in the loop;

    Function 1 reads data coming in on the serial port and records the information to be used in the update callback.

    Function 2 reads data coming from a Touch screen (software serial) and sends data out over serial. Note this is the serial send I plan to move into the update() call back.

    t.update() which is set to execute every 500ms. This call back updates the information displayed on the LCD, this info is gathered from Function 1.

     

    What happens is after random amounts of button presses on the LCD, Function 2, the LCD no longer updates it's information on screen which should be happening from the Call back. I can verify that the data is still received on the serial (Function 1) and I can verify that the information is still being received on the Software serial in Function 2. So the loop is still running, but the update callback fails to update the LCD as if the timer is no longer their.

     

    If I power down and power back up, all the correct data is then updated to the LCD, including all my last button presses that weren't updated previously, and everything works again until I press a few touch buttons again. As long as I don't press buttons everything works fine.

    I am fairly certain that it's being caused by the Serial Sends inside the function2, However I would expect only a skipped update now and again, not a total loss of t.update.

     

    I would send you the code, but I'm not at liberty.

     

    I suppose it could also be the Software Serial that is getting messed up somehow and data is not being sent to the LCD properly but I have a second program that is set up basically and almost identical to what I described above, only real difference is that there is only one button to press on the LCD. It has been running flawlessly for over 3 weeks here on my desk.

     

    If moving the serial send inside the update callback fixes the problem, then it is something for you to be aware of that could happen. Just to note, using the delay() function in conjunction with your timer lib seems to induce the problem sooner.

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

    Thanks for the reply!.

     

    Once the call back is skipped it never executes again. I'm not sure if the call back isn't getting called or the timer simply isn't updating.

     

    Basically I have 3 function calls in the loop;

    Function 1 reads data coming in on the serial port and records the information to be used in the update callback.

    Function 2 reads data coming from a Touch screen (software serial) and sends data out over serial. Note this is the serial send I plan to move into the update() call back.

    t.update() which is set to execute every 500ms. This call back updates the information displayed on the LCD, this info is gathered from Function 1.

     

    What happens is after random amounts of button presses on the LCD, Function 2, the LCD no longer updates it's information on screen which should be happening from the Call back. I can verify that the data is still received on the serial (Function 1) and I can verify that the information is still being received on the Software serial in Function 2. So the loop is still running, but the update callback fails to update the LCD as if the timer is no longer their.

     

    If I power down and power back up, all the correct data is then updated to the LCD, including all my last button presses that weren't updated previously, and everything works again until I press a few touch buttons again. As long as I don't press buttons everything works fine.

    I am fairly certain that it's being caused by the Serial Sends inside the function2, However I would expect only a skipped update now and again, not a total loss of t.update.

     

    I would send you the code, but I'm not at liberty.

     

    I suppose it could also be the Software Serial that is getting messed up somehow and data is not being sent to the LCD properly but I have a second program that is set up basically and almost identical to what I described above, only real difference is that there is only one button to press on the LCD. It has been running flawlessly for over 3 weeks here on my desk.

     

    If moving the serial send inside the update callback fixes the problem, then it is something for you to be aware of that could happen. Just to note, using the delay() function in conjunction with your timer lib seems to induce the problem sooner.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • R_Phoenix
    R_Phoenix over 13 years ago in reply to R_Phoenix

    Simon,

     

    Also note as a quick check I removed the Timer.h lib and went back to the old method of;

     

    unsigned long currTime;

    unsigned long lastUpdate = 0;

    unsigned long updateInterval = 500UL;

     

    and in the loop

    currTime = millis();

     

    if(currTime - lastUpdate >= updateInterval)

      {

      UpdateAll();

      lastUpdate = currTime;

      }

     

    and the problem is gone. image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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