Shop OBEX P1 Docs P2 Docs Learn Events
How to connect Serial pin with DTR/DSR/RTS/CTS ? — Parallax Forums

How to connect Serial pin with DTR/DSR/RTS/CTS ?

BronsonBronson Posts: 44
edited 2006-03-10 00:35 in BASIC Stamp
Hi,

I would like to connect a electronic scale to BS2 by RS-232 connection.
I found out that the scale needs 'handshaking' method, connecting RXD,TXD,GND only couldn't work.
Here is the pin connection (Device - PC):
===================
2 RXD
3 TXD
3 TXD
2 RXD
7 RTS
1 CD
8 CTS
1 CD
---- 4 DTR
|
---- 6 DSR
---- 7 RTS
|
---- 8 CTS
5 GND
5 GND
===================
(SCALE) (PC)
===================

I would like to replace the PC with BS2.
Pls tell me how can I implement this pin connection with BS2, and how about the programming code?
The purpose of the connection is BS2 send ASCII commands, and the scale reply by sending back ASCII codes.

Thanks, this forum is great.....

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-09 05:54
    Have a look at these docs: http://www.parallax.com/dl/docs/prod/appmod/Rs232.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • BronsonBronson Posts: 44
    edited 2006-03-09 05:54
    Hi,

    It seems that the pin connection looks confusing.
    ========
    ---- 4 DTR
    |
    ---- 6 DSR
    ---- 7 RTS
    |
    ---- 8 CTS
    ======== above connection is belongs to PC

    Thanks
  • BronsonBronson Posts: 44
    edited 2006-03-09 06:26
    Thanks for your quick reply, Jon.
    But due to my lask of experience in DTR/DSR/RTS/CTS, I don't understand the relation between my project and your attachment.
    How can I replace PC with BS2, since BS2 doesn't have any DTR/DSR/RTS/CTS/CD?

    Thanks,
    Bronson
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-03-09 10:53
    This is a part of RS-232 that has a long history of creating confusion.
    In the early days, some of these handshaking lines were needed due to slow machines needing to tell the faster device to wait.

    In many cases you can eliminate a lot of hassle by 'fooling the machine' into thinking it received the correct handshaking response and it will merely stand ready to receive and transmit immediately.

    Since the BasicStamp does not have these, it is likely that it would just have to keep up in that same manner.

    Alternatively, you could create a serial port [noparse][[/noparse]other than the one used for programing -- which always ECHOs messages] and additional handshaking pins that operate with software control. Then, the Stamp could say it is busy and know if the other device is busy.

    Try to observe which pairs work together.· I believe that, at your device, conecting Pin 7 to Pin 8 AND Pin 4 to Pin 6 would create the illusion you want. But that is assuming the Scale has all the same lines on the above PC diagram.

    Take care to get things right though. If you short out a pin to ground, it might do some damage to the RS-232 driver and receiver.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 3/9/2006 11:06:59 AM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-03-09 11:21
    It looks like standard connections to me, with the exception of CD.
    The pc has local handshakes RTS/CTS and DTR/DSR, the scale has local
    handshake RTS/CTS. The scale local handshake also connects to the
    pc Carrier Detect input, most probably for signaling the pc when
    results are available. You need to know the protocol used by the
    original pc program.
    One possible protocol:
    The scale asserts its handshake (and thus CD) so the pc program knows
    when it can send a command.
    For the BS, use 3 pins: TX (serial out), RX (serial in), CD (digital in).
    (You'll need a rs232 level converter like max232).
    The BS waits for asserted CD (if CD = 1), then BS sends a command (SEROUT), then BS
    waits for the response from the scale (SERIN).

    regards peter
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-09 12:05
    Bronson -

    This is really a good deal easier than it may appear on the face of it. You just need the appropriate documentation, and just a bit of guidance.

    All of the information you are requesting regarding the connections and wiring can be found in both the PBASIC Manual, and the PBASIC Help File. Both will show the pinouts for DB-9 and DB-25 RS-232 connectors (respectively), how they need to be wired or jumpered to effect flow control and how to defeat hardware handshaking. Both reference items can be downloaded for FREE directly from the Parallax web site here:

    Manual - http://www.parallax.com/html_pages/downloads/basicstamps/documentation_basic_stamp.asp

    Editor/IDE and Help File -
    http://www.parallax.com/html_pages/downloads/software/software_basic_stamp.asp

    The SERIN and SEROUT commands are the ones you will need to communicate with your scale. Note carefully, the FPIN parameter on both commands, as that represents the flow control pin facility. For SERIN the flow control pin will be an OUTPUT, and for SEROUT the flow control pin will be an INPUT. You do not need to be concerned about the direction of those pin (input or output) as SERIN/SEROUT will handle that for you.

    You will need to defeat the hardware handshaking, since there is no modem between the two devices. You are using what might be called a direct connection, as opposed to a through-modem connection. Thus, CD (carrier detect) must be provided artificially by tieing it to a fixed voltage pin on the connector, as there is nothing in this direct connection method which is able to provide the signal electronically as a modem would. CD ordinarily comes from the modem, and indicates that the connection has been made or is extant.

    Please note also that communication speed is limited when using any PBASIC Stamp and flow control. The connection is speed-limited to 19.2 KBPS (19,200 BPS), due to the time required to handle the flow control pins.

    Just as a reminder, the following pins will need to be "tied" on the RS-232 connector (example below is for a DB-9, DB-25 in shown in the reference material also):

    Pins 1 + 4 + 6 all tied together

    Pin 7 tied to pin 8

    That's all there is to the basic wiring set-up. The rest will be determining the appropriate baud rate, parity, etc and once that is found, using the appropriate BAUDMODE (PBASIC terminology) which represents that baud rate, parity, etc in the SERIN and SEROUT commands. Then it's just a matter of sending and receiving the scale commands and processing the returned data.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • stamptrolstamptrol Posts: 1,731
    edited 2006-03-09 12:32
    Bronson,

    You should be able to get the scale talking to the Stamp without too much trouble as has generally been pointed out.

    My own scale experience would suggest you'll need only the pin 2, 3, 5 between scale and stamp. However, at the scale end you'll have to connect the hand shaking pins so the scale indicator will think everthing is properly connected. Usually jumpering 4-6 and 7-8 at the indicator will do the trick.

    One little wrinkle with a couple of old Toledo ( I think) indicators I worked on was that the RS-232 circuitry in the indicator depended on the PC's negative voltage circuitry to generate part of the RS-232 signal. Normally thats not a problem, except the Stamp is also set up the same way, so an external negative (-5 to -12) source is required. Not hard to do with an external chip or some creative power supply mods, but a bit mystifying if you run into it without warning.

    Feel free to contact me directly if you have other questions.

    Tom
  • BronsonBronson Posts: 44
    edited 2006-03-10 00:35
    Waw...
    Thx for all of your responses. I have solved it because of you guys....
    I just connect RXD,TXD,GND in proper way, then I jumpered RTS & CTS at the scale. It works!!
    This 'handshaking' protocol is still confusing to me, but I've got the rough picture.

    Thx again,
    Bronson
Sign In or Register to comment.