Shop OBEX P1 Docs P2 Docs Learn Events
Help DEBUGIN — Parallax Forums

Help DEBUGIN

bboy8012bboy8012 Posts: 153
edited 2007-08-17 18:54 in BASIC Stamp
I am not completely understanding the DEBUGIN command. I·referneced the book Whats a Microcontroller on page 122 and am not able to operate my Electronic speed controller. Attached is the code, can anyone give me insight please. This is to control a EDF F-35C jet using a joystick.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-17 18:31
    What don't you understand about DEBUGIN? What's happening when you run your program that you don't expect?
  • bboy8012bboy8012 Posts: 153
    edited 2007-08-17 18:40
    Well when I run the program it configures the ESC just fine, but when it comes to the subroutine debugTerm I expect it to apply the pulse I give it. To my suprise it doesnt.· I would like the debugTerm to take a value I input it and apply it as the pulse for the ESC until I change the value using the terminal.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-17 18:51
    The PULSOUT statement produces a single pulse. Your program is written to ask for a pulse duration, then produce a pulse, then wait for 20ms and ask again for a new pulse duration.

    Unfortunately, you probably want the Stamp to continuously produce pulses at the same time it's waiting for you to enter a new pulse duration and Stamps can't do that. They're what are called single threaded processors. They do only one thing at a time and there's no overlap possible. What you could do is attach a pushbutton to the Stamp, ask for an initial duration, then start a loop where there's a PULSOUT, then a PAUSE. The DO statement can include a condition and this can check to make sure the pushbutton is not pushed. If it's not pushed, the loop continues. As soon as you push the pushbutton, the loop stops and the outer loop repeats where your program asks for a new duration. The pushbutton can be hooked up like others shown in "What's a Microcontroller?". Typically, there's a 10K or 100K resistor from an I/O pin to ground and the pushbutton is connected between the I/O pin and +5V. For safety, use another resistor (like 1K) between the pushbutton and the +5V. The I/O pin (INx where x is the pin #) will be non-zero when the pushbutton is pushed.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-08-17 18:54
    Your loop would look something like this:
    debugTerm:
        DO
          DEBUG "Enter Duration:", CR
          DEBUGIN DEC duration
          DO WHILE IN15 = 0
              PULSOUT ESCpin, duration
              PAUSE 20
          LOOP
        LOOP
    
    


    The pushbutton would be connected as I described to I/O pin 15.
Sign In or Register to comment.