How to detect variable decrease moment?


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2013
    Posts
    868

    Default How to detect variable decrease moment?

    Hello.

    I'm doing a task, where variable presents certain data (changes every second). I have to capture a moment, when it starts to decrease.

    My code is here:

    Code:
    COMPARER:
    IF OLD>NEW THEN GOTO OTHER TASK
    PAUSE 1
    OLD=NEW
    GOTO COMPARER
    But isn't there some kind of statement, to make this shorter?

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: How to detect variable decrease moment?

    Have a look at the PB manual

    http://melabs.com/resources/pbpmanual/5_75-5_76.htm#572

    While..Wend

  3. #3
    Join Date
    Apr 2011
    Location
    Welches, Oregon
    Posts
    197


    Did you find this post helpful? Yes | No

    Default Re: How to detect variable decrease moment?

    You did not specify if you mean "shorter" as in with fewer lines of code or "shorter" as in faster...

    Here is a thread you may find interesting: http://www.picbasic.co.uk/forum/showthread.php?t=5335
    Also, you may look at the Pauseus statement.

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: How to detect variable decrease moment?

    Code:
    Code:
    COMPARER:
    IF OLD>NEW THEN GOTO OTHER TASK
    PAUSE 1
    OLD=NEW
    GOTO COMPARER
    If you loop inside the snippet how do you feed the variable "NEW" with the updated value?

    Al.
    All progress began with an idea

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,587


    Did you find this post helpful? Yes | No

    Default Re: How to detect variable decrease moment?

    @ first ... your processor will be able to see a change only AFTER data have been collected ( La Pallice, french philosopher ).

    from that, if you collect data once a second ( as written @ post #1 ) no need to scan value @ each millisecond ...

    just place your test ONCE after data collection ( ADC conversion or serial value received ) and you won't loose any time !!!

    no need to have a watching loop nor ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,256


    Did you find this post helpful? Yes | No

    Default Re: How to detect variable decrease moment?

    (nevermind)

    Robert

Similar Threads

  1. How to detect sound direction?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th December 2008, 04:53
  2. Detect 240V with a PIC
    By The Master in forum Off Topic
    Replies: 48
    Last Post: - 28th October 2008, 20:21
  3. Detect Signal
    By angrysmileyface in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 10th April 2007, 00:28
  4. What is the easiest RTC chip of the moment?
    By paxmowa in forum Off Topic
    Replies: 2
    Last Post: - 13th October 2006, 00:41
  5. Low Voltage Detect
    By Brian in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st April 2005, 16:46

Posting Permissions

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