Shop OBEX P1 Docs P2 Docs Learn Events
Where is the first debug command in this code? — Parallax Forums

Where is the first debug command in this code?

Tyler MeekTyler Meek Posts: 21
edited 2011-09-11 12:15 in BASIC Stamp
Here is the first part of the example code supplied by Parallax for the SHT11 (temp/humidity)

tF VAR Word ' temp - Fahrenheit
soRH VAR Word ' humidity counts
rhLin VAR Word ' humidity; linearized
rhTrue VAR Word ' humidity; compensated
status VAR Byte ' status byte
'
' EEPROM Data
'
'
' Initialization
'
Initialize:
GOSUB SHT_Connection_Reset ' reset device connection
PAUSE 250 ' let DEBUG window open
DEBUG CLS,
"SHT11 Sensor Demo", CR,
"
", CR
'
' Program Code
'
Main:
DO
GOSUB SHT_Measure_Temp
DEBUG CRSRXY, 0, 3,
"soT...... ", DEC soT, CR,
"tC....... ", DEC (tC / 10), ".", DEC1 tC, DegSym, " ", CR,
"tF....... ", DEC (tF / 10), ".", DEC1 tF, DegSym, " "
GOSUB SHT_Measure_Humidity
DEBUG CRSRXY, 0, 7,
"soRH..... ", DEC soRH, CR,
"rhLin.... ", DEC (rhLin / 10), ".", DEC1 rhLin, "% ", CR,
"rhTrue... ", DEC (rhTrue / 10), ".", DEC1 rhTrue, "% "
PAUSE 1000
LOOP
END
'
' Subroutines
'
' connection reset: 9 clock cyles with ShtData high, then start sequence
'
SHT_Connection_Reset:
SHIFTOUT ShtData, Clock, LSBFirst, [$FFF\9]
' generates SHT11 "start" sequence
' _____ _____
' ShtData |_______|
' ___ ___
' Clock ___| |___| |___
'
SHT_Start:
INPUT ShtData ' let pull-up take high
LOW Clock
HIGH Clock
LOW ShtData
LOW Clock
HIGH Clock
INPUT ShtData
LOW Clock
RETURN


After Initialization there is the GOSUB command and then the PAUSE 250 'let DEBUG window open command/explanation

Where is the command to open the debug window in the first place?

Comments

  • PublisonPublison Posts: 12,366
    edited 2011-09-11 11:17
    It's here:
    Initialize:
    GOSUB SHT_Connection_Reset	' reset device connection
    PAUSE 250	' let DEBUG window open
    [COLOR="red"]DEBUG CLS,[/COLOR]
    "SHT11 Sensor Demo", CR,
    

    Make sure you have your declarations for your chip as in:
    '[COLOR="#2e8b57"] {$STAMP BS2}
    ' {$PBASIC 2.5}[/COLOR]
    
    "SHT11 Sensor Demo", CR,
    will not display. It needs to be:
    DEBUG "SHT11 Sensor Demo", CR
    
  • Tyler MeekTyler Meek Posts: 21
    edited 2011-09-11 11:42
    Why does the comment next to the PAUSE say…' let DEBUG window open…when the command to actually open it doesn't happen until the next line?
  • PublisonPublison Posts: 12,366
    edited 2011-09-11 12:01
    Tyler Meek wrote: »
    Why does the comment next to the PAUSE say…' let DEBUG window open…when the command to actually open it doesn't happen until the next line?

    The "Pause 250" is giving the program 250 ms (1/4 second) to give the "GOSUB SHT_Connection_Reset" routine time to return from the the reset. Otherwise it may miss some data.
  • Tyler MeekTyler Meek Posts: 21
    edited 2011-09-11 12:15
    Thank you, I understand now.
Sign In or Register to comment.