Help ?


Closed Thread
Results 1 to 21 of 21

Thread: Help ?

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jetpr View Post
    hello this is my code of 3 Years off my hobbies Turbines for Models
    A few things to note at first look at your code...

    There's a few places where you've got a GOTO followed by a GOTO. The code isn't ever going to get to that 2nd GOTO. You might have actually meant to put a GOSUB followed by a GOTO...unless it's just a change that you haven't removed.

    There's at least 1 IF/THEN statement that doesn't look right. I think it's in the Autostart file.
    Code:
     if (EGT > 300) and (RPM > PumpAdd +10) and (FlameOut_1=0) then FlameOut_1=1: gosub opengasoff 'Close Gas Valve
    A single line If/Then with a colon in it generally doesn't work. If it was me, I'd use:
    Code:
    if (EGT > 300) and (RPM > PumpAdd +10) and (FlameOut_1=0) then
    FlameOut_1=1 : gosub opengasoff 'Close Gas Valve
    endif
    Is that zip file the actual code you are programming into your PIC and using right now?
    Oh...987 lines is what I got it down too

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


    Did you find this post helpful? Yes | No

    Default

    ROFL!

    And I thought you were the High Colonic Master.

    IF colons separate multiple statements on the same line as an IF, they are ALL executed if the condition is TRUE, and none will execute if it's false.

    So the 2 examples shown, are the same thing.

    .
    DT

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    ROFL!
    And I thought you were the High Colonic Master.
    IF colons separates multiple statements on the same line as an IF, they are ALL executed if the IF condition is TRUE, and none will execute if it's false.
    So the 2 examples shown, are the same thing.
    .
    I know that's what the manual says, but in the past, I've had certain situations where if one of those statements after the THEN is a goto or a gosub, the If/Then 'acts up' under certain circumstances. I can't quantify exactly what those circumstances are...I just know that I've been avoiding that certain way of doing the IF/THEN statements for a reason ever since it bit me way back when.
    Maybe that's one of those things that got fixed back in PBP 2.2, or it might've gotten fixed since, I don't know...I just avoid it...

  4. #4
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Here's a how to save on some code space a long with a marginal increase in speed. Avoid using the AND operator where possible by multiple nesting IF's.

    Code:
    if (EGT > 300) then
       if (RPM > PumpAdd +10) then
          if  (FlameOut_1=0) then
              FlameOut_1=1 
              gosub opengasoff  'Close Gas Valve
          endif
       endif
    endif
    Also try to avoid GOTO and GOSUB where possible. Most often, programs which make extensive use of them turn out to be spaghetti code.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default Code problems...

    On 2nd glance at the code (which is over 2400 lines)...

    There's a handful of places in the code as a whole where you are decrementing (or incrementing) a byte variable without doing any underflow (or overflow) checking. For instance, a variable contains 4 and you subtract 5, now you've got 255 instead of -1 (which PBP doesn't do)...
    Add underflow and overflow checking to those spots. Only subtract if the value is large enough to be subtracted from...same thing with adding, only add if the number is small enough to be add to...to keep the byte (or word) values from under- or over- flowing.

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


    Did you find this post helpful? Yes | No

    Thumbs up

    Ok
    thanks to all for the Idea off code speed and help

    i going to modify the code more efficient to the PICBASIC PRO Code.

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


    Did you find this post helpful? Yes | No

    Thumbs up

    Thanks to Melanie and all other.

    I change from Pic18f252 to Pic18f2620 and now is working with no problem up to now.

    now i compiler and program the PIC and no Glitch.

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