Way


Closed Thread
Results 1 to 6 of 6

Thread: Way

  1. #1
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133

    Exclamation Way

    This work
    if (RPM > 3) then
    low Estarter
    else
    high Estarter
    pause 100
    endif

    this no work

    if (RPM <= 3) then
    high Estarter
    pause 100
    low Estarter
    endif

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Is rpm less than or equal to 3 when it doesn't work?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Exclamation Way

    This work
    if (RPM > 3) then
    low Estarter
    else
    high Estarter
    pause 100
    endif

    this no work

    if (RPM <= 3) then (when is less the 3)
    high Estarter
    pause 100
    low Estarter
    endif

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


    Did you find this post helpful? Yes | No

    Default

    IF THEN with out an else has to have the THEN condition on the same line. This should work assuming "Estarter" is a Label or Statement.
    Code:
    if (RPM <= 3) then high Estarter
    pause 100
    low Estarter
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It should work fine as-is, but if you expect to see the LED blink, you would probably
    want a short pause after each logic state change.

    I.E.;

    Code:
    RPM VAR BYTE
    SYMBOL Estarter = PORTB.0
    PORTB.0=0
    TRISB.0=0
    
    Main:
        for RPM = 0 TO 255
        if (RPM > 3) then
          low Estarter
          pause 100
        else
          high Estarter
          pause 100
        endif
    
        if (RPM <= 3) then
          high Estarter
          pause 100
          low Estarter
          pause 100
        endif
        next RPM
        goto Main
        
        END
    This definitely works. LED blinks 4 times on each pass through the loop.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I'm thinking they weren't meant to be in the same program.
    They are attemping to do the same thing, 2 different ways.

    Quote Originally Posted by jetpr View Post
    This work
    Code:
            if (RPM > 3) then  
               low Estarter   
            else
               high Estarter
               pause 100
            endif
    this no work
    Code:
            if (RPM <= 3) then  
               high Estarter
               pause 100
               low Estarter  
            endif
    In which case, the second example is simply missing the else...
    Code:
            if (RPM <= 3) then  
               high Estarter
               pause 100
            else
               low Estarter  
            endif
    DT

Members who have read this thread : 0

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