Shop OBEX P1 Docs P2 Docs Learn Events
Using DEBUG effectively — Parallax Forums

Using DEBUG effectively

MorrolanMorrolan Posts: 98
edited 2007-09-19 09:55 in BASIC Stamp
Hi, I'm writing a very small program that as yet is completely untested, so please excuse me if the program doesn't appear to make much sense yet - I am simply more concerned over the appearance of seemingly random characters in the debug window?

lrandw = 27687
randb = 108
Tÿ



Whereas the output should be simply:

randw = 27687
randb = 108


The code that is producing this is below:

' {$STAMP BS2e}
' {$PBASIC 2.5}

sync       CON         255      ' Sync byte set to 255
servo      VAR         Byte     ' Servo Number
position   VAR         Byte     ' Servo position
n96n       CON         $4054    ' Comms set to 9600 baud (look into this stuff)
signal     CON         11       ' Controller set to pin stamp pin 11

randw      VAR         Word     'Seed and result for RANDOM.
randb      VAR         Byte     'Returned result.

  Main_Loop:

        servo = 0

  RANDOM randw
  randb = randw / 256
  DEBUG DEC ? randw, DEC ? randb

        position = randb

        SEROUT signal,n96n,[noparse][[/noparse]sync,servo,position]

        PAUSE 3000

GOTO Main_Loop:




This is using a BS2e and a servo controller board from a UK company called Milford Instruments (hence why the SEROUT might not make immediate sense).

But, why does the debug window show an L at the beginning in the example above, and the Ty? I've looked at DEBUG in the syntax and reference manual but it doesn't go into enough detail to clear this up for me.



Many thanks in advance,
Morrolan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-18 17:12
    The extra characters may be due to noise or timing problems on the serial port and have nothing to do with the DEBUG statement. I don't know how you're powering the servo and servo controller, but that may have something to do with it. Your program should output a new random value every 3 seconds, yet you show only one. What happened? Did you just download the program and run it or did you download it, fiddle with the hardware, then start the program?
  • MorrolanMorrolan Posts: 98
    edited 2007-09-19 09:55
    The board and Stamp are powered by a 9v mains adapter - the board contains a voltage regulator so the stamp receives 5v on the Vss pin.

    Below I have attached a link and image - unfortunately they don't provide a schematic of the board, but hopefully the picture might help.

    The only thing I can think of is that I didn't actually have the servo's connected to the board when I was testing this, so could that be the cause of the noise at all? The servo's connect to the header pins on the right - I'm wishing that I'd just waited for them to get the Parallax servo controller back in stock rather than buy theirs! The code still works by the way, but I'm curious about the debug rather than worried.


    http://www.milinst.com/animatronics/animsside.htm

    (it is the servo 8 controller)


    Many Thanks,
    Morrolan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Flying is simple. You just throw yourself at the ground and miss.

    Post Edited (Morrolan) : 9/19/2007 12:18:19 PM GMT
    980 x 735 - 133K
Sign In or Register to comment.