PAUSE for a variable time? Using MAX and MIN


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26

    Default PAUSE for a variable time? Using MAX and MIN

    In my program I have LC as a variable word ranging from 0 to 57000. It is the mainloop counter

    In a subroutine I want to pause a variable amount of time in the 0 to 5000 part of the mainloop counts. I have tried to use:

    pause 0 min 5000-LC

    in other words, if LC is 5000 to 57000 don't pause at all. and between 0 and 5000, pause for a proportional length of time.

    I think my pause pause and min statement is missing some syntax?

    Any hints please?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: PAUSE for a variable time? Using MAX and MIN

    5000-57000 will give negative number

    Maybe you want to use ABS(5000-LC)

    so:

    Code:
    a=abs(5000-LC)
    a=a min 5000
    Pause a
    might help?

    But then I am not very sure about the maths to calculate the needed delay.

    Ioannis

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: PAUSE for a variable time? Using MAX and MIN

    Does this provide the functionality you want?
    Code:
    IF LC < 5000 THEN
      PAUSE (5000 - LC)
    ENDIF

  4. #4
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: PAUSE for a variable time? Using MAX and MIN

    Thank you Ioannis and Henrik, both your suggestions would be suitable for me. I apologise for posting this amateur question. In my defence, I had just started a section a code when the grandchildren arrived and that put a sudden stop to it . . . . .

Similar Threads

  1. Array variable access time
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2020, 07:48
  2. MAX MIN vs IF
    By netstranger.nz in forum PBP3
    Replies: 1
    Last Post: - 3rd March 2013, 10:24
  3. pause 1 min in osc 48 ?
    By dala01 in forum USB
    Replies: 1
    Last Post: - 12th December 2011, 15:22
  4. defining max pulsin time with duty cycle 100%
    By hkpatrice in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th April 2010, 10:58
  5. ADCIN > HPWM but with min/max limits - i failed maths
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th November 2009, 02:02

Members who have read this thread : 18

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