Shop OBEX P1 Docs P2 Docs Learn Events
setting up a 2nd serial port on the stamp Basic II — Parallax Forums

setting up a 2nd serial port on the stamp Basic II

NiallNiall Posts: 7
edited 2008-11-20 14:32 in BASIC Stamp
Basically, for my college project i need to have my stamp connected to my pc and be able to send an sms with·a modem (wavecom 1206B). For this i need the basic serial setup to my pc and another serial port for my modem. So i need to know can you have 2 serial ports on the stamp. ·Can this be done using the stamp alone or do i need additional hardware.
Any help or links to some useful sites would be brilliant.

Cheers Niall

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-20 14:27
    Yes, you can have a second serial port on the stamp.

    In fact, all 16 I/O pins, AND the Programming Port, can recieve serial data. But there's a catch.

    "Normal" UART chips run "in the background", taking data and interrupting the 'main processor' when there's data to take. The BS2 uses a 'bit-banging' algorithm to recieve serial data, which means it has to be WAITING in a SERIN statement to recieve serial data. There IS no 'background UART' hardware on the BS2 to 'buffer' serial data, so if it isn't waiting in a SERIN statement when serial data arrives, the data is ignored.

    And it's a single-tasking processor, so it can only 'wait' on one I/O pin at a time. Bummer.

    There's an additional issue, and that is that RS-232 data signalling levels are normally +- 3 to +- 10 volts. So you need a MAX232 (or equivalent) with 4 capacitors (to drive the MAX232 +- voltage supplies) to do this 'level shifting'.

    But there's LOTS of inexpensive solutions to both issues.

    1. You can add an inexpensive RS-232 recieve buffer chip. Like this one: http://www.rhombusinc.com/co-processors.html
    For $6.50, this will buffer up to 11 bytes, giving your BS2 some time to do something else while the data is coming in.

    2. You can add an inexpensive MAX-232 connector. Like this one: http://www.kronosrobotics.com/xcart/product.php?productid=16167&cat=261&page=1

    Note you only need the MAX-232 if you want your BS2 to be able to SEND (SEROUT) data to your serial device. If all you're doing is recieving, a simple 22Kohm series resistor can be used.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-20 14:32
    You can have several serial ports on a Stamp with some conditions:

    1) Only one port can send or receive at a time. This is a general limitation of the Stamps. None of the serial I/O is buffered.

    2) You will need some kind of interface circuitry if you're connecting to an RS232 serial port. This can be as simple as a 22K resistor in the receive lead.

    If you don't already have it, download the Parallax Basic Stamp Reference Manual and read the chapters on the SERIN / SEROUT statements
Sign In or Register to comment.