Shop OBEX P1 Docs P2 Docs Learn Events
Entering a value in debug terminal without pressing enter. — Parallax Forums

Entering a value in debug terminal without pressing enter.

Tyler MeekTyler Meek Posts: 21
edited 2013-04-03 11:20 in BASIC Stamp
Hi all, what is the best way or a way to monitor a value imputed into the debug terminal without pressing enter?

DEBUGIN DEC Name_Value
IF Name_Value = 8 THEN....

...ENDIF

I don't want to press enter after the value 8 is pressed.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-01 19:13
    You don't have to press Enter. Any non-numeric character will work like a space or comma or period. If the number is always only one digit, then you can use DEC1 instead of DEC and the non-numeric delimiter is not needed. Be a bit more specific about what you're trying to do and we can give you more specific suggestions.
  • Tyler MeekTyler Meek Posts: 21
    edited 2013-04-01 19:26
    I'll have to wait until I get home to post my code (at work with small phone and fat thumbs).
    In the mean time what is DEC short for? I have been thinking it was the deceleration for any number 0 to 9.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-01 20:30
    DECimal, HEXadecimal, BINary
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2013-04-02 09:11
    Tyler,
    Also you can use simply
    [SIZE=1][FONT=courier new]DEBUGIN  Name_Value
       IF Name_Value = "8" THEN....[/FONT][/SIZE]
    
    Note that there is in this snippet no DEC before Name_Value, and the 8 is in quotes. The response input could be any character, not just numeric, for example "A", or "$". No ENTER required.
  • Tyler MeekTyler Meek Posts: 21
    edited 2013-04-02 10:10
    HA that works! I froze it up again but it works. Mike, this is an experiment to use the number pad on my keyboard to step a stepper motor manually. I didn't want to have to press enter, or as I have learned, any other key other than the number specified - 8 for counterclockwise rotation, 2 for clockwise. I am doing this to (in the future) move my ceiling trolly along its track manually. I will modify this program to count how many steps were used ( how many times I pressed "8") to move the trolly to the desired position. I can then use the number of steps used as a measurement value to automate the trolly to move from point A to point B. Of course there are many other ways to do this like trial and error but this is more fun.
    Now to figure out why I am freezing up. I pressed 8, held it, all was well, and whamo I got this (see picture).
    IMG_1146.jpg
    IMG_1147.jpg
    IMG_1148.jpg
    1024 x 1365 - 135K
    1024 x 1365 - 186K
    1024 x 1365 - 149K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-04-02 19:41
    IF human_step_control = "8" THEN
    GOSUB step_fwd
    
    IF human_step_control = "2" THEN
    GOSUB step_rev
    
    endif
    endif
    

    versus
    IF human_step_control = "8" THEN
    GOSUB step_fwd
    endif
    
    IF human_step_control = "2" THEN
    GOSUB step_rev
    end if
    

    ? ? ?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-02 21:01
    Post your code if you want an answer to your freeze problem.
    attachment.php?attachmentid=78421&d=1297987572
  • Tyler MeekTyler Meek Posts: 21
    edited 2013-04-03 09:28
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    ' {$PORT COM4}
    
    Phase         VAR       OUTB      'phase control outputs
    
    StpsPerRev    CON       48        'whole steps per rev
    
    
    idx                     VAR       Byte      'loop counter
    stpIdx                  VAR       Nib       'step pointer
    stpDelay                VAR       Byte      'delay for speed control
    Human_Step_Control      VAR       Word
    
    Steps          DATA      %0011, %0110, %1100, %1001
    
    
    Setup:
      DIRB = %1111
      stpDelay = 15
    
    Main:
      FOR idx = 1 TO StpsPerRev
        GOSUB Step_Fwd
      NEXT
      PAUSE 20
      FOR idx = 1 TO StpsPerREv
        GOSUB Step_Rev
      NEXT
      PAUSE 500
      GOTO Test
    
    
    Step_Fwd:
      stpIdx = stpIdx + 1 // 4
      GOTO Do_Step
    
    Step_Rev:
      stpIdx = stpIdx + 3 // 4
      GOTO Do_Step
    
    Do_Step:
      READ (Steps + stpIdx), Phase
      PAUSE stpDelay
      RETURN
    
    
    
    Test:
    
     DEBUG  CLS, "Control Stepper:", CR
    
     DO
            DEBUGIN  Human_Step_Control
    
            IF  Human_Step_Control = "8" THEN
            GOSUB Step_Fwd
            PAUSE 50
            DEBUG CLS
            ENDIF
    
            IF Human_Step_Control = "2" THEN
            GOSUB Step_Rev
            PAUSE 50
            DEBUG CLS
            ENDIF
    
     LOOP
    
  • Tyler MeekTyler Meek Posts: 21
    edited 2013-04-03 10:27
    PJ Allen wrote: »
    IF human_step_control = "8" THEN
    GOSUB step_fwd
    
    IF human_step_control = "2" THEN
    GOSUB step_rev
    
    endif
    endif
    

    versus
    IF human_step_control = "8" THEN
    GOSUB step_fwd
    endif
    
    IF human_step_control = "2" THEN
    GOSUB step_rev
    end if
    

    ? ? ?
    My way of thinking, which after reading your blog post is more malleable than ever, is: "IF" implies uncertainty and "ENDIF" implies finality. It isn't really possible to have an option between doing two things if one option is removed before a decision is made. Three options kinda blows my thinking out of the water. What is the standard? - ENDIF after each IF?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-03 11:20
    Think of the IF/THEN as an opening parenthesis and the ENDIF as a closing parenthesis. They have to match like () and they can nest like ((( ))) or (()(())). Your first example looks like (()) and your second like ()(). They mean different things. I would actually do something different like
    if human_step_control = "8" then
       gosub step_fwd
    elseif human_step_control = "2" then
       gosub step_rev
    endif
    
    or
    select human_step_control
    case "2"
       gosub step_rev
    case "8"
       gosub step_fwd
    endselect
    
Sign In or Register to comment.