Using Variables with PAUSE/PWM Commands


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default Using Variables with PAUSE/PWM Commands

    I want to be able to set a PAUSE value using a variable at the top of my code so that the same value can be referenced in many places and I only have to change it in one place while experimenting.

    FLASH_ON VAR BYTE
    FLASH_OFF VAR BYTE


    FLASH_ON = 1500
    FLASH_OFF = 500

    lblLoop:
    High LED_0
    Pause 1500
    Low LED_0
    Pause 500

    GoTo lblLoop

    But this doesn't work, or at least the PAUSE doesn't last as long as I think it should (1.5 seconds the first instance, 0.5 the second).

    Can you use variables with PAUSE? If so, are they defined as different types?

    What about PWM? I'd like to do the same thing for the Duty & Cycle values.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Using Variables with PAUSE/PWM Commands

    Should I be using instead:

    Symbol FLASH_ON = 1500
    Symbol FLASH_OFF = 500

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Using Variables with PAUSE/PWM Commands

    FLASH_ON VAR BYTE
    FLASH_OFF VAR BYTE
    Your values are larger than a BYTE.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Using Variables with PAUSE/PWM Commands

    Yeah, they need to be WORD-size variables to fit values larger than 255....
    But if you're not going to change the value at runtime there's no real need to have them as variables, you might as well make them constants:
    Code:
    FLASH_ON CON 1500
    FLASH_OFF CON 500
    Saves on both RAM and flash memory.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Using Variables with PAUSE/PWM Commands

    Thanks all! I'll use constants for now but eventually it will read from a pot input.

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