A Journey Into Unexpected Serial Ports

Through all the generations of computing devices from the era of the teleprinter to the present day, there’s one interface that’s remained universal. Even though its usefulness as an everyday port has decreased in the face of much faster competition, it’s fair to say that everything has a serial port on board somewhere. Even with that ubiquity though, there’s still some scope for variation.

Older ports and those that are still exposed via a D socket are in most case the so-called RS-232, a higher voltage port, while your microcontroller debug port will be so-called TTL (transistor-transistor logic), operating at logic level. That’s not quite always the case though, as [Terin Stock] found out with an older Garmin GPS unit.

Pleasingly for a three decade old device, given a fresh set of batteries it worked. The time was wrong, but after some fiddling and a Windows 98 machine spun up it applied a Garmin update from 1999 that fixed it. When hooked up to a Flipper Zero though, and after a mild panic about voltage levels, the serial port appeared to deliver garbage. There followed some investigation, with an interesting conclusion that TTL serial is usually the inverse of RS-232 serial, The Garmin had the RS-232 polarity with TTL levels, allowing it to work with many PC serial ports. A quick application of an inverter fixed the problem, and now Garmin and Flipper talk happily.

17 thoughts on “A Journey Into Unexpected Serial Ports

    1. The MAX232 is a classic, but it has a “flaw”. A single MAX232 can convert merely two (?) signals same time.

      For a simple 3-wire connection with RxD and TxD and ground that’s enough, but all the status/handshake lines are left out.

      A simple hack used to to be to an diode and a 7805 linear voltage regulator to convert +12v level down to +5v level.
      -12v was blocked, so it looked like 0v (no signal).

      The other direction was left as is. The RS232 would understand +5v same way as +12v. The treshold was about 3v.
      Around 3v, the RS232 would be uncertain if the logic level was high or low.

      That’s why 3.3v is such a borderline scenario. It may work fine, depending on the lenght of wires.
      If beinh too long, the voltage would drop down to 3v or less.

      By the way, it’s also possible to use transistors or optocouplers to interface RS232 and TTL.
      They can be used as pull-downs on the other side, for example.

      1. “A simple hack used to to be to an diode and a 7805 linear voltage regulator to convert +12v level down to +5v level.”
        This isn’t a simple hack, this is an awful kludge for various reasons. The proper way to do this is to shunt the line with a zener or clamp it to the supply rails of the receiving end with two signal diodes – RS232 outputs are current limited, there’s a 300Ω series resistor for that purpose. (see Motorola’s MC1488 and MC1489 datasheets for details. More modern chips have similar arrangements.)

        “The treshold was about 3v.”
        It’s more like 2V. Works perfectly with 3.3V CMOS outputs, if they can drive a 2kΩ load.

          1. Zeners and clamping diodes aren’t “tricks”, but standard ways to do level conversion. Also galvanic isolation isn’t a cure-’em-all method, especially if isolation isn’t required in the first place. Garden variety optocouplers are slow with rise/fall times measured in tens of µs, better ones are quite pricey. Transformers are out, they do not work with the NRZ signalling used with RS-232. No designer right in his mind would use unnecessarily complex and expensive stuff for a mass product if two 1N4148 can do the job.

          2. “No designer right in his mind would use unnecessarily complex and expensive stuff for a mass product if two 1N4148 can do the job.”

            Um, they would, maybe ? 🤷 In industrial applications, I think, optocouplers are not seldomly being used.
            (Not sure if that qualifies as “mass production”, though, I must admit.)

            That’s when money is secondary and safety/reliability first.
            It’s also because of power differences. Big machinery has potential differences or uses stronger currents/voltages.
            Relays cards are not seldomly being optocoupled, as well. That’s when galvanic insulation happens multiple times.

            Optocouplers.. These days irdinary noname optocouplers can reach about ~30 Kilobaud, at least, which is speed of MIDI port.
            – That’s beyond what GPS mice and Packet-Radio TNCs used to use; 4800 Baud and 300 to 9600 Baud.
            But they have to be used in “photodiode mode”, maybe.
            As a full-blown phototransistor they might be reacting too slow, that’s right.

            For full RS-232 speed of 115200 Baud (classic limit), quicker optocouplers are required, I do agree. They’re not rare by any means, though.
            Just a bit more expensive than the very cheap models we hobbyists are used to.

            Truely ‘expensive’ optocouplers can handle a few Megabaud (MBit/s, since it’s raw symbol rate and no compression is used).
            The 6N137, for example, can do 10 Mbit/s and costs ~50 cents, I think. A single 1N4148 costs a fifth of this (10 cents).

            But does it really matter if the final circuit costs a single €/$ more ?
            Does the customer care if he has to be charged $200 or 201$ at the end ? I don’t.

            I think the customers expects to overpay, anyway.
            I mean, since when did production cost ever correlate to the final price ?

            Also, at least here in Germany, to my knowledge, the average hobbyist circuits would rather use a pair of BC548 transistors as a driver stage rather than just diodes.
            Sometimes with an extra resistor or a diode at the base of the transistor. Among other things, they are there to protect the source in case the transistor goes ‘poof’ !

            By using such a transistor driver stage, as a side effect, the RS232 port could drive bigger loads on the other side.
            It doesn’t have to be another TTY device/intelligent serial device, for example, but could also be a dumb DC lamp or a motor.

            Alternatively to this, a few decades ago, hobbyists used electro-mechanical relays with an anti-parallel diode.
            Classic relays worked for slow applications only, of course.
            Like building an PC-operared telephone dialer for COM port, for example.
            I once saw such a circuit in a PC magazine from circa 1986 to 1988, it used an miniature relay in DIP form factor.
            Pulse dialing doesn’t need high speeds, so it seemed reasonable to do.

            Speaking of relays.. Recently, there were new types of relays being made or so I heard. They are working like optocouplers, but using a magnetic field instead of light waves.
            They’re working like miniature transformers, essentially. Except that they can be used for DC, too?

            Speaking under correction here.

  1. “a 10-bit week counter that is incremented once a week, and a 19-bit time of week signal incremented every 1.5 seconds. This week counter rolls over every 1024 weeks (or approximately 19.6 years)”

    I dis not know this. I find 10 bits an odd design choice in the protocol. Later expanded to 13 bits, which may lead to bewilderment in 150 years.

    Regarding the altitude, I think GPS has always been less accurate, could it be that old receivers had less accurate altitude calculation or compensation algorithms?

    1. That’s my assumption as well: newer devices have had 3 decades of improvements to interpreting the altitude and they have more space to store world tuning data. Being a unit loaded with airport data for the US, if it has any data for tuning the altitude, it would be pretty useless here in the Netherlands.

    2. GPS do not give altitude data above the surface of the Earth, but above the “geoid,” a theoretical oblate spheroid which is calculated to follow the actual Earth’s bulging-sphere shape as closely as possible. But the local altitude can be quite different from the geoid, and for detailed navigation databases are used to map the difference. Older devices had a limited memory for such data, and a limited need since they were simply less accurate when the GPS military operators were deliberately smudging the signal to make it less useful to potential enemies.

      1. Thanks Roger. Is it possible to reason that on an old gps device, a recorded trip with data for altitude distance travelled, would be relatively accurate, since the altitude differences are only relative during the trip?

      2. also the accuracy increases with the number of satellites being included in calculation—and the old units were limited to 3-4 satellites IIRC, while the new ones can handle dozens of satellites.

        1. I once did a hike in what was becoming a huge storm, and about every half hour I had to change my barometric wristwatch altimeter by 1mbar of asml pressure, or about 50m of altitude. I kept rising and I think the pressure I had at sea level in the morning was about 500m in the evening.

  2. Ahhh, the “Inverted” nature of the serial signal is probably also why my electricity meter’s P1 port needs it’s signal inverten to be read by an ESP32 (even though the meter is from 2021)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.