Shop OBEX P1 Docs P2 Docs Learn Events
DEBUG qusetion.... — Parallax Forums

DEBUG qusetion....

ArchiverArchiver Posts: 46,084
edited 2003-10-07 14:18 in General Discussion
my question is this, in my sample program below, i want to be able to
debug how often input 15 gose high, in other words i want to monitor
it has how fast the program is running... the reason for this is , is
that i want to see how many times a minite , input 15 gose high (BUT!
not useing the count command , sence that takes time away from the
program running rest of the code...)


'{$STAMP BS2}
TB_POS VAR BYTE
X VAR WORD
x0 CON 1000
x1 CON 2000
x2 CON 3000
x3 CON 4000
x4 CON 5000
x5 CON 6000
x6 CON 7000
x7 CON 7500
x8 CON 8000
x9 CON 8500
x10 CON 9000
x11 CON 9500
x12 CON 10000

MAIN:

INPUT 15
IF IN15 = 1 THEN TB
GOTO MAIN

TB:

PULSIN 8, 1, TB_POS
lookup TB_POS min 5 max 18 - 5,
[noparse][[/noparse]x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12], x
pulsout 7,x

GOTO MAIN


*** u see i have the program run "TB" once input 15 gose high ... so
every time my engine's crank sensor triggers the input 15 to cause it
high, it will then run the sub program "TB" then look back to
the "MAIN" program....


Sean....

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-10-06 14:43
    In a message dated 10/5/2003 10:43:15 PM Pacific Daylight Time,
    djrevolution99@y... writes:
    my question is this, in my sample program below, i want to be able to
    debug how often input 15 gose high, in other words i want to monitor
    it has how fast the program is running... the reason for this is , is
    that i want to see how many times a minite , input 15 gose high (BUT!
    not useing the count command , sence that takes time away from the
    program running rest of the code...)
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++


    If I am not mistaken (others please chime in) debug itself takes time from
    your program, lots of time in fact.
    If you have access to an o-scope connect it to pin 15 and watch it for one
    period, and multiply that result times 60. This is assuming you are checking
    pin 15 at a constant engine speed.

    Ken


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-06 17:50
    Hi Sean,

    I think you want to detect when the in15 goes from low to high. The
    way you have it now, it detects the high state, and that might cause
    the loop to run more than once per revolution. That depends on the
    engine timing. Here is a debouncing routine:

    main:
    main1:
    IF in15 THEN main1 ' stay in this loop while in15 is high
    main0: ' now it is low
    BRANCH in15,[noparse][[/noparse]main0,TB] ' stay in this loop while in15 is low
    ' branch to TB when it goes high
    TB:
    PULSIN 8, 1, TB_POS
    lookup TB_POS min 5 max 18 - 5,
    [noparse][[/noparse]x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12], x
    pulsout 7,x
    debug "X" '<---- this shows one character on screen
    GOTO MAIN


    The debug command does take a bit of time, printing one X per
    revolution. The timing question is, how fast is your engine running?
    How long are the pulses you expect? There are people on this list
    who are much more qualified than I am to advise about engine timing.

    The PULSIN command on the BS2 will wait for up to 0.13 second for the
    start of the TB_POS, and the pulse on TB_POS can be up to 0.13
    seconds long. Does the pulse you expect fall within those limits?
    If not, you will have to take a different approach.

    -- regards,
    Tracy





    >my question is this, in my sample program below, i want to be able to
    >debug how often input 15 gose high, in other words i want to monitor
    >it has how fast the program is running... the reason for this is , is
    >that i want to see how many times a minite , input 15 gose high (BUT!
    >not useing the count command , sence that takes time away from the
    >program running rest of the code...)
    >
    >
    >'{$STAMP BS2}
    >TB_POS VAR BYTE
    >X VAR WORD
    >x0 CON 1000
    >x1 CON 2000
    >x2 CON 3000
    >x3 CON 4000
    >x4 CON 5000
    >x5 CON 6000
    >x6 CON 7000
    >x7 CON 7500
    >x8 CON 8000
    >x9 CON 8500
    >x10 CON 9000
    >x11 CON 9500
    >x12 CON 10000
    >
    >MAIN:
    >
    >INPUT 15
    >IF IN15 = 1 THEN TB
    >GOTO MAIN
    >
    >TB:
    >
    >PULSIN 8, 1, TB_POS
    >lookup TB_POS min 5 max 18 - 5,
    >[noparse][[/noparse]x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12], x
    >pulsout 7,x
    >
    >GOTO MAIN
    >
    >
    >*** u see i have the program run "TB" once input 15 gose high ... so
    >every time my engine's crank sensor triggers the input 15 to cause it
    >high, it will then run the sub program "TB" then look back to
    >the "MAIN" program....
    >
    >Sean....
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-07 14:18
    Hi,

    It looks like what you want is to detect the status of PIN 8, active
    or not. In this case PULSIN is not proper for your application because
    PULSIN works like a stopwatch counting the the timing between two
    states. What you need is just an INPUT command paired with IF
    statement or DO - LOOP

    main:
    IF IN15 = 1 THEN TB
    GOTO main 'Sometime you need to replace this with IF IN15 = 0 THEN
    'main, if for strange reason it breaks away from the loop
    or

    main:
    DO
    LOOP UNTIL IN15 = 1
    GOTO TB 'This may not be necessary if TB is just below it

    But from my experience with PBasic 2.5 those two examples sometime
    just break away from the loop for no reason especially when the
    program gets larger. The IF statement can't seem to exist on its own.
    It needs the comparison between the two states like 'IF IN15 = 1'. But
    when IN15 = 0 and if you don't specify it what to do, the program got
    confused. Even monitoring the PIN status with a scope, the program
    just breakaway from the loop while the status of the PIN didn't
    change. Perhaps guys from Parallax could explain this strange behaviour.

    Cheers,

    - Johari

    --- In basicstamps@yahoogroups.com, "djrevolution99"
    <djrevolution99@y...> wrote:
    > my question is this, in my sample program below, i want to be able to
    > debug how often input 15 gose high, in other words i want to monitor
    > it has how fast the program is running... the reason for this is , is
    > that i want to see how many times a minite , input 15 gose high (BUT!
    > not useing the count command , sence that takes time away from the
    > program running rest of the code...)
    >
    >
    > '{$STAMP BS2}
    > TB_POS VAR BYTE
    > X VAR WORD
    > x0 CON 1000
    > x1 CON 2000
    > x2 CON 3000
    > x3 CON 4000
    > x4 CON 5000
    > x5 CON 6000
    > x6 CON 7000
    > x7 CON 7500
    > x8 CON 8000
    > x9 CON 8500
    > x10 CON 9000
    > x11 CON 9500
    > x12 CON 10000
    >
    > MAIN:
    >
    > INPUT 15
    > IF IN15 = 1 THEN TB
    > GOTO MAIN
    >
    > TB:
    >
    > PULSIN 8, 1, TB_POS
    > lookup TB_POS min 5 max 18 - 5,
    > [noparse][[/noparse]x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12], x
    > pulsout 7,x
    >
    > GOTO MAIN
    >
    >
    > *** u see i have the program run "TB" once input 15 gose high ... so
    > every time my engine's crank sensor triggers the input 15 to cause it
    > high, it will then run the sub program "TB" then look back to
    > the "MAIN" program....
    >
    >
    > Sean....
Sign In or Register to comment.