wiggy wrote: ↑Tue Apr 06, 2021 10:41 pm
Every time I see one of these "circuits" with an MCU's bare GPIO pins used as a differential "line driver" I have to go away and scream! (In the day job that would be a taken-outside-and-shot offence, so some of that is conditioning...)
To put this in perspective, you are shorting two opposing voltages together with 50 Ohms (two terminators in parallel). Those two voltages are your supply rails (say 0 and 3.3V) less the voltage drop through the resistance through some not-very-big FETs that are the output stage of the pin. Estimating the On-resistance of the pins is tricky, not least as Broadcom are so shy about sharing datasheets (anybody'd think they don't want you to buy their parts, but I digress). But at the max current it's probably dropping about 0.5V through the pin (if that's 16mA - probably about right, certainly in the typical range for a micro - then that gives a FET around 30 Ohms.)
So we have:
Code: Select all
3.3V----[30 Ohms]----o----[50 Ohms]----o----[30 Ohms]----0V
Ohm's law says you should be passing 30mA. Which means you are dissipating about 30mW in each pin (a 60mW hotspot if you picked adjacent pins!). That doesn't sound a lot until you realise just how small those FETs are (you don't put whoppers on a micro: they'd eat too much die space)... and the CPU on a Pi is in a BGA, so you haven't even got a leadframe (i.e. the legs) to use as a mini-heatsink. (the ATmega/ATtiny versions score slightly better here...)
So the odds are you'll be running the poor thing close to it's death zone. And that's if all goes
well. (Oh, and there are also things like "ground bounce" - passing lots of current through a chip's ground pin raises the on-chip ground rail a bit above true ground, reducing your noise immunity and/or introducing unexpected signals.... don't forget the Pi's CPU core logic is probably only running on a 1.0-1.5V supply!)
Now consider the following:
- If the line accidentally gets shorted, you have no protection: your whole supply voltage is being shorted through the pins. Game over.
- If something else drives the line when the Pi isn't powered, then it'll do it's best to power the Pi through the protection diodes on the power pins. That won't end well either.
- If you have a longish length of cable and don't get the terminators right, the reflections can easily reach double (and/or minus) the voltage you put in. Ouch.
- If something else (e.g. static) gets into the cable...
- If something plugged into the cable elsewhere has a different ground voltage, by more than 3.3V (surprisingly easy to achieve) then it will end very badly, as there is no scope for the common-mode voltage to get outside the supply rails (the protection diodes turn on again...)
- ... and so on. If it's bad, and you have "long"/"external" (as in outside-the-equipment-box) cabling then it will happen. Sooner or later.
Now, the thing is that the line driver chips are not only designed and specified to drive continuously into the 50 Ohm terminated line (a quick check of the old 75159 datasheet shows a typical operating current of 40mA... probably more than most micros' Absolute Maximum. The 26LS3x are similar, some of the modern ones are nearly double) but also to deal with all of the above fault conditions (the 422/485 standards specify most of these). Some vastly exceed it (Maxim, TI, and Analog Devices - to mention a few - have an extensive portfolio of 422/485 drivers which includes ICs with 15kV static protection, 2+kV electrical isolation, high drive currents, full short circuit protection, and more... mostly from a 3.3V supply)
There's one big clue that all is not well here: to meet the 485 drive levels you only need to run your driver from 3.3V. There are plenty that do and none (well, apart from the internal isolation ones) have any sort of step-up supply (unlike the 232 drivers which do). So if you aren't managing to power the passive terminators then your drive voltages must be collapsing: the Pi's GPIO pin FETs are not coping.
So do yourselves, and your kit a favour and stick a driver (or transceiver) in and then you can relax. There are hundreds to chose from - you can trade off price vs paranoia as you wish. There really isn't any excuse not to do it properly!
Oh, and if you want to risk the death of your own kit, so be it, but making such for sale/build by the unwary is not really acceptable.
PS: just seen sweh's: The "40mA" spec for the ATmegs328 on the Arduino Nano is the "Absolute Maximum" (as the adjacent note says "beyond [this] may cause permanent damage to the device" i.e. this is the red line: there is no margin left for error ). Down the page a bit, they're only rated to
operate at 20mA at 5V/10mA at 3.3V. And that's a nice 'scope trace of the pin voltages exceeding the Abs Max limit of 0.5V beyond the rails, too ... You're on borrowed time.