Delay without using pause


Closed Thread
Results 1 to 40 of 43

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Hi,
    Even basic logic doesn't seem to work !!!
    Code:
    if Cvar => 1 or Cvar =< 10 then
    Can you tell me when the above is NOT evalutated true?
    When CVar is 0? When CVar is 8? When CVar is 11? When CVar is 25?

    EDIT... seems it likes if Cvar =>11 and Cvar =< 20 then... rather than OR
    I think YOU like it better with AND rather than OR. The compiler and the PIC likes either one equally well - and it works as expected, just not the way YOU want it to.....

    /Henrik.

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    You realise a zero value skips that whole block right?
    Speed probably is no issue here, but you’re making it work hard!
    It would matter if you’re watching a tilt sensor on a moving part or something like that.

    Code:
    If Cvar < 13 then
    If Cvar > 9 then ShowLCD4
    If Cvar > 6 then ShowLCD3
    If Cvar > 3 then ShowLCD2
    If Cvar != 0 then ShowLCD1
    endif // Cvar < 13

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    The only difference between the ShowLCDx commands is x constant?
    Code:
    Pid_channel=x
    I had a play with every consideration for the micro, and no consideration for the Human

    Code:
    i var byte; bonus loop counter
    x var byte; initial value to subtract 3 from
    
    
    x = 9
    If Cvar < 13 then
    for i = 3 to 0 step -1
    If Cvar > x then
    Pid_channel=i
    LCDOUT $FE,$C0,"Viv",DEC1 Pid_channel+1," "
    TempC = Temperatures(pid_Channel)
    gosub read_dht 
    LCDOUT $FE,$C0+5 
    TempWD = TempC
    GOSUB TempToLCD
    ; if nothing else calls TempToLCD it can go straight in here
    LCDOUT $DF
    if SensorActive(pid_Channel) = 0 then lcdout $FE,$C0+5,"N/C"
    LCDOUT $fe,$94,dec Cvar
    goto check
    ; I don’t see check in what you’ve posted
    ; but you can drop it straight here if nothing else goes there
    endif
    x = x - 3
    next i
    endif;

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Art,

    Thanks for the suggestion.... like I said my original code was bulky and crude, but worked, but I know it could be made simpler, but after 10 hrs of coding I think my brain just gave up

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    It was really just a play... It's not simpler for the Human to read six months later.
    Wherever there's not likely to be a performance problem,
    and thinking of the possibility of having to adjust those constants later,
    I'd avoid the above code like the plague!
    but would personally go for the smaller block directly above that.

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Delay without using pause

    Quote Originally Posted by Art View Post
    It's not simpler for the Human to read six months later.
    Wherever there's not likely to be a performance problem,
    and thinking of the possibility of having to adjust those constants later,
    I'd avoid the above code like the plague!
    but would personally go for the smaller block directly above that.
    That's the thing, I can see the need for tight compact code in a commercial arena where costs etc matter, but for home projects I like things more simpler to follow. As mentioned, it might not be the best way, but if it gets the end result I'm after, and there is little impact on speed then I'm happy. If it means I have to throw an overkill PIC at it to maintain the performance, or to have enough memory to hold my bloated code then so be it

Similar Threads

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

Members who have read this thread : 1

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