Shop OBEX P1 Docs P2 Docs Learn Events
Serial Comms Demo Example in BS Manual v2.2 — Parallax Forums

Serial Comms Demo Example in BS Manual v2.2

duhzzzduhzzz Posts: 7
edited 2009-02-19 12:42 in BASIC Stamp
I have tried to test on the·Demo program·on simple serial communication example in the Basic stamp manual v2.2 page 412-414. However, I could not get the communication to work.
Is there any thing wrong with my connections or code?

I have connected the flow control pin as shown in the attachment.

' SENDER
' {$STAMP BS2pe}
' {$PBASIC 2.5}
' {$PORT COM8}
SO PIN 1 ' serial output
FC PIN 0 ' flow control pin
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
Inverted CON $4000
Open CON $8000
Baud CON T38K4 + Inverted
Main:
DO
· SEROUT SO\FC, Baud, [noparse][[/noparse]"Hello!", CR] ' send the greeting
· PAUSE 2500 ' wait 2.5 seconds
LOOP ' repeat forever
END

' RECEIVER
' {$STAMP BS2px}
' {$PBASIC 2.5}
' {$PORT COM5}
SI PIN 0 ' serial input
FC PIN 1 ' flow control pin
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
Inverted CON $4000
Open CON $8000
Baud CON T38K4 + Inverted
letter VAR Byte
Main:
DO
· SERIN SI\FC, Baud, [noparse][[/noparse]letter] ' receive one byte
· DEBUG letter ' display on screen
· PAUSE 1000 ' wait one second
LOOP ' repeat forever
END
665 x 1021 - 135K

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-02-18 12:43
    S0 (pin 1) on sender should be connected to SI ( pin 0) on the receiver.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • duhzzzduhzzz Posts: 7
    edited 2009-02-18 14:32
    Oh ok...but i followed the instruction shown in the Manual where P1 is connected to P1.

    Is there a mistake in the manual?
    437 x 180 - 11K
  • stamptrolstamptrol Posts: 1,731
    edited 2009-02-18 15:11
    Just goes to show ya, the system works based on the code!

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • duhzzzduhzzz Posts: 7
    edited 2009-02-18 15:15
    thank youcool.gif
  • duhzzzduhzzz Posts: 7
    edited 2009-02-19 06:56
    Is the SEROUT only able to send 1 byte of information, meaning 0-255?

    How can I·send a value that is larger than that (Word VAR·eg. 1800).
  • stamptrolstamptrol Posts: 1,731
    edited 2009-02-19 12:42
    Use the modifiers "highbyte" and "lowbyte" which allows you to easily split a Word variable into two pieces.

    Have a look in the Help section of the development environment under "highbyte".

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
Sign In or Register to comment.