Shop OBEX P1 Docs P2 Docs Learn Events
RS232 to TTL Converters worthwhile? — Parallax Forums

RS232 to TTL Converters worthwhile?

OtterOtter Posts: 12
edited 2009-03-15 21:09 in Robotics
Hello Again Guys,

Despite what Mike Green mentioned, I still want to build a robot based on a tablet PC without any other microcontroller.· He made a good point, which was that a PC will want to use RS232 and all these cool devices use TTL serial interfaces which are inheirently incompatible.

The point of this message is that I'm still stubborn, but your expertise could keep me out of trouble.

Per his advice, it might just be easier to plop a BS2 between the PC and the other goodies.

But what about a simple translator like this?:
http://www.bb-elec.com/bb-elec/literature/232LPTTL-3406ds.pdf

Allegedly, I can just tie the receive and transmit lines together and I have a TTL serial I/O line.· I don't expect this to be magic.· For example, I have no idea how the bits/bytes/words will get translated.·· Will I run into a problem with communication phrases of really akward lengths?· What about something like Ping))) which actually has to measure the time of a pulse?

If anybody has any experience with attempting something like this your advice is sure appreciated.

Sincerely,

-Todd







▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • GWJaxGWJax Posts: 267
    edited 2009-01-31 23:16
    This looks like what I will be using but I'm building my own circuit from the MAX323N chip for interaction and data crunching for my Elvinator Project which will be using 3 BS2px24 chips. I don't want to give out my circuit just yet because I'm adding it to my articles that I have with RoboCommunity and they have first dibs on it along with all the programming that will be evolved and I don't want to spoil the fun and anticipation that the members are waiting on. But you do have the right idea and it can be done with this module also it would be easier to control your bot with the BS2 stamps and the correct program to interface it with.

    Jax

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • OtterOtter Posts: 12
    edited 2009-02-01 00:28
    Jax,

    Thanks for the reply.· I hope none of the engineers here think I'm too weak here to dig into microcontrollers.· It's just that, hey, if I can only code for one animal, I'd rather keep it to one animal.· Fortunately it's a cheap experiment to perform with the·rs232/TTL converter.· But perhaps someone can save me a few bucks.

    Oh... and just in case you guys haven't gotten enough of it (and completely off topic) I'm posting the link to the cute little 'bot with the tracking head (set to music... hehe) again.·

    Sorry.

    -T·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • kwinnkwinn Posts: 8,697
    edited 2009-02-01 04:31
    Otter, all you need is the MAX232 to go from the +-12V of rs232 to the 0-5V TTL levels. Download the data sheet and it should even have a schematic.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-01 05:14
    The RS232 to TTL conversion device you indicated is essentially a MAX232 all pre-assembled and with some circuitry to "steal" power from whichever I/O lines are idle. You'll have +5V available for your various sensors, you could look for a "breakout board" with just the MAX232 and DB-9 socket if you wanted to save money. This should work ok for sensors that report their results via an asynchronous serial line or accept commands the same way. One of the problems you will have is that many of the Parallax sensors (and sensors from others) don't use asynchronous serial I/O or they share a single I/O line for both or, like the PING))), use some other way to communicate that involves precise timing. The PING))) uses the timing of a pulse from the sensor to tell distance, but it also needs to receive a pulse on the same line to start the measurement. This can all be done in "dumb" hardware in such a way that the PC can do the timing, but you'll need to design and build the small amount of hardware needed. If you use Parallax's GPS receiver, you'll have a similar issue unless you use "raw" mode which only sends out serial data. There will be other sensors that will also require custom logic circuitry to interface with a serial line if you don't use a microcontroller. There's also the issue of how you'll multiplex the data for a variety of sensors to the PC and the data for a variety of actuators from the PC. If you have lots of different serial lines from the PC to the robot, you can accomodate all this communication without a microcontroller at the robot, but I don't recommend that.
  • OtterOtter Posts: 12
    edited 2009-02-01 22:42
    Crew,

    Okay... yeah... the using a microcontroller isn't sounding bad.· If nothing else, I would have to do a lot of multiplexing on the serial ports to get·enough TTL I/O lines.

    One thing that seems so magical about the Stamp is that·the I/O pins seem to be so multifunctional in a way that·makes·no sense to me.··In addition to normal asynchronous·digital I/O, it appars that they do magical A/D conversion,·as in·the light meter·example in the BOE documentation:
    http://www.parallax.com/Portals/0/Downloads/docs/prod/boards/BOE-RevC-v1.3.pdf

    But if it is indeed magical, why did Steve Norris·(http://norrislabs.com/) use a 16F684 microcontroller (http://ww1.microchip.com/downloads/en/DeviceDoc/41202F-print.pdf) to do the A/D conversion for his two GP2D12 optical·proximity detectors (http://document.sharpsma.com/files/GP2D12-DATA-SHEET.PDF) on his RoboStool project?· Isn't that overkill?

    Not only that, the way that the·Ping))) sensor functions makes·no sense to me.· I mean,·I don't get how these two commands (as in the datasheet) can·capture the time of a zillionth of a second pulse into the 'time' variable:

    PULSOUT 15, 5
    PULSIN 15, 1, time

    Oh well...·I can·gamble on it·since I need to·save up enough money for a BOE... it just makes me feel uncomfortable.

    Any comforting comments, suggestions or advice are appreciated.· I'm sure I'll come up with more questions as time goes on here [noparse]:)[/noparse]






    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-01 23:54
    As with most of this sort of thing ... "READ THE MANUAL!" Parallax is actually quite good with their manuals and tutorials. The Stamp Basic Syntax and Reference Manual has a chapter on each of the statements and does a good job of explaining statements like PULSOUT and PULSIN.

    The Stamp I/O pins, like most microcontroller I/O pins, are very much multifunctional. They can be used for asynchronous serial I/O. They can be used for timing pulses (like from the PING). They can be used for producing pulses of a particular width. They can be used to produce analog voltages (with a couple of passive components attached to filter the output). They can even be set up (with a few passive external components) to measure analog voltages. A Stamp is a poor analog to digital converter ... it's not really designed for this ... it's slow and doesn't have great accuracy. On the other hand, if you want to measure battery voltage, it's a cheap and effective technique.

    The PING))) sensor uses a brief pulse on the I/O line to initiate a measurement cycle. Some time later, the PING))) outputs a pulse whose width corresponds to the distance from the PING))) to the nearest object in the path of the beam. You measure the width of the pulse (with a PULSIN statement) and you can compute the distance (since the pulse width is a function of time to first echo).
  • OtterOtter Posts: 12
    edited 2009-02-02 17:43
    Mike,

    Ahh... you are de-mystifying a lot of this for me.· I am more confident now.· You also mention a few things that are still questions for me, like better A/D solutions and power supply issues.· Of course, those questions are not exactly on topic for this thread.· In the meantime, like you said, I have some homework to do.

    However, I don't want anybody to simply drop this thread.· It appears that RS232/TTL issues are still going to be with me.· For example, I think I'm going to want to multiplex a serial port for this project anyway, and I saw a product like this here:· http://www.usbserial.com/USBG-4X232.html
    Allegedly it should be fine with Linux·and plain old signal propegation.· Though I don't anticipate any problems using it with some sensors or BS2 interface, someone around here may have encountered some issues.

    Keep the ideas rolling in guys!

    Thanks again,

    -T

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • kwinnkwinn Posts: 8,697
    edited 2009-02-08 16:39
    Otter, I have taken a second look at your post and the two sites (http://www.bb-elec.com/bb-elec/literature/232LPTTL-3406ds.pdf and http://www.usbserial.com/USBG-4X232.html) you mention above. The first device is an RS232 to CMOS/TTL level converter, meaning it converts the +-12V levels of RS232 to the 0-+5V levels of CMOS/TTL and vice-versa. The second one is a USB to 4 port serial interface that will give you 4 serial ports on your Tablet PC once the drivers for it are loaded. Each of those ports would need level converters (similar to the first device) to shift the +-12V signals to 0-+5V CMOS/TTL levels.

    I agree with you that a Tablet PC is a far more powerful and capable controller for the robot than a microcontroller, but it does not have the I/O necessary to control the motors, servos, and read the sensors that are required. Nor is windows really a RTOS (Real Time Operating System). Yes, you can design an interface using CMOS/TTL logic chips that allows the RS232 or USB port of the Tablet PC to control the robot, but it would require many many chips and consume a lot of power.

    It is far better and simpler to have a microcontroller to run the motors and servos, read the sensors, and communicate with the Tablet PC over one RS232 line. Then the Tablet PC can be left to process the data and send commands to the microcontroller. This way each performs the function they were designed for.

    Think of the Tablet PC as your conscious mind and the microcontroller as the autonomous functions of your nervous system. You do not have to think about controlling your heart beat or balancing when you are standing, that is automatic. You decide when you want to get up and go somewhere and your nervous system controls your muscles to accomplish that.
  • GWJaxGWJax Posts: 267
    edited 2009-02-08 18:16
    I do have to say one thing about TTL's. When I was in high school, I went to our local Radio Shack "This is when it was really designed for the electronics hobbyist and not to the consumer of electronic gadgets now a days" and asked for a SN74S134 chip {12-input Positive-NAND Gates with 3-state outputs} for an electronic project I was doing at the time. The well diverse salesman told me that it was going to be 6 weeks before they come in. I asked him if they could put a rush on it because it was for a science fair project and I only had 2 weeks left. Well to make a long story short there was no way I could get one and then I asked him if I could just build one from scratch using transistors, caps, resistors ect. and he said NO it's not possible. Well I was not going to take that for my answer as being a teen I was always right and no one could tell me different, so I took out my data sheets and started to build the chip I needed which took me about one week to build at the time and once finished ran through all the data specs and it worked great so I finished my project and took it back up to the salesman to show him that it could be done and not to tell his customers that they can not do something because you don't have the chip for it.

    So what I am saying here is there is ALWAYS a solution to ANY problem no matter how big or small it is, anything can be done as long as you put your mind to it and today with the WEB there's all the information you need but you just have to find it and put it together.

    Jax

    ps. I won 1st place in both my local and State Science Fair in GA with a devise now called the clapper.. And yes I built it before they were selling them but I did not patent it due to the lack of my teachers and myself's thinking [noparse]:([/noparse] so I guess I cannot really call myself the inventor of it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If a robot has a screw then it must be romoved and hacked into..
  • OtterOtter Posts: 12
    edited 2009-02-12 19:56
    Mike, Kwinn,

    Yeah, I'm pretty much sold on using a microcontroller, now that you guys mention all the risks I'd be taking by trying to fudge microcontroller functionality out of a PC. And yes, it would be a better idea anyway to have another processor doing the dirty work of monitoring all the robot 'stuff' while the PC does the thinking.

    And Ugha, you also mentioned the same thing these guys were saying, although I think you were also thinking I was cautious about learning a new programming language. Naw... I can program anything. I was just thinking I could get rid of one variable (the microcontroller) but as it turns out, I'd actually be adding more by omitting it.

    Speaking of programming, these pbasic commands serin and serout are the 'dedicated' I/O commands to the serial port (usually) hooked to the PC right? I mean, these aren't detracting from the 16 TTL I/O lines are they? Is that 'debug' command just a synonymn for the serout command, then?

    Ah, and thanks for the vote of confidence on the makeshift NAND gate. That's pretty funny [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • kwinnkwinn Posts: 8,697
    edited 2009-02-13 04:52
    On most micro's the serial connection is a separate pair of pins from the digital (TTL) I/O lines. You would only use the I/O lines if you needed hand shaking as well (rts/cts, dtr/dsr). Just read the specs very carefully to be sure.
  • UghaUgha Posts: 543
    edited 2009-02-13 12:08
    I'll breakdown the whole SERIN/SEROUT pins thing for you...

    The programming connector on a BOE/BS2 is connected through a level shifter that translates the +12/-12 to TTL levels (+5v/0v) internally.

    You can address this communication port and thus speak directly to the computer to the programming port by using pin 16 on either SERIN or SEROUT.

    If you want to communicate with anything except a computer, pins 0-15 on a BS2 can be used for TTL level serial communication as well.

    Think of DEBUG as a wrapper function that does the SEROUT communication on pin 16 and formatting for you. DEBUGIN is its counterpart.

    DEBUG and DEBUGIN allow you to interact with the stamp from the BS2 editor, but to get anything like a GUI or custom interface, your going to have to write a
    computer program yourself or find one for download that does what you want already.

    I hope this clears some of this up for you.
  • OtterOtter Posts: 12
    edited 2009-03-15 21:09
    Kwinn, Ugha,

    As always, the support here is great. With this assistance, it appears I can seamlessly communicate with the BS2 over a serial interface programatically.

    Anyway, this does not mean I'm done with the questions... I just should post the next question under a new thread since it will be a new topic.

    Just give me a few days so I can formulate that question right.

    Cheers,

    -Todd

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.