Shop OBEX P1 Docs P2 Docs Learn Events
Serial link via MAX3232 IC? — Parallax Forums

Serial link via MAX3232 IC?

parts-man73parts-man73 Posts: 830
edited 2006-04-17 13:37 in Propeller 1
A question about making a serial port programming adapter. Would it be possible to use a MAX3232 chip instead of the transister network called for in the diagram refered to many times in this forum? This chip is functionally the same as the MAX232, it converts serial port level signals to TTL level signals. The "3232" version of the IC can be run at 3.3 volts.

One other related questions. Is the serial data Rx/Tx (P30,P31) inverted or non-inverted?

Thank you,
Brian

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-04-15 04:02
    That chip should work fine.

    The logic levels are TRUE, not inverted like the signals on the DB9.

    You must make the low-pulse generator for positively-transitioning DTR. To do this, take the DTR signal from the·MAX chip·and couple it to the base of an NPN via a 10nf cap. Tie the NPN base via a 10k resistor to ground. Tie the NPN emitter directly to ground. The NPN collector must connect to the RESn pin on the Propeller chip. This way, when DTR goes from low to high, RESn will be pulsed low briefly to generate a reset.
    parts-man73 said...
    A question about making a serial port programming adapter. Would it be possible to use a MAX3232 chip instead of the transister network called for in the diagram refered to many times in this forum? This chip is functionally the same as the MAX232, it converts serial port level signals to TTL level signals. The "3232" version of the IC can be run at 3.3 volts.

    One other related questions. Is the serial data Rx/Tx (P30,P31) inverted or non-inverted?

    Thank you,
    Brian
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-15 06:52
    Chip,

    When you say "take the DTR signal from the MAX chip", I assume you mean the inverted signal from the level-translated side, right? Could it be inferred from your circuit description, then, that it doesn't matter which DTR edge triggers the reset? The reason I ask is that the transistor reset circuit you describe above is identical in function to the one shown here (http://forums.parallax.com/showthread.php?p=581926, lower schematic) without the intervening MAX3232 inverter (and which works well, in my experience). Your circuit triggers on DTR high-to-low (i.e. nDTR from the MAX chip going low-to-high), whereas the other circuit triggers directly from DTR going low-to-high. If the IDE sends a short pulse on DTR to effect the reset, both circuits should work equally well. But I just wanted to make absolutely sure, since I've got a board design that uses the circuit from the other thread.

    Thanks,
    Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 4/15/2006 7:17:07 AM GMT
  • cgraceycgracey Posts: 14,133
    edited 2006-04-15 08:46
    Phil,

    Yes, I meant the level-translated DTR signal, not the raw one. Taking the raw DTR signal through the same circuit may work, but it could be unreliable. The reason for this is that the host-side software times itself from the (level-translated) DTR rising edge before talking to the Propeller. The Propeller takes ~50ms to begin executing the boot routine after a reset, then there is an additional ~50ms-to-center sweet spot where it is possible to talk to the Propeller before it tries to boot from the EEPROM. The PC software 'SET's DTR for 25ms·before 'CLR'ing DTR, resulting in the reset. So, opposite-edge triggering (by using the raw DTR signal), will cause the timing to be 25ms late. This could result in failure, especially at temperature extremes where the chip's internal oscillator speed is affected. Also, if DTR was already in the 'CLR' state, no reset pulse would be generated, at all. It may be possible to reduce the 25ms 'SET' to 1ms. Then, it won't matter any more because the important edge will be very close to the ~100ms sweet spot. We'll have to add an extra DTR transition in there, too, to make sure it fires.
    Phil Pilgrim (PhiPi) said...
    Chip,

    When you say "take the DTR signal from the MAX chip", I assume you mean the inverted signal from the level-translated side, right? Could it be inferred from your circuit description, then, that it doesn't matter which DTR edge triggers the reset? The reason I ask is that the transistor reset circuit you describe above is identical in function to the one shown here (http://forums.parallax.com/showthread.php?p=581926, lower schematic) without the intervening MAX3232 inverter (and which works well, in my experience). Your circuit triggers on DTR high-to-low (i.e. nDTR from the MAX chip going low-to-high), whereas the other circuit triggers directly from DTR going low-to-high. If the IDE sends a short pulse on DTR to effect the reset, both circuits should work equally well. But I just wanted to make absolutely sure, since I've got a board design that uses the circuit from the other thread.

    Thanks,
    Phil

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


    Chip Gracey
    Parallax, Inc.

    Post Edited (Chip Gracey) : 4/15/2006 8:54:45 AM GMT
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-15 17:55
    The Stamp IDE has the nice checkbox to control DTR. I really like that and make use of it a lot.

    If the Propeller is connected to the Stamp IDE via the USB-clip, nothing happens when you check the box (DB9 DTR goes from low to high), but the Propeller resets when you uncheck the box (DB9 DTR goes high to low, and DTR\ seen by Propeller reset goes low to high.) Propeller is opposite of the Stamp in that respect, because on the Stamp, the capacitor is connected directly from DB9 DTR to the transistor circuit.

    I'm used to the following situation. Most terminal programs (e.g. Hyperterminal), bring DTR to a high level when they start. On the Stamp that causes a reset, and I use that as a signal for the Stamp to enter a Menu mode. I have the DTR line indirectly connected to another Stamp pin, which uses the high level there to sort out whether the reset came from the COM line or from another source (reset button).

    On the Propeller, throught the normal connection, a reset does not occur when you start up Hyperterminal, but a reset does occur when you disconnect. That negates the "Menu on connect" strategy. and it is disconcerting to have it reset when disconnecting. The Propeller of course has a lot more options for testing the state of the serial port, but those take extra protocol. So in my own systems I might opt for reset on the leading edge of DTR. If I understand you correctly, Chip, proper centering would be restored if a 25 millisecond delay is imposed after the rising edge of DB9-DTR?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-15 18:03
    Chip,

    In light of your comments, I wonder if the transistor-only reset circuit might better be designed as a follower. (See attached schematic.) One caveat, but I don't think it matters: The reset pin can be pulled slightly negative (as the attached scope trace shows) — limited, I believe, by the forward voltage of the transistor's base-collector junction.

    I guess any necessity for such a change depends on your commitment (or not) to the IDE download routine changes that you proposed above. On the other hand, I've noticed from my experiments that the DTR pulse width varies quite a bit. I'm guessing it's being bit-banged by the IDE, and I wonder if the software has enough control over the port to produce a pulse as narrow as 1mS reliably.

    Thanks,
    Phil

    Addendum: Now, having read Tracy's comments, I'm beginning to doubt that the follower circuit is the right way to go...

    Post Edited (Phil Pilgrim (PhiPi)) : 4/15/2006 6:25:27 PM GMT
    381 x 258 - 2K
    640 x 480 - 10K
  • cgraceycgracey Posts: 14,133
    edited 2006-04-15 18:41
    That follower looks fine. I'm thinking a single cap from DTR to RESn might work, too.

    Yes, it's hard to control timing on the order of milliseconds on the PC. Even though our software tries to generate an accurate pulse, it gets pre-empted and who-knows-what-else by Windows. On the latest Propeller.exe, Jeff switched over to the 'high performance timers' in Windows, instead of the regular (perhaps 'tick' based timer). This will be released soon. I'll try to get Jeff to comment on the observed performance.
    Phil Pilgrim (PhiPi) said...
    Chip,

    In light of your comments, I wonder if the transistor-only reset circuit might better be designed as a follower. (See attached schematic.) One caveat, but I don't think it matters: The reset pin can be pulled slightly negative (as the attached scope trace shows) — limited, I believe, by the forward voltage of the transistor's base-collector junction.

    I guess any necessity for such a change depends on your commitment (or not) to the IDE download routine changes that you proposed above. On the other hand, I've noticed from my experiments that the DTR pulse width varies quite a bit. I'm guessing it's being bit-banged by the IDE, and I wonder if the software has enough control over the port to produce a pulse as narrow as 1mS reliably.

    Thanks,
    Phil

    Addendum: Now, having read Tracy's comments, I'm beginning to doubt that the follower circuit is the right way to go...
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • cgraceycgracey Posts: 14,133
    edited 2006-04-15 18:44
    I think I understand, but I'm not sure. If, in the current software, the opposite DTR edge gets used to create reset, the software should reduce its delay by 25ms to compensate for the 25ms wait before reset firing.
    Tracy Allen said...


    If I understand you correctly, Chip, proper centering would be restored if a 25 millisecond delay is imposed after the rising edge of DB9-DTR?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-15 19:54
    Chip,

    Is the reset pin pulled up with a resistive element or a constant-current source? What are the parameters (in ohms or microamps)?

    Thanks,
    Phil
  • cgraceycgracey Posts: 14,133
    edited 2006-04-15 22:25
    Within the Propeller chip, there is a 5k-ohm resistor which is driven low/high when BOEn is low (enabled). So, it will source VDD (3.3V) through 5k-ohms, or sink through the same.
    Phil Pilgrim (PhiPi) said...
    Chip,

    Is the reset pin pulled up with a resistive element or a constant-current source? What are the parameters (in ohms or microamps)?

    Thanks,
    Phil
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-15 22:38
    (Phil, page 11 of preliminary doc says RESn pullup is ~5 kohms to Vdd, when BOE is tied low.)

    The way the FT232RQ is set up, it produces that ~25 millisecond long 1->0->1 pulse. On the trailing, 0->1 edge it couples into the transistor base via 10nf/10k, which generates a 1-0-1 reset pulse approximately 100 microseconds long at the collector of the transistor, which is pulled up by the 5k pullup inside the propeller chip.

    Now, suppose for some reason I want to reset on the leading edge instead of the trailing edge. For exampie, I want Propeller to reset when it is "connect now" in a terminal program like HTPE. I have to construct a modified clip that generates the inverted pulse, or couple directly to the transistor circuit from DB9-DTR (like the Stamp). However, like you have warned, if I then try to use my modified clip to program the propeller, the pulse from the IDE will be 25 milliseconds too early. So, I could compensate in my special clip, most easily, by stretching out the pulse in the inverter transistor, so that instead of being 100 microseconds long, it is roughly 25 milliseconds long. That would roughly compensate for time lag. Not exactly, because as has been noted, the 25 milliseconds is nowhere near exact, and an RC delay in the transistor would be nowhere near exact either. But is sounds like the Propeller has a +/- 50 milliscond window to hit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-16 01:55
    I think I'll try Chip's idea and directly couple the DTR line to nRST through a small cap and see what happens. That's why I asked about the nRST internals. (Didn't know it was in the docs, though. 'Sorry about the redundancy.) If that works, I've got an out with the PropSTICK and can give people the option of either using the common-emitter NPN inverter, or putting a jumper between base and collector pads, omitting the base-to-ground resistor, and using a low-valued series base resistor. I've got to figure out a cap that won't put too much stress on the nRST pin when DTR makes a 20V excursion from -10 to +10 or vice-versa. The Stamp boards use a capacitive divider in the DTR circuit, which may not be such a bad idea here, either.

    Another option is simply to DC-couple the common-emitter inverter. That way the Propeller will be in reset the entire width of the DTR pulse. The only thing that matters, timing-wise, is when it comes out of reset, and with DC-coupling, that will happen at the right moment. Of course, that'll be a problem for those terminal programs that insist on keeping DTR high. But those are going to be trouble for the transistor level-shifting circuit anyway, since the bias resistor from DTR to TxOUT will also be pulled high, making low excursions on TxOUT impossible.

    I'm a little perplexed over why, with the free availability of the excellent PBASIC Debug screen, anyone would use HyperTerminal anyway. It's got to be the worst piece-of-Smile, user-unfriendly terminal program ever conceived!

    -Phil
  • cgraceycgracey Posts: 14,133
    edited 2006-04-16 02:45
    We're going to add some simple terminal capability into the Propeller Tool before too long.
    One thing we've been thinking about since the early SX days was to add GRAPHICAL debug windows. For the Propeller, we could make data-driven oscilloscopes, XY scopes, raster imagers, and all kinds of stuff. The Propeller Clip (or the FTDI chip, I should say) can handle 3MBPS serial. This is nice throughput for camera-type data, audio, etc.
    Phil Pilgrim (PhiPi) said...
    I'm a little perplexed over why, with the free availability of the excellent PBASIC Debug screen, anyone would use HyperTerminal anyway. It's got to be the worst piece-of-Smile, user-unfriendly terminal program ever conceived!

    -Phil
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-16 02:54
    Chip Gracey said...
    We're going to add some simple terminal capability into the Propeller Tool before too long.

    Chip, that makes my day! I was hoping you guys would do something like that, and the graphical stuff would be the icing on the cake. As much as I like the PBASIC Debug screen, having that capability integrated into the IDE makes it even sweeter. Thanks!

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-16 03:30
    I just tried shorting the DTR series cap, thus DC-coupling the DTR->nRST connection through the common emitter inverter. Of course, it worked fine, with no problems in the PBASIC Debug window, either. I can't see a downside to doing it this way, especially with a Propeller-friendly comms window being integrated into the IDE. And I see nothing wrong with requiring DTR to be low for normal operation. Am I missing anything important?

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-16 04:16
    Phil -

    If I understand your query as to why some folks would want to use the Windows Hyterterminal program, it's often done for (optional) data capture directly to a PC data file, and not necessarily for direct display.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-16 04:53
    I wouldn't go so far as to say HTPE is, "the worst piece-of-Smile, user-unfriendly terminal program ever conceived!". (I've seen worse!) I'll say two things in its favor.

    1) It can capture capture text into a file, which is something the Stamp IDE can't at present do. Graphical Debug windows would be great too!

    2) HTPE is resident without asking on practically every PC out there, back into the stone ages. It is KISS. Not everyone who hooks up to Propeller is going to be using an IDE. I'm thinking about my customers, or my customers' customers or field techs. I know the Propeller can support its own video display and keyboard, but for many applications the easiest way to configure it in an application setting will be with a PC through the pin a30/a31 serial/USB port. There are a lot of other terminal programs out there, and AFAIK they bring DTR high automatically when they connect. Sure, you could write a custom VB terminal program or application specific program, but it is always good to have good ol' HTPE avaialble in a pinch.

    If I understand your DC coupled scheme correctly, Phil, when you connect that to HTPE or any other standard comms program, it will hold Propeller in reset so long as it is connected. Yikes.

    It is not a big deal to do it with the reset at the trailing edge of the DTR pulse. The Propeller, unlike the Stamp, can continuously monitor the TX line for incoming activity, and wake up on that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 4/16/2006 5:03:23 AM GMT
  • cgraceycgracey Posts: 14,133
    edited 2006-04-16 05:52
    I empathize with Phil. I think the only redemptive thing that can be said about HyperTerminal is that it's resident on every PC. Sometimes when I go back to use it after a long recess, I swear it wasn't THIS screwed up·last time (and I imagine Microsoft must have quietly rev'd it in order to make simple things yet more painful), but then I stumble back through all the loopy setup conjigulations and finally get it going again. I think it's actually some kind of conditioning tool for the New World Order.
    Tracy Allen said...
    I wouldn't go so far as to say HTPE is, "the worst piece-of-Smile, user-unfriendly terminal program ever conceived!". (I've seen worse!)
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.

    Post Edited (Chip Gracey) : 4/16/2006 6:06:45 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-16 06:19
    Tracy, "yikes" is exactly what I'm thinking, too.

    Here's my dilemma: In order for the Propeller just to be able to transmit using the transistorized RS232 converter, DTR has to be low anyway, to pull /TxD negative when it's not being driven high. (This bias connection is made to /RxD on the Stamp boards, which works fine, since the Stamp can't do full duplex.) On the one hand, it might appear that the transistorized RS232 interface being flogged in that other thread needs to be reconsidered in its entirety. On the other hand, I see a simple, elegant hardware design being mooted by the ubiquity of ill-conceived legacy terminal programs that provide no (and I've checked this) negative handhake signals or any means to control them.

    I could bias /TxD to ground instead of a negative voltage, and it would probably work with 90% of the PCs out there. (Mine even works with 0-to-3.3V signals.) But there's no guarantee that it would work on all of them.

    The other option is to add a diode and storage cap to /RxD, to maintain a negative bias on /TxD when /RxD makes positive excursions. But this only works effectively with ICs like the DS276 that don't draw on the cap when /TxD is high. I would like to have used the DS276. I've used it in the past and have had great success with it. But ever since Maxim bought Dallas Semiconductor, I haven't been comfortable with the availability (or lack thereof) of Dallas's parts. That leaves the multiple-sourced MAX232 family, which seems like overkill for this app, but may provide the only relief.

    So that's where things stand right now. I'm not terribly happy about it, but I guess I'll find a way to deal with it.

    -Phil

    P.S. Really? You've seen worse than HyperTerminal??
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-16 06:35
    Chip,

    I don't think Microsoft ever really "got" RS232. From the DOS days forward, I've had to rely on third-party programs for reliable comms. These have included the BitCom and QModem terminal programs, and the MID interrupt-driven serial driver. I still have issues with their Windows serial drivers. What makes the situation particularly galling and hard to fathom is that it's not that hard to get it right! But it's like serial I/O was never a front-burner item with them — just something they tossed in at the last minute to say they had it.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-16 07:21
    Gents -

    As easy as it might be to expect that Microsoft is the party responsible for Hyperterminal and all its horrors, another party is clearly responsible. If you check the program file properties, then look at the version, here is what you will find:

    "HyperTerminal ® was developed by Hilgraeve, Inc. for Microsoft"

    So, they are the guilty party!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Tracy AllenTracy Allen Posts: 6,656
    edited 2006-04-17 03:19
    Phil, I see the dilemma, to find a convenient negative voltage.

    Before Parallax started adding the capacitors to the Stamp development boards and schematics, it was a perennial source of puzzlement: "Why is my Stamp dead, when I connect it to Hyperterminal". I'd hate to see the same issue arise again with Propeller. The issue will arise if the capacitor is left off, so I say, please keep it in there, even if it has to trigger on the trailing edge of DB9-DTR.

    If you want to find crumb-bum serial programs, look at the current crop available for the Mac! GoSerial for exampe. zTerm is better, but still not good for control of scientific equipment. There is very little flexibilty or support for the hardware handshaking lines. On the PC, I used to use Procomm. But I've gotten adept and even fond of using Hyperterminal, despite its lack of Macro capability. The most galling thing is that it loses data if a laptop goes to sleep or Windows preempts for whatever. Once you have a setup file, it is easy to send that to other people as a starting point. (So who is going to write a Xmodem object for Propeller?!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-17 04:43
    Hi Tracy,

    I bit the bullet and put a MAX3232 on the board. That took care of the negative voltage issue. 'Went back to capacitive coupling using Chip's circuit, so the reset now occurs on the trailing edge of the DTR pulse. (But users can leave out the transistor inverter and one resistor, change the value of another resistor, and jumper the transistor's base and collector pads to get the reset on the leading edge.) 'Had to extend the board a quarter inch, bend the TO220 leads closer to the quick, and fold a couple resistors transistor-radio-style, but everything fits. It's been awhile since I've laid out a through-hole board. I'd forgotten how big that stuff is!

    -Phil
  • FORDFORD Posts: 221
    edited 2006-04-17 10:30
    Tracy / Phil,
    I don't know if this helps in any way, but when I purchased vb6 pro, it comes with a sample terminal program written in vb6, which is (to me) much nicer than hyperterminal, but I'm not sure (off the top of my head) if it has the features you are speaking of.
    I use it for setting up modems etc, and its a breeze compared to hyperterminal.
    If you dont have it, I'd be happy to compile it and email it to you, or send the vb6 code so that you can then massage it a bit.

    You could then perhaps modify it and add DTR controls as you wish. If that worked out, it could perhaps be made available as a basic program specially suited for comms with a prop.

    Cheers, Chris.
  • parts-man73parts-man73 Posts: 830
    edited 2006-04-17 13:37
    wow, I started this thread, and now I'm confused. I started to think maybe the MAX3232 was a bad idea, Because you still needed one of the transistors for the DTR line, plus the MAX chip and it's associated capacitors. My original goal of circuit simplifacation wasn't realized, I was just going to use the 3 transistor design for my board. Is this a valid interface? or is the MAX3232 the best way to go now?

    Happy tinkering,
    Brian
Sign In or Register to comment.