Life after 2k w/ 16F648


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    How is the GoSub returning??

    If I remember correctly, you are only allowed 4 levels of "GoSubs"

    Thus, my first impression would be a "illegal" return from your GoSub... Something like the following:

    Loop:

    .....
    ......
    ......
    if (something happens gosub Loop2)
    goto Loop

    Loop2:
    ......
    ......
    ......
    if (something happens goto Loop) ' This is a NO NO!!!!
    .....
    .....
    return

    end


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    No, it's much simpler ...

    Start:

    result = 0

    For I = 1 to 16....

    GOSUB Thesub
    PULSIN input,1, value

    IF (value < A) OR ( value > B ) then

    error = 1 ( it's a red led ! )
    value1 = ...
    value2 = ...
    GOTO Start

    ENDIF

    result = result + value

    NEXT I

    result = result >> 4 ( the mean value ....)


    .
    .
    .

    the sub:
    Low out1
    Pulsout out1,value1...
    Low out2
    Pulsout out2,value2

    RETURN

    That's all !!!
    Alain

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


    Did you find this post helpful? Yes | No

    Default

    Is there another GOTO Start that's not enclosed in the IF/THEN block?

    If program execution falls-through, lands in TheSub, then hits the RETURN, it will go haywire on you.
    Regards,

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

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Bruce

    No, nothing else.

    Note without the FOR NEXT, it works well , but a further (in the 2 following lines ) " If result = ...THEN" test always passes, even if values should make the test fail ...

    another strange thing.

    Alain

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


    Did you find this post helpful? Yes | No

    Default

    Remove the GOTO Start from the IF/THEN block. Place it after the NEXT.
    Last edited by Bruce; - 23rd June 2005 at 20:45.
    Regards,

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

  6. #6
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    How about a interupt??

    Maybe a wrong return on a interupt (Like a Goto Start), instead of not returning on the GoSub?

    I was looking at your code....

    What happens if A = Value? and that IF statement fails?

    It goes right through 16 times, and then continues to the Subroutine...hits REturn... and...and...<g>

    DWayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  7. #7
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Ace,
    >>>
    Ace
    For I = 1 to 16....

    GOSUB Thesub
    PULSIN input,1, value

    IF (value < A) OR ( value > B ) then

    error = 1 ( it's a red led ! )
    value1 = ...
    value2 = ...
    GOTO Start

    ENDIF

    result = result + value

    NEXT I

    result = result >> 4 ( the mean value ....)
    <<<<

    REwrite it as the following:; I think this will solve your problem...This is assuming you have a goto start BEFORE your subroutine...like after your
    result = result >> 4 ( the mean value ....) statement.


    i=1
    while(i<17)

    GOSUB Thesub
    PULSIN input,1, value

    IF (value < A) OR ( value > B ) then

    error = 1 ( it's a red led ! )
    value1 = ...
    value2 = ...
    i=18
    else
    result = result + value
    endif
    I=I+1
    endwhile
    if I>18 then goto start

    result = result >> 4 ( the mean value ....)
    Last edited by Dwayne; - 23rd June 2005 at 21:36.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Bruce

    The "GOTO Start" has to be here to allow a pulsout for each value of I ....

    It works very well with no FOR -NEXT loop ...

    But there's another problem on the line past "result = result >> 4" :

    ( with >> 4 neutralised ...of course !!! )

    IF ABS ( result - refvalue ) > 100 THEN Start

    Whatever the value of result ... test result is YES !!!

    So, I begin to think the problem is located on the IF THEN tests ...

    Note this works with R/C signals ... 1 to 2 ms pulses @ 40 Hz

    Alain

Similar Threads

  1. Worst day of my life
    By brid0030 in forum USB
    Replies: 6
    Last Post: - 12th March 2008, 23:27
  2. EEPROM life expectancy?
    By muddy0409 in forum General
    Replies: 3
    Last Post: - 1st May 2007, 13:44
  3. Replies: 5
    Last Post: - 12th February 2007, 00:55
  4. Any chance of Life being easy?
    By josegamez in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd November 2006, 21:52
  5. above 2k with 16F877
    By Peter Oors in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th March 2006, 13:43

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