Shop OBEX P1 Docs P2 Docs Learn Events
is there a way to single step through BS2 Pbasic ?? — Parallax Forums

is there a way to single step through BS2 Pbasic ??

mikedivmikediv Posts: 825
edited 2009-01-04 02:20 in BASIC Stamp
Hey guys I am doing some work with my boebot and I am having some problems with code I wrote is ther anyway to single step through it so I can see where my program is going wrong?, it kind of works fine but its not repeating the lcd driver so it works but then when it runs through a second time it fails somwhere I would love to be able to watch each step of the way and see where it breaks down? thnaks
·

Comments

  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2009-01-04 02:06
    mikediv

    The only thing that·I can tell you is to put debug statements where you think the problem might be and see where it is hanging up at this dose take a lot·time to this


    As far as doing one set at a time you can not do that

    The closes thing to this is run part of your routine one routine one at a time


    I have had the same problem when·I have add a LCD Display

    The routine will work OK with out the LCD display

    Can you post what you have so far and let see if we can help

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-01-04 02:07
    Hi Mike, the best thing to do if you have the program space is to place a few DEBUG instructions at places where the variable you are watching might be modified so that you can see if its doing as expected. If this is all happening too fast to observe follow the DEBUGS with a short pause to slow things down. Great that you want to debug the program for yourself, if you find you cannot resolve it you could always post the code here.

    Jeff T.
  • mikedivmikediv Posts: 825
    edited 2009-01-04 02:20
    Thanks guys, here is the code ' I put a label that says here is the new part of code so you can see where my problem is
    this code will work fine it displays a 1 or 0 in the mini LCD display and it also lights up an LED to let me know if the IR is activated and which side has been selected or both. the failuer is when it runs through the program a few times the display will no longer work the LEDS and everything else works perfectly fine it just seems to shut off the LCD if I hit reset the LCd comes back to life for a few trys then disapears again, I am adding a picture Also I am not 100 percent sure what you mean by add debug commands??? do you mean just add the command debug where I think there is a problem ?? is there a specific way to do it?? debug cr ?

    DO
    LfIrOut········ PIN···· 8·················· ' left IR LED output
    LfIrIn········· PIN···· 9··················· ' left IR sensor input
    RtIrOut········ PIN···· 2····················· ' right IR LED output
    RtIrIn········· PIN···· 0····················· ' right IR sensor input
    E·············· PIN···· 1······················ ' LCD Enable (1 = enabled)
    RW············· PIN···· 2······················ ' Read/Write\
    RS············· PIN···· 3······················ ' Reg Select (1 = char)
    LcdDirs········ VAR···· DIRB··················· ' dirs for I/O redirection
    LcdBusOut······ VAR···· OUTB

    '
    [noparse][[/noparse] Constants ]
    LcdCls········· CON···· $01···················· ' clear the LCD
    LcdHome········ CON···· $02···················· ' move cursor home
    LcdCrsrL······· CON···· $10···················· ' move cursor left
    LcdCrsrR······· CON···· $14···················· ' move cursor right
    LcdDispL······· CON···· $18···················· ' shift chars left
    LcdDispR······· CON···· $1C···················· ' shift chars right
    LcdDDRam······· CON···· $80···················· ' Display Data RAM control
    LcdCGRam······· CON···· $40···················· ' Character Generator RAM
    LcdLine1······· CON···· $80···················· ' DDRAM address of line 1
    LcdLine2······· CON···· $C0···················· ' DDRAM address of line 2

    '
    [noparse][[/noparse] Variables ]
    irBits········· VAR···· Nib···················· ' storage for IR target data
    irLeft········· VAR···· irBits.BIT1
    irRight········ VAR···· irBits.BIT0
    char··· VAR· Byte····· ' character for LCD

    '
    [noparse][[/noparse] EEPROM Data ]

    '
    [noparse][[/noparse] Initialization ]
    Initialize:
    · NAP 5········································ ' let LCD self-initialize
    · DIRL = %11111110····························· ' setup pins for LCD
    LCD_Init:
    · LcdBusOut = %0011···························· ' 8-bit mode
    · PULSOUT E, 3 : PAUSE 5
    · PULSOUT E, 3 : PAUSE 0
    · PULSOUT E, 3 : PAUSE 0
    · LcdBusOut = %0010···························· ' 4-bit mode
    · PULSOUT E, 3
    · char = %00101000····························· ' 2-line mode
    · GOSUB LCD_Command
    · char = %00001100····························· ' on, no crsr, no blink
    · GOSUB LCD_Command
    · char = %00000110····························· ' inc crsr, no disp shift
    · GOSUB LCD_Command
    · char = LcdCls
    · GOSUB LCD_Command

    '
    [noparse][[/noparse] Program Code ]
    ·DO
    Main:
    ··· FREQOUT LfIrOut, 1, 38500·················· ' modulate left IR LED
    ··· irLeft = ~LfIrIn··························· ' read input (1 = target)
    ··· FREQOUT RtIrOut, 1, 38500·················· ' modulate right IR LED
    ··· irRight = ~RtIrIn·························· ' read input (1 = target)
    ··· char = LcdLine1 + 1······· ' show left IR
    ··· GOSUB LCD_Command
    ··· char = irLeft + "0"······· ' convert bit to ASCII
    ··· GOSUB LCD_Write_Char······················· ' write it
    ··· char = LcdLine1 + 6······· ' show right IR
    ··· GOSUB LCD_Command
    ··· char = irRight + "0"
    ··· GOSUB LCD_Write_Char

    {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{here is the new part of the code}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
    ····· IF (irright = 1 ) THEN
    ···· HIGH 10
    ····· ELSE
    ···· LOW 10
    ···· ENDIF
    ···· IF (irleft = 1) THEN
    ···· HIGH 1
    ···· ELSE
    ····· LOW 1
    ····· ENDIF

    · LOOP


    '
    [noparse][[/noparse] Subroutines ]
    ' Send command to LCD
    ' -- put command byte in 'char'
    LCD_Command:··································· ' write command to LCD
    · LOW RS
    · GOTO LCD_Write_Char
    ' Write character to current cursor position
    ' -- but byte to write in 'char'
    LCD_Write_Char:································ ' write character to LCD
    · LcdDirs = %1111······· ' enable LCD bus outputs
    · LcdBusOut = char.HIGHNIB····················· ' output high nibble
    · PULSOUT E, 3································· ' strobe the Enable line
    · LcdBusOut = char.LOWNIB······················ ' output low nibble
    · PULSOUT E, 3
    · HIGH RS······································ ' return to character mode
    · LcdDirs = %0000······· ' release LCD bus
    · RETURN
    · LOOP
    ·· ENDlook at the section labled "" look here"
    1280 x 960 - 199K
Sign In or Register to comment.