2
\$\begingroup\$

I want to use two LEDs to show send and receive on my max232 RS232 to TTL (5v) converter. I have seen this method as the most conventional way to power an LED for max232:

enter image description here

I tested it and the LED light was very dim and decreasing the resistor value resulted in voltage drop at TTL level.

What is a more intelligent way to do this? Can I use two N-channel MOSFET and connect the gates to RX and TX and use a separate 5v between the Source and Drain? What are the pros and cons of this approach?

I have too many IRF3205 and I can use them. I think they will serve the purpose unless you think the specs are not good.

If it is good what resistor value seems reasonable between Rx/Tx and the gate of the MOSFET?

And one last question. Do you think a pulse stretcher is going to be necessary with this approach? or at least recommended? I am not familiar with them. If it is necessary or recommended I'd be thankful if you could show me a simple way to implement it. I am a tyro at best in electronics so I need a very simple solution... (like LM780x for voltage regulation / max232 for level conversion without too many details and components)

Thank you very much in advance.

\$\endgroup\$
  • 1
    \$\begingroup\$ The converter really is the wrong place to do this. Why can't you do this at the UART? \$\endgroup\$ – Ignacio Vazquez-Abrams Feb 1 '16 at 11:44
  • \$\begingroup\$ You mean the pin 7 and 13? They are connected to a 4000$ device with max 80ma current draw and I don't want to mess with that. \$\endgroup\$ – arudino.tyro Feb 1 '16 at 11:51
  • 1
    \$\begingroup\$ No, on the other side of JP1. \$\endgroup\$ – Ignacio Vazquez-Abrams Feb 1 '16 at 11:52
  • \$\begingroup\$ Oh, Sorry! I just posted this picture as a quick reference for LED location! In my application, pin 10 and 12 are directly connected to an Arduino! \$\endgroup\$ – arudino.tyro Feb 1 '16 at 11:55
  • \$\begingroup\$ @arudino.tyro post the correct circuit to avoid wasting any more people's time. \$\endgroup\$ – Andy aka Feb 1 '16 at 12:00
4
\$\begingroup\$

For transmit/receive indication, you want the LED to light when the line is NOT at idle. This means you need the LEDs to be lit when the line is low, since this indicator will be connected to the digital logic side of the converter, not the RS-232 side. The other issue is that the LEDs will likely take more current to light well than the UART signals can supply. You need some current amplification:

The resistor value shown assumes 5 V power and 20 mA thru the LED when on. The LED will be lit whenever the line goes low. Due to the gain of the transistor, most of the LED current will be sunk by ground, not the digital signal.

This is still not a great circuit. The LED will light for the start bit and any 0 bits. Maybe that's good enough for a quick and dirty indicator, but the average brightness will be data-dependent, and it will stop immediately when the line is no longer in the active state. It may be very difficult to see a single character being transmitted, especially when it contains mostly 1 bits.

A more user-friendly way to do this is to insert a retriggerable one-shot in front of the transistor. This guarantees the LED is lit for some minimum time after the first sign of activity. 20 ms is usually a good value for this. That's long enough to be a clear blip to a human observer, but still look like the indication goes away "instantly".

If you are going to do all this, you might as well add the logic to the micro instead of trying to recover the activity indication after the fact in external hardware. I've done this a few times where the UART interrupt would reset a counter to 20, then the regular clock tick interrupt decrements it every millisecond until it reaches 0. The LED is lit whenever the counter is non-zero. Depending on the micro and the LED and how bright you need it, you may be able to drive the LED directly from a micro pin with just a resistor in series.

\$\endgroup\$
  • \$\begingroup\$ On the RS232 side idle = low. \$\endgroup\$ – Andy aka Feb 1 '16 at 12:01
  • 1
    \$\begingroup\$ @Andy: Right. This is why I'm suggesting to wire it to the digital logic side. That's also how the OP shows the LEDs wired, although he has their polarity backwards. I clarified that I meant this LED to be wired to the digital logic side of the converter. \$\endgroup\$ – Olin Lathrop Feb 1 '16 at 12:05
  • \$\begingroup\$ @OlinLathrop, Thank you very much. I found this schematics from a random place on net. If only blinking is concerned, Can I replace the PNP amplifier (2n4403) with the N-channel MOSFET I mentioned? If not... why not? \$\endgroup\$ – arudino.tyro Feb 1 '16 at 12:12
  • 1
    \$\begingroup\$ @arud: No. A N-channel MOSFET is a very different device from a PNP transistor. \$\endgroup\$ – Olin Lathrop Feb 1 '16 at 12:15
  • 2
    \$\begingroup\$ "I'm on the side of a road with a flat tire. I have a bag of tomatoes in the car. How do I change the tire using the tomatoes?" \$\endgroup\$ – Olin Lathrop Feb 1 '16 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.