Shop OBEX P1 Docs P2 Docs Learn Events
Using a BSII to convert RS232 to TTL? — Parallax Forums

Using a BSII to convert RS232 to TTL?

Vern GranerVern Graner Posts: 337
edited 2005-08-30 14:16 in BASIC Stamp
I've been using the Rogue Robotics uMP3 unit and have found a need to be able to send data to/from the unit from my PC (i.e. for firmware updates). The uMP3 requires TTL level serial signals which make it fine for connection to the Basic Stamp, but they specifically state that connecting the uMP3 to "Standard" RS-232 levels may damage the unit. They reccomend the use of a MAX232 chip to convert the levels.

What I was wondering was if the BSII could be "programmed" to act like a MAX232, in effect allowing the BSII to accept serial data through the DB9 programming connector on the carrier board, and echo it to a pin, and vice versa. Has anyone done this, and if so is there code somewhere? TIA! smile.gif

Vern

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
Senior Systems Engineer    | obviously incompetent so why are we
Texas Information Services | paying you? Of course,if the network
http://www.txis.com        | is up, then we obviously don't need
Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG

Comments

  • steve_bsteve_b Posts: 1,563
    edited 2005-08-26 21:45
    The regular stamp pin can be connected to "standard" rS232 levels by using a resistor in series (22kohm I believe -- check the manual/help file under SERIN).
    Dare I assume that you could do the same with the uMP3?
    The resistor just limits the current going to those pins, and the stamp has clamping/clipping diodes that will chop the voltage level coming in.
    BUT, does the uMP3 want TTL levels in an RS232 format -- in RS232, a logical 1 is actually -12 volts (0volts TTL) and a logical 0 is +12volts (5volts TTL)....in regular TTL 1's are 5volts and 0's are 0volts.

    So, RS232 is inverted from TTL....what do you require? A MAX232 will take the RS232 and invert and convert it to give standard TTL out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    Steve

    "Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-26 21:54
    Vern,

    ·· In theory what you propose could work.· On the other hand, if the PC would be sending, say, MP3 files to the device, this may not work out so well.· The BASIC Stamp has no FIFO buffer.· You would need some flow control, and the transfers would be somewhat slower than what you'd get simply using a MAX232.· Of course, I have no technical details on your device, so this is all just off the top of my head.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Vern GranerVern Graner Posts: 337
    edited 2005-08-29 17:34
    Chris Savage (Parallax) said...
    Vern,

    In theory what you propose could work. On the other hand, if the PC would be sending, say, MP3 files to the device, this may not work out so well. The BASIC Stamp has no FIFO buffer. You would need some flow control, and the transfers would be somewhat slower than what you'd get simply using a MAX232. Of course, I have no technical details on your device, so this is all just off the top of my head.

    The uMP3 unit just needs commands sent to it and then it spits back result codes, kinda like a modem (i.e. "AT" results in "OK"). Although the firmware of the uMP3 is supposed to be updated this way so would be great if a simple program on the BS2 could sustain a transfer of a binary file. I think I'll experiment with this in the next few days. So, would you suggest I use "SERIN"/"SEROUT" or maybe shiftin? What would you guess would be a good starting point?

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-08-29 18:14
    www.kronosrobotics.com sells a small, in-expensive module ($10 or so), with DB-9 attached, for this very purpose (it has a MAX232 chip on it). It would be a shame to dedicate a $50.00 BS2 to this purpose -- plus the BS2 would probably miss some incoming bytes while it was sending on bytes already recieved.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-29 18:31
    Vern,

    ·· Sustained transfers would only be possible using flow control, but as I said would likely slow things down a bit.· So, how do you get the MP3s on to this device?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Vern GranerVern Graner Posts: 337
    edited 2005-08-29 20:03
    Chris Savage (Parallax) said...
    So, how do you get the MP3s on to this device?

    They have a SD/MMC card for the MP3s. You pre-load the card using your PC. The serial interface on the uMP3 is used to tell it what to play, to get status info and to change settings (i.e. play/pause, volume u/down, etc). The uMP3 can also used it to write data to files on the SD/MMC card so it can be used as a data recorder (i.e. record temperature readings over time etc.). It's pretty neat. For details have a look at the manual if you have a few minutes. smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-29 20:10
    Vern,

    ·· Thank you for the information.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Vern GranerVern Graner Posts: 337
    edited 2005-08-29 20:33
    allanlane5 said...
    http://www.kronosrobotics.com sells a small, in-expensive module ($10 or so), with DB-9 attached, for this very purpose (it has a MAX232 chip on it).
    Cool! Thanks for the link. That *is* quite inexpensive! I may have to get a couple of these just to have laying around. I sent the link to the guys at Rogue Robotics to see if this would work with the uMP3 just to make sure.
    allanlane5 said...
    It would be a shame to dedicate a $50.00 BS2 to this purpose -- plus the BS2 would probably miss some incoming bytes while it was sending on bytes already recieved.

    Though I agree it would be a waste to *dedicate* it to this purpose, in this case the BSII is already connected for the purpose of controlling the uMP3 so I was hoping to maybe have it serve "double duty" acting as in I/O interface allowing you to use a terminal program to interact with the uMP3 and/or upgrade the firmware through the BSII without having to remove the uMP3 from the circuit or having an additional Max 232 unit.

    If I can just download a small program that would let the BSII act as a MAX-232 long enough to program the uMP3, then load the "real" program back into the BSII, it would save the additional cost in parts and allow "field" reprogramming of the firmware in the uMP3. smile.gif

    Thanks again for the tip on the Kronos unit! smile.gif

    Vern

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Vern Graner CNE/CNA/SSE    | "If the network is down, then you're
    Senior Systems Engineer    | obviously incompetent so why are we
    Texas Information Services | paying you? Of course,if the network
    http://www.txis.com        | is up, then we obviously don't need
    Austin Office 512 328-8947 | you, so why are we paying you?" ©VLG
    
    

    Post Edited (Vern) : 8/29/2005 8:32:26 PM GMT
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-08-30 14:16
    Ah, well, if you already have a BS2 in there for some other purpose, then yes, with appropriate flow control between the BS2 and your PC (basically a "!" sync character so the BS2 can tell when it has missed some bytes, and request a re-send from the PC) then the BS2 could be used to program the uMP3.

    It would probably be slower than the MAX232 solution -- but would take less hardware. Your choice.
Sign In or Register to comment.