Delay without using pause


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Malcolm,

    You could also do this via a Timer Interrupt using DT's Instant Interrupts.
    Say, Timer2 (8bit timer) with both a Prescaler and Postscaler, then in the ISR decrement a word variable that is preset to a number that gets you to 3 seconds or whatever time you want. When the var reaches zero set a flag to run the display routine and reset the word var back to your preload value. In your main loop test for the flag and call the display routine if set and then clear the flag.

    This would allow you to hit a time-based delay much easier.
    Regards,
    TABSoft

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Why not just count the number of data updates and after so many, Update the display with a different set of data? That way you won't slow down the data taking and control timing and you will get a "cycling" data display you want. That way there is no need for a delay of any type.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Thanks for the suggestions guys.

    Dave, your suggestions sounds simple enough for me to understand. I guess I could have a variable that is updated every time the program goes around the main loop, then when it reaches a certain value display one set of data for the 1st probe, then when reaches another it displays the second set etc... I'll have a look at implementing that. I guess that provided the program doesn't loop more than 65535 times in 8 seconds then I will be able to use a word variable and each update would be visible for 2 seconds

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Quote Originally Posted by Scampy View Post
    Thanks for the suggestions guys.

    Dave, your suggestions sounds simple enough for me to understand. I guess I could have a variable that is updated every time the program goes around the main loop, then when it reaches a certain value display one set of data for the 1st probe, then when reaches another it displays the second set etc... I'll have a look at implementing that. I guess that provided the program doesn't loop more than 65535 times in 8 seconds then I will be able to use a word variable and each update would be visible for 2 seconds
    And . . . . if you average several samples of each you would see it displayed longer, side bonus a "flier" reading would not upset you as much when averaged than it will if not averaged or discarded.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Quote Originally Posted by Scampy View Post
    I guess that provided the program doesn't loop more than 65535 times in 8 seconds then I will be able to use a word variable and each update would be visible for 2 seconds
    Since you are using DT interrupts, another approach would be to use a variable to count every time the program goes to the interrupt routine. After so many hits, then you update the LCD display. Depending on how long you set the time intervals for the interrupts, this might be a "cleaner" solution.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Guys, thanks for your continued input.

    I've hit a hurdle and it's doing my head in. In the original code the readings from the 4 sensors were displayed constantly on the LCD, so within the main program loop there is a for next loop which runs through and reads the 4 DS18B20's and puts the results into a 4 line array. This results in a fast response in updating the display when temperatures change. Now that I'm also reading an AM2302 and want to display data from that too, the LCD looks cluttered if I follow the same method, hence my idea of displaying the readings from each vivarium on a single line, which would overwrite the values for each vivarium every few seconds. The problem is that if I opt to change this so the for next loop which reads the sensors is changed so that it reads sensor 1 and then goes to a subroutine to display the results for two or three seconds it means that it can take 8 - 12 seconds to go round the loop to read all four sensors, which defeats the object of having fast response times, and in 12 seconds the temp in the vivarium could become dangerously high as this would effect the PID timings.

    I think to only option is to use two 20 x 4 LCD's or one 40 x 4 LCD, or possibly a GLCD

  7. #7
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Can you post a mockup of your display in text and how you use it and how you see using it?
    Regards,
    TABSoft

  8. #8
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    This was the best match, but I have no room to display the time.

    Name:  oldlcd.jpg
Views: 2555
Size:  38.4 KB

    This is what I'm trying to achieve

    Name:  newlcd.jpg
Views: 1977
Size:  30.4 KB

    With line 2 being updated with data for Viv2, Viv3 etc

Similar Threads

  1. Replies: 6
    Last Post: - 28th October 2014, 06:08
  2. Do I need a pause?
    By tazntex in forum Serial
    Replies: 21
    Last Post: - 29th August 2008, 04:32
  3. 1 us delay
    By Pedro in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th February 2006, 17:28
  4. Pause
    By blue in forum General
    Replies: 7
    Last Post: - 29th December 2005, 14:24
  5. pause 0.5
    By detail in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th June 2005, 11:32

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts