Shop OBEX P1 Docs P2 Docs Learn Events
Pin 16 question — Parallax Forums

Pin 16 question

firestorm.v1firestorm.v1 Posts: 94
edited 2006-04-22 00:55 in BASIC Stamp
When using the serial port on the HomeWork board (this may affect other boards, BOE, etc..) I know that i can use the serial port (programming port 9 pin Dsub) as pin 16.

Is there a way to turn off local echo on that serial port? Example, i hit "A", the stamp receives "A" and the Termainal app on the PC gets the letter "A". It's like the TX/RX pins on the stamp are connected to each other. Can someone verify this?

What I am trying to do is create a Serial LCD display that is bi-directional, where a pushbutton on the Basic Stamp, sends a command to the PC via the serial cable to interpret. (Right now, the button returns the value "1") but the PC also sends commands to the Stamp to display characters on the LCD, position cursor, set up LCD displays, etc..

Thanks in advance.

Comments

  • Tom WalkerTom Walker Posts: 509
    edited 2006-04-20 14:33
    You cannot change this behavior in software. It is hardwired and part the programming function that attempts to determine if a Stamp is hooked up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-20 15:49
    Yup, sorry about that, the RS-232 voltage conversion circuit on the BS2 uses the TX voltage when it is sending data back on the RX pin. The practical result of this is that every bit on the TX pin is also echoed back (by this hardware) to the RX pin.

    Since you're sending this data from the PC in the first place, in theory you already know the 'echo' will come back, and know how many characters to 'toss'. But it can be a pain.

    On the good side, you can use ANY I/O pin on the BS2 as an RS-232 recieve pin without a MAX232, IF you put a 22Kohm resistor in series with the signal. But then for the BS2 to 'talk' back with RS-232 levels you'll still need a MAX232.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-20 16:26
    Ok.. thanks for the quick reply. Now I'm off to find some 9 pin Dsub connectors.. :P
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-21 18:37
    Just because I am insanely curious, what is the difference between the voltage produced by the bs2 and the voltages produced by a serial port? I understand that it's a RS232 signal, but is that a TTL or some other voltage level? IIRC, the BS2 produces TTL voltages, correct?

    Thanks for your help with this, I have been wanting to learn signalling via RS232 and I guess here's my chance.. [noparse]:)[/noparse]
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-21 18:55
    "Classic" EIA-RS-232b, and RS232c standards, call out the pin-outs for the DB-25 connector, and the voltage levels for the signals. They started out at +- 12 volts -- a -12 voltage corresponding to a +5 volt "marking", or "idle" voltage. A +12 corresponds to a zero volt "spacing" signal. (Note I may have these 'senses' reversed -- a +5 is a "one", while a 0 volts is a "zero")

    So, you can see the +12 signal is associated with a zero-volt TTL, and a -12 volt signal associated with a +5 volt TTL. Thus, the RS-232 drivers were sometimes called "inverter-drivers".

    A full 'byte' (it's a byte oriented protocol) has a 'start-bit', 8 'data-bits', and one or more 'stop-bits'. The 'start-bit' guaranteed a transition at the start of the byte, while the 'stop-bit' guaranteed some time at the end of the byte.

    The MAX232 chip implements the full RS-232 specification. With the 'b' and 'c' variants, that +- 12 volts dropped down to +- 10 volts, and some laptops only put out +- 3 volts.

    Now, the BS2 CAN recieve ( that's RECIEVE only) the +-12 volt signal if you put a 22 Kohm resistor in series with it, to reduce the current to something that won't damage the PIC. When you do that, there's an inversion left in the signal, so the BS2 supports recieving this 'Inverted' signal with the 'Inverted' baud-modes. What's 'inverted' and what isn't depends on your interpretation, so this can take some experimentation to get it to work.

    Still, to TRANSMIT the 'true' RS-232, +- 12 volt (or +- 10 volt, whatever) signal will still take a MAX232 driver.

    Post Edited (allanlane5) : 4/21/2006 6:59:22 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-04-21 19:09
    Firestorm may be interested in this -- http://www.parallax.com/detail.asp?product_id=29120
    There are other similar ready-made circuit-boards for implementing a full-fledged 5V-to-RS232 solution.

    Post Edited (PJ Allen) : 4/21/2006 7:12:17 PM GMT
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2006-04-21 21:01
    PJ Allen: That is exactly what I was looking for, sadly I don't have the $30 and will need to roll a lot of pennies to get it.. [noparse]:([/noparse] Maybe I can convince some of my friends that owe me birthday presents to get me a BoE and BS2 so I can use the AppMod headers.. [noparse]:)[/noparse]

    Allanlane5: Thank you for the very informative post. That will help tremendously as soon as I can afford the parts. Just to make sure I understand, TTL is signalling between 0 and 5v and RS232 is between 0 and 12vdc or 0 and -12vdc, correct?

    Thank you both.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-21 21:46
    Firestorm -

    Allan's post was excellent and quite detailed. I'd just like to make one addition to one part of it. Allan said:

    "A full 'byte' (it's a byte oriented protocol) has a 'start-bit', 8 'data-bits', and one or more 'stop-bits'. The 'start-bit' guaranteed a transition at the start of the byte, while the 'stop-bit' guaranteed some time at the end of the byte."

    To that I would just add the following:

    If parity is specified (common forms: odd or even) one additional bit will be transmitted, prior to the 'stop-bit', which contains the appropriate parity for the particular data byte to be transmitted. The bit is set or not, based on the parity specified, and the raw parity of the 8 bits in question. Here are the basic rules, although the calculation is much simpler than these rules may seem to imply (Note: The "raw parity" is the parity of the 8 data bits alone. The raw parity is calculated as the left-truncated one bit wide total of all 8 data bits.):

    If ODD parity is specified, and the raw parity is already ODD, the parity bit is set to ZERO. If ODD parity is specified, and the raw parity is EVEN, the parity bit is set to ONE to cause it to be ODD. In either case the 8 data bits + the parity bit, now represent the appropriate parity as specified.

    If EVEN parity is specified, and the raw parity is already EVEN, the parity bit is set to ZERO. If EVEN parity is specified, and the raw parity is ODD, the bit is set to ONE to cause it to be EVEN. In either case the 8 data bits + the parity bit, now represent the appropriate parity as specified.

    If you want the "bible" on asynchronous serial data transmission, the following comes HIGHLY recommended: "Serial Port Complete", Jan Axelson, and here is a link to her web site: http://www.lvr.com

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 4/21/2006 9:50:51 PM GMT
  • ForrestForrest Posts: 1,341
    edited 2006-04-22 00:23
    It's fairly simple to build an RS232 to TTL circuit using a Maxim MAX232CPE or a TI MAX232N chip, (4) 1uF Electrolytic capacitors, a DB9 connector plus a small circuit board to hold the circuit. Shouldn't cost more than $5 plus shipping for all the parts. For the cicrcuit, just Google MAX232
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-22 00:55
    Well, it's POSSIBLE to do the RS-232 protocol (start bit, 8 data bits, stop bits) in TTL -- in fact, that's what the BS2 does. It expects you to then run that TTL signal into a MAX232 if you want to talk with some other 'public' RS232 interface -- like a modem, or a PC. However, you can connect two BS2 modules together, and just use the TTL version of RS232. It doesn't meet the electrical standard (which calls out that +- 12 volts), but that's not a problem.
Sign In or Register to comment.