Shop OBEX P1 Docs P2 Docs Learn Events
USB communication with BS2 : TTL <-> RS232 shifting — Parallax Forums

USB communication with BS2 : TTL <-> RS232 shifting

snotlingsnotling Posts: 7
edited 2010-11-11 07:51 in BASIC Stamp
Hello,

I have a USB Board of Education and it works just fine with my BS2.
Now I'd like to move my BS2 from the board to a standalone device of mine, connected by USB (requirement).

So I need to build a similar USB transmission module as there is on the board, to be able to communicate with the BS2 over the SIN, SOUT and ATN pins. The other TTL pins are not acceptable as I need to be able to "remotely" program the BS2.

If I'm not mistaken, the SIN, SOUT and ATN pins require RS232 levels.
Then I suppose that I have to have a level shifter between my USB TTL module and the BS2. Please note that my module is based on a CP2102 chip, which produces 3.3v signals AFAIK -- and should accept 5v levels, though I'm not sure what it means.

So, starting from the BOE USB schematics, what modifications are required to switch from a 5v FT232R to 3.3v CP2102?
I'm thinking in particular of the resistors linked to Q1, Q2 and Q3.
I'm kind of a beginner at electronics so I'm sorry if the question is trivial :-)

On a side note, isn't it kind of odd to have to produce RS232 levels from USB TTL chips... to have them subsequently converted back to TTL right on the BS2?
Wouldn't it be easier to have BS2 chips that directly accept TTL levels on SIN, SOUT and ATN pin?

Thanks for your help!

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2010-11-09 16:23
    snotling wrote: »
    Hello,

    I have a USB Board of Education and it works just fine with my BS2.
    Now I'd like to move my BS2 from the board to a standalone device of mine, connected by USB (requirement).

    So I need to build a similar USB transmission module as there is on the board, to be able to communicate with the BS2 over the SIN, SOUT and ATN pins. The other TTL pins are not acceptable as I need to be able to "remotely" program the BS2.

    If I'm not mistaken, the SIN, SOUT and ATN pins require RS232 levels.
    Then I suppose that I have to have a level shifter between my USB TTL module and the BS2. Please note that my module is based on a CP2102 chip, which produces 3.3v signals AFAIK -- and should accept 5v levels, though I'm not sure what it means.

    So, starting from the BOE USB schematics, what modifications are required to switch from a 5v FT232R to 3.3v CP2102?
    I'm thinking in particular of the resistors linked to Q1, Q2 and Q3.
    I'm kind of a beginner at electronics so I'm sorry if the question is trivial :-)

    On a side note, isn't it kind of odd to have to produce RS232 levels from USB TTL chips... to have them subsequently converted back to TTL right on the BS2?
    Wouldn't it be easier to have BS2 chips that directly accept TTL levels on SIN, SOUT and ATN pin?

    Thanks for your help!
    '
    Take a look at this.
    '
    Hope it helps
    '
    http://www.parallax.com/Store/Accessories/CablesConverters/tabid/166/CategoryID/40/List/0/SortField/0/Level/a/ProductID/378/Default.aspx
  • snotlingsnotling Posts: 7
    edited 2010-11-10 02:26
    Hello $WMc%,

    Yes, that's the kind of device I'm trying to build -- not buy, as I do already have a "USB TTL converter". Plus I don't a need a DB9 connector.

    After some googling I've learned that the BS2 uses +/- 12V on SIN and ATN but +5/-12V on SOUT. All of this using RS232 signaling of course.

    So my understanding is that the 3-transistor based setup is there to do TTL <-> RS232 translation, in terms of voltage and level inversion.

    Am I right ?

    Now I'm a total newbie at transistors, so I'm still trying to determine if switching from a 5V FT232R (Parallax setup) to a 3.3V CP2102 module (my setup) dictates any change in the various components, in particular the resistors. My idea is that it probably does, so I think I'll have to go back to "transistors 101" first...

    But any hint would still be appreciated :-)
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-11-10 05:13
    Hi, the serial signals at the Stamp should be TTL , that is 0 volt to 5 volt.

    If the setup is to use a RS232 com port from a computer then a line driver is needed to take the signals from the com port (which are in excess of +/- 10 volt ) and present them to the BS2 at TTL levels and inverted. The Stamp Module has this line driver built onto the modules circuit board.If you build your own Stamp circuit board its down to you to also build a line driver.

    If the setup is to use USB to serial using a virtual com port and you want to use a chip other than the FT232 you can probably power your USB/serial converter from the USB power rails (0-5 volt) , check the data sheet. The three transistors with base resistors on your schematic should be ok as is too , the 5 volt at each transistor is taken from the USB supply. Its also important when you have signals from different power sources that the 0v/grounds are connected at a common point.

    Jeff T.
  • snotlingsnotling Posts: 7
    edited 2010-11-10 06:16
    Hello Jeff,
    Hi, the serial signals at the Stamp should be TTL , that is 0 volt to 5 volt.

    Hum, are you sure of that? From what I've read, only the "general purposes" P0-P15 pins accept TTL levels, whereas it's not the case with SIN, SOUT and ATN, which are (almost) running at like RS232 ports.
    If the setup is to use USB to serial using a virtual com port and you want to use a chip other than the FT232 you can probably power your USB/serial converter from the USB power rails (0-5 volt) , check the data sheet. The three transistors with base resistors on your schematic should be ok as is too , the 5 volt at each transistor is taken from the USB supply. Its also important when you have signals from different power sources that the 0v/grounds are connected at a common point.

    Yes, I'm in the "USB to serial" use case. For the transistors, I was looking at calculators but I'm still struggling to get a grasp of how this all works :-)
  • snotlingsnotling Posts: 7
    edited 2010-11-11 03:03
    Hi, the serial signals at the Stamp should be TTL , that is 0 volt to 5 volt.

    Alright, I've used my oscilloscope, done some measurements and indeed, SIN, SOUT and ATN behave like TTL @ 5V.
    On a side note, I also got some strange readings on SIN, which goes at ~ 2.74V when the BS2 is simply powered up and then ~ 3.68V once the USB cable is plugged in (?!), even though I never do any SERIN calls in my code.

    Anyway, back to the topic, now I don't understand why the FTDI USB TTL module on the Board of Education isn't directly wired to the BS2 ??
    What's the use of these 3 transistors then, which I though was related to RS232 <-> TTL conversion ?

    I'm lost :-)
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2010-11-11 05:32
    Hi , the transistors buffer and invert and in the case of USB_DTR apply a pulse to Stamp pin ATN from the 3.3-5v output from the USB to Serial converter.

    Jeff T.
  • electrosyselectrosys Posts: 212
    edited 2010-11-11 05:51
    When we talking about Basic Stamp module, we have to take in consider that actually, there are two kind Basic Stamp modules:

    1- The actual Basic Stamp Module, like this one:
    attachment.php?attachmentid=75165&stc=1&d=1289479999
    This module is configured (programming part, pin1 SOUT, pin2 SIN & pin3 ATN) to directly connect to PC serial COM part (D9) which is RS232 (~ -12 / +12 volt) that is why there is a line drive circuit on board on the Basic Stamp module, to convert the PC RS232 to TTL signals. Therefor we can not connect the TTL signals to the Basic Stamp (programming part pin 1,2 & 3) module above)) because the line drive on board would inverted the TTL signals.


    2- The other Basic Stamp module which we talk about is the OEM kit module like this one (schematic)
    bs2oemlite_01_hi.jpg
    This one has no line drive circuits, and that's why you must not connect it directly to the PC D9, but you could connect this module to the TTL signal, like USB to (serial-TTL) converter. I hope that could be at your help.
    Download Basic Stamp schematics from Parallax web pages and study them. You could also read some more about the BS2 and RS232 interface circuity here at this Parallax web page, that explaining much more and schematics as well:
    http://www.parallax.com/tabid/802/Default.aspx
    Have this in mind that no BS2 module could be connected directly to the PC serial part D9, but only programming part(pin 1, pin2 & pin3) of the BS2 (first module above)
    107 x 182 - 5K
  • snotlingsnotling Posts: 7
    edited 2010-11-11 07:51
    Yes, you're right, I missed the "inverted" detail.
    The BS2 is really a strange animal, kind of hybrid between RS232 and TTL.
    Plus the difference between the IC and OEM version that must have confused me.

    After all, the easiest thing to do is to build the inverter according to the schematics of the BOE-USB and see how it works in practice :smilewinkgrin:

    Thanks for your help.
Sign In or Register to comment.