Shop OBEX P1 Docs P2 Docs Learn Events
Serout command — Parallax Forums

Serout command

leshea2leshea2 Posts: 83
edited 2006-01-03 21:44 in BASIC Stamp
How would I make sure that the serout command was putting out the text message that I wanted it to put out, could I use the debug command to check it ?

Thanks !

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-02 20:06
    leshea -

    Sure, you might want to do this, during testing:

    'SEROUT pin_port, baudmode, [noparse][[/noparse]"data = ", datum]
    DEBUG "data = ", datum

    When you're done, just comment out the DEBUG statement, and UN-comment the SEROUT.

    Regards,

    Bruce Bates
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-01-02 20:19
    Another technique, albeit advanced, is to use conditional compilation.· You can set a conditional flag at the top of your program like this:

    · #DEFINE TestMode = 1

    And in your pin definitions do this:

    · #IF TestMode #THEN
    ··· Sout··· CON··· 16
    ··· Baud··· CON··· T9600 + Inverted
    · #ELSE
    ··· Sout··· CON··· 0
    ··· Baud··· CON··· T19K2
    · #ENDIF

    This will set the serial output to the programming port when TestMode = 1 (change to zero to set Sout to P0), and use the standard Debug baud rate of 9600 (inverted fro programming port).· The T19K2 constant is derived from a previous conditional-compilation structure that is included in my standard template·(posted several times).

    When you use TestMode you'll need to manually open the Debug Terminal window and set the comm port.· By using this technique there is no possibility that duplicating your SEROUT parameters in DEBUG will introduce an error.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • leshea2leshea2 Posts: 83
    edited 2006-01-02 21:43
    Bruce Bates, Can you show me how your code would be properly inserted into a code like this, so that it tests the data being sent out, to make sure that the info is all there ?

    Kira DATA "Call Dave at 1-800-465-8563 at 4:30 on Tuesday", 0

    Athrun VAR Word
    ML VAR Word

    Athrun = Kira
    Main:
    DO
    READ Athrun, ML
    Athrun = Athrun + 1
    IF (ML = 0) THEN EXIT
    SEROUT 3/4, 17405, [noparse][[/noparse]ML]
    LOOP
    END

    Thanks !
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-02 22:07
    leshea -

    ·"My code" doesn't test anything. I only suggested an easy way to use EITHER SEROUT or DEBUG, as you were testing your program. For that matter, you can use SEROUT AND DEBUG if you wish. The example below shows that. If you don't want both, just comment out the one you wish not to use.

    Kira DATA "Call Dave at 1-800-465-8563 at 4:30 on Tuesday", 0

    Athrun VAR Word
    ML VAR Word

    Athrun = Kira
    Main:
    DO
    READ Athrun, ML
    Athrun = Athrun + 1
    IF (ML = 0) THEN EXIT
    SEROUT 3/4, 17405, [noparse][[/noparse]ML]

    DEBUG ML

    LOOP
    END

    Regards,

    Bruce Bates
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-02 23:06
    leshea2,

    If you are looking for an example of how to send serial data, then you might be in interested in a project that I posted in "Projects":

    http://forums.parallax.com/showpost.php?p=0

    There·you find·Attached·a program called host_prj.bs1, it just reads some inputs and transmits a message, in ASCII (in an "endless loop".)

    What are you sending your text message to (another STAMP, a lap-top)?· How are you doing it (direct connection TTL, via a RS-232 converter)?


    Post Edited (PJ Allen) : 1/2/2006 11:10:44 PM GMT
  • leshea2leshea2 Posts: 83
    edited 2006-01-03 00:17
    If the word “Christmas” can be seen clearly on the debug screen when you use the debug command, dose that automatically mean that the word “Christmas” will be sent clearly when you use the serout or shiftout commands ?

    Thanks !
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-03 01:17
    I haven't seen your program.·

    As I see it, having "Christmas"·result on your Debug window is proof·only that the program got to a point in execution where the line was: DEBUG "CHRISTMAS".

    You have this line in one of your previous posts: SEROUT 3/4, 17405, [noparse][[/noparse]ML]· The Slash ( / ) is wrong.· SEROUT 3, 17405, [noparse][[/noparse]ML] would send the value contained in the variable ML out of P3, serially,·at 2400, 8N1.· Similarly, SEROUT 3, 17405, [noparse][[/noparse]"Christmas"] would send the word Christmas out of P3, serially, (2400, 8N1).

    ***·I'll re-ask my questions·from my last post -- What are you sending your text message to (another STAMP, a lap-top)?· How are you doing it (direct connection TTL, via a RS-232 converter)? ***· It would really help for me to know.
  • leshea2leshea2 Posts: 83
    edited 2006-01-03 18:42
    Thanks, you answered my question, but the reason I have 3/4 is because in the example on the BS editor, it list the use of the flow control pin, so do I not need it ?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-03 19:21
    · Flow control -- that is a Back Slash ( \ ).· You know, I don't use·flow control·(as part of SEROUT.)· I do it my way: my transmitter makes an RTS, on a output PIN of its own; if I want to I make another PIN an input to receive CTS, that way the STAMP gets confirmation that there is a device to send data to.

    [noparse][[/noparse] Does "Syntax Check" in the STAMP Editor allow a Forward Slash ( / )? ]

    · Ordinarily, I don't use flow control of any sort, but sometimes RTS (Request to Send) is useful, i.e.·when I use a certain radio modem, it turns of its transmitter, saving power, when there is no RTS present.· [noparse][[/noparse] So, I turn on my RTS pin, then I SEROUT my data, and then turn the RTS off. ]

    So, No, you don't "need" flow control.
  • SteelSteel Posts: 313
    edited 2006-01-03 21:44
    There is a tool that I used called 'Com Port Toolkit' that is a free download (Google it).

    Put this software on your PC, and you can see all communication to your comport.· I generally test my BS2 by doing a SEROUT to my PC, and making sure the signal is there with Comport toolkit.

    You can also send signals from your PC to the BS2 to verify that your SERIN commands work.
Sign In or Register to comment.