+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Advanced Member level 5
    Points: 16,588, Level: 31
    Achievements:
    7 years registered
    neazoi's Avatar
    Join Date
    Jan 2008
    Location
    Greece
    Posts
    3,357
    Helped
    13 / 13
    Points
    16,588
    Level
    31

    Convert RS232 to UART and vice versa (discrete)

    I have this circuit http://qrp.gr/cb2/hardware/schematic_simple.gif and I need to make it communicate with this http://qrp.gr/cb2/modem/modem3.gif
    But the modem IC uses UART 0/5v. I do not want to use the second UARD serial of the MCU so I am limited to the RS232.

    Is there a simple discrete way to make these two devices communicate?

    For data that is sent from the MCU to the modem, I believe a simple diode will suffice, to eliminate (making them zero) the negative pulses.
    But for data received from the modem to the MCU, zero needs to be converted to -V (or is it one?)
    So some kind of charge pump is needed.
    Professional engineering is the top, but amateur engineering is more fun.
    It is when you cross the barrier between these two, that things become really fascinating!

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 259,261, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,261
    Helped
    13769 / 13769
    Points
    259,261
    Level
    100

    Re: Convert RS232 to UART and vice versa (discrete)

    For data that is sent from the MCU to the modem, I believe a simple diode will suffice, to eliminate (making them zero) the negative pulses.
    But for data received from the modem to the MCU, zero needs to be converted to -V (or is it one?)
    No, RS232 signal is inverted with respect to UART logic level. UART logic has idle state high while RS232 has idle state low.



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 80,983, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,273
    Helped
    4433 / 4433
    Points
    80,983
    Level
    69

    Re: Convert RS232 to UART and vice versa (discrete)

    Technically FvM is correct (isn't he always!) but you might be able to bend the rules a little.

    For conversion of RS232 to TTL, add a resistor (~1K) in series with the data and on the receiver end of it connect a diode with anode end to ground. This will conduct when the RS232 signal is negative. Also connect it to the base of an NPN transistor, emitter to ground and collector pulled up 5V. It isn't true RS232 conversion but it will give voltage translation and inversion.

    For the TTL to RS232 you do the opposite and omit the diode. The signal goes to the base through a resistor, the emitter is grounded and the collector is pulled up to +12V. It may work because many RS232 receivers ignore the negative voltage anyway so producing a signal between 0V and +12V will often fool them into working.

    You could of course simply cross-link TX to RX at TTL levels and not use RS232 at all. That would also make the components around D4 redundant as no negative supply would be needed.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 5
    Points: 16,588, Level: 31
    Achievements:
    7 years registered
    neazoi's Avatar
    Join Date
    Jan 2008
    Location
    Greece
    Posts
    3,357
    Helped
    13 / 13
    Points
    16,588
    Level
    31

    Re: Convert RS232 to UART and vice versa (discrete)

    Quote Originally Posted by betwixt View Post
    Technically FvM is correct (isn't he always!) but you might be able to bend the rules a little.

    For conversion of RS232 to TTL, add a resistor (~1K) in series with the data and on the receiver end of it connect a diode with anode end to ground. This will conduct when the RS232 signal is negative. Also connect it to the base of an NPN transistor, emitter to ground and collector pulled up 5V. It isn't true RS232 conversion but it will give voltage translation and inversion.

    For the TTL to RS232 you do the opposite and omit the diode. The signal goes to the base through a resistor, the emitter is grounded and the collector is pulled up to +12V. It may work because many RS232 receivers ignore the negative voltage anyway so producing a signal between 0V and +12V will often fool them into working.

    You could of course simply cross-link TX to RX at TTL levels and not use RS232 at all. That would also make the components around D4 redundant as no negative supply would be needed.

    Brian.

    I will draw a small schematic just to make sure I have understood that correctly. In the mean time, I am thinking that the MCU outputs a TTL actually isn't it? So can I just bypass the negative charge pump?
    Professional engineering is the top, but amateur engineering is more fun.
    It is when you cross the barrier between these two, that things become really fascinating!



  5. #5
    Super Moderator
    Points: 80,983, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,273
    Helped
    4433 / 4433
    Points
    80,983
    Level
    69

    Re: Convert RS232 to UART and vice versa (discrete)

    In the mean time, I am thinking that the MCU outputs a TTL actually isn't it? So can I just bypass the negative charge pump?
    More accurately you can omit the charge pump, all it does is generate the negative voltage to more closely follow RS232 voltage levels.
    Bear in mind that in a standard RS232 link, the signal polarity is inverted twice (hence the two transistors), once to make RS232 from TTL and again to reverse it back again. The net effect is no inversion so you can directly connect the two devices with no interface between them. RS232 is normally used when longer distances are needed but the +12/-12 Voltages date back to the days when it was directly powering relays and teleprinter solenoids. For short distance TTL to TTL it isn't needed and a simple wired connection will work just as well.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.


    1 members found this post helpful.

  6. #6
    Advanced Member level 5
    Points: 16,588, Level: 31
    Achievements:
    7 years registered
    neazoi's Avatar
    Join Date
    Jan 2008
    Location
    Greece
    Posts
    3,357
    Helped
    13 / 13
    Points
    16,588
    Level
    31

    Re: Convert RS232 to UART and vice versa (discrete)

    Quote Originally Posted by betwixt View Post
    More accurately you can omit the charge pump, all it does is generate the negative voltage to more closely follow RS232 voltage levels.
    Bear in mind that in a standard RS232 link, the signal polarity is inverted twice (hence the two transistors), once to make RS232 from TTL and again to reverse it back again. The net effect is no inversion so you can directly connect the two devices with no interface between them. RS232 is normally used when longer distances are needed but the +12/-12 Voltages date back to the days when it was directly powering relays and teleprinter solenoids. For short distance TTL to TTL it isn't needed and a simple wired connection will work just as well.

    Brian.
    Well I finally took the signals directly from the chip pins http://qrp.gr/cb2/hardware/schematic_simple.gif and it worked!
    The author of the firmware has included an RS232/TTL setting in the firmware, which I do not know what it does but it enables TTL when set accordingly. If set to RS232 instead and the signals are taken directly from the chip pins instead of the DSUB9 connector then garbage is sent and received.

    So I think this works ok!
    Professional engineering is the top, but amateur engineering is more fun.
    It is when you cross the barrier between these two, that things become really fascinating!



    •   AltAdvertisement

        
       

  7. #7
    Super Moderator
    Points: 77,067, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,613
    Helped
    3557 / 3557
    Points
    77,067
    Level
    67

    Re: Convert RS232 to UART and vice versa (discrete)

    Hi,

    What's the behind the idea to build this with discrete parts?
    The usual converter ICs are simple, cheap and most of all they work reliably, even for high baud rates. They usually include ESD protection and create output voltage levels according RS232 standard. A lso the input voltage thresholds are according RS232.
    If you include all this in your circuit, then it may become complex.

    There are even completely assembled very small and cheap modules availabke at ebay and many other places in the internet.

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  8. #8
    Advanced Member level 5
    Points: 16,588, Level: 31
    Achievements:
    7 years registered
    neazoi's Avatar
    Join Date
    Jan 2008
    Location
    Greece
    Posts
    3,357
    Helped
    13 / 13
    Points
    16,588
    Level
    31

    Re: Convert RS232 to UART and vice versa (discrete)

    Quote Originally Posted by KlausST View Post
    Hi,

    What's the behind the idea to build this with discrete parts?
    The usual converter ICs are simple, cheap and most of all they work reliably, even for high baud rates. They usually include ESD protection and create output voltage levels according RS232 standard. A lso the input voltage thresholds are according RS232.
    If you include all this in your circuit, then it may become complex.

    There are even completely assembled very small and cheap modules availabke at ebay and many other places in the internet.

    Klaus
    There may be several reasons, and of different consideration for each hobbyist.
    Cost, availability and obsolescence may be some, but to my view availability is a main issue. You just may not happen to have this IC on junkbox when you want it, having to wait for several days to order it.
    I do not like when this happens.
    A few NPNs are more likely to be found in everyone's junkbox.

    But as said I was lucky to not need any of them finally.
    Professional engineering is the top, but amateur engineering is more fun.
    It is when you cross the barrier between these two, that things become really fascinating!



--[[ ]]--