SensorModbusMaster icon indicating copy to clipboard operation
SensorModbusMaster copied to clipboard

Document why some RS-485 adapters don't communicate when lights flicker

Open aufdenkampe opened this issue 3 years ago • 21 comments

This last fall I started seeing Modbus communication failures with a very inexpensive batch of RS-485 adapters that I purchased for the Modbus-Mafly-WingShield. What I observed was that the TXD and RXD lights on the RS-485 adapter would weakly and rapidly flicker on the adapters that didn't work. On the adapters that did work, the TXD light would blink strongly once, and the RXD light would soon follow with a strong blink.

At that time, I figured the issue was due to inferior quality of the very inexpensive adapters (which looked nearly identical, BTW), so I ordered the more expensive SMAKN SCM TTL to RS485 Adapter. Those worked and I had other deadlines, so I didn't think anything of it... until I purchased another batch from SMAKN a few weeks ago, and they all had the same faintly flickering light issue issue!

@neilh10, appears to have just had the same issue, which he posted to https://github.com/EnviroDIY/SensorModbusMaster/issues/5#issuecomment-678486323

The good news is that I just figured out the solution last week, so I'm creating this issue to remind me to fully document it. Below is from my response to @neilh10.

The SOLUTION: solder a 120 ohm resistor between the A+ and B- data lines as "termination" to prevent data signal reflections. A 100 or 150 ohm resistor also worked for me.

These are my info sources:

  • https://www.maximintegrated.com/en/design/technical-documents/tutorials/7/763.html
  • https://www.csimn.com/CSI_pages/RS-485-FAQ.html

Technically, the terminating 120 ohm resistor is supposed to be placed at the end of the sensor chain, but it worked for me to solder it right onto the RS485 adapter board.

aufdenkampe avatar Aug 21 '20 23:08 aufdenkampe

Here's a picture of my solution, with a 120 ohm resistor (1/4W) directly soldered to the A+ and B- terminals on the RS-485 adapter:

WingShield+TerminationResistor

aufdenkampe avatar Aug 21 '20 23:08 aufdenkampe

Gosh thanks for the response. Good to know the universe hasn't just picked on me.!!! Though sorry for your pain as well ~ but pain shared...... oh will I will give up on the poetry.

Early this morning, I thought I should try the 120ohms termination as it is RS458 specified ~ usually as strap option ~ so I did try it this morning, found a 1W 200ohms , and also looking at the loading of the differential signal on the scope, to see if the the signal is too small, but couldn't see anything specific and I didn't mention it as it hadn't made a difference to me, at least with the 30ft sensor line that I'm using. It was 200ohms which seems close enough, but maybe I should try the specified 120ohms. I'm just re-avauating my stock or RS485 hybrids , and trying to categorize by purchases. I did purchase on Feb2nd some cheap "2pcs TTL to RS485" @ $5.18 https://www.amazon.com/gp/product/B07YZTGHGG so I'm building a board with that. I'll also look for a 120ohm and try it with that....... and order the SMAKN.

neilh10 avatar Aug 21 '20 23:08 neilh10

Well the new very cheap worked for me this time "2pcs TTL to RS485" @ $5.18 https://www.amazon.com/gp/product/B07YZTGHGG So just building one wingboard. So document what I'm seeing - and seeing two different problems a) the RS485 instruments responds to a request, however it is not decoded, thrown away. b) the RS485 instrument doesn't respond, (also the sign of the wires not plugged in OR no power)

For a poll that works it is three polls, flashing 1.5 seconds the Tx and Rx leds almost simultaneous, and the software decodes it successfully For a poll that doesn't work - either a) or b) there is a stream of 30 flashes. For a) RS485 instrument responds, there are weak Tx and Rx flashses. For b) RS485 doesn't respond there is only Tx flashes.

The output of a poll that works, looks like this on the line ~ with a fast Tx and Rx flash at the same time image With -DMS_KELLERPARENT_DEBUG the debug output image

a closer up look at just one poll working and what is unusual is that there still is this breakthrough to the hybrids RXD line to the MAYFLY. So that was also previously on the failing one. image

When I add a 200ohm R - which is all I have , or even a 1000Ohm R, the Acculevel instrument doesn't respond ~ the differential lines are attenuated, but that is normal to some point. They are visible so assuming they are still within spec. A real pain that the Acculevel hasn't responded

image

In this case there are 3 sets of 10 flashes. Each flash is about 1.5Seconds apart - so a stream of flashes.

image

For the case of no instrument plugged in, the Rs485 RX line goes high and stays high image

So a note to myself, is that I need to build the RS485 wingboard, add a traceable serial number, test it, and note the results.

My guess for a) that it may be solvable in sw by looking at the way the decoding is working , but for b) the instrument has to respond to be able to do anything. For me, with some other experience on Chinese component manufacturing, is it is not very disciplined, and as in this case selling to amazon its selling a "lot" with out feedback. Or perhaps as its so cheap because it was returned or failed sale for some reason. Who knows. What a pain the termination R doesn't clean it up.

neilh10 avatar Aug 22 '20 01:08 neilh10

@neilh10, thanks for all that extra diagnostic info.

I think it might still be worth getting and trying 120 ohm resistors.

From what I've read, the key to avoiding electrical reflections in the data line is use a resistor that matches the impedance of the twisted pair wire that is used, and that 120 ohms is the standard cable impedance used for RS-485 applications. So, it makes sense that 1000 ohm resistor wouldn't work, and not too surprising that a 200 ohm resistor wouldn't work (although, as you know I'm not an electrical engineer, so I'm mostly just spitting back what I've read rather than truly understanding this stuff).

For the record, I did try a 100 ohm resistor at first because I also didn't have a 120 ohm resistor. The 100 ohm solved the problem, but I decided to get this EDGELEC 100pcs 120 ohm Resistor 1/4w (0.25 Watt) ±1% Tolerance Metal Film Fixed Resistor from Amazon anyways, and they worked well for 8 different RS-485 adapters from 3 different manufacturers.

All of my tests were with YosemiTech sensors, but with two different cable types (they clearly changed suppliers, and their older cables worked more consistenly without the termination than their newer cables).

aufdenkampe avatar Aug 23 '20 19:08 aufdenkampe

@aufdenkampe sorry for the detailed reports, its the raw data I'm seeing.
The different hybrids are acting differently with terminating R v no terminating R. Its clear they have been produced by different manufacturing processes if not manufacturers and chips.

As an EE I've characterized and fine tuned different types of transmission mediums, - terminating impedance's/R usually more of an issue at high speed. So the terminating R is really acting like a loading R at these low speeds.

As far as I can see it shouldn't really make a difference on an ideal RS485 cct. Obviously should specify a 120ohms for getting the best optimal/longest highest data rate. Practically for these short wires at 9600baud it really shouldn't make a difference from 100ohms, 120ohms, 200ohms.

Practically IHMO, Amazon is a not a good source for electronic components, as the manufactures sources are just not accountable. I have greater trust with digikey (or mouser ..) as a traceable source of components when possible.

I'm pleased I've got another RS485 hybrid working, which will allow me to build another system. And of course prove the greater software libs.

The breakthrough on the RX is probably because the Half-Duplex management is being done by analog R & C's components. Probably works at higher speeds. But how does it vary with temperature. Will it get worse at lower or higher temperatures and start to fail at reading the transducers. I do some temperature testing, but usually only at the end of the design and with my circuits.

There is an RS485 chip that manages the half-duplex digitally to a defined spec.

Building reliable systems is about a chain of traceable reliable components. In this case the RS485 hybrid is untraceable, ~~ the price is nice ~ until they don't work ~~ . There is only one solution to this type of observed unreliability.

neilh10 avatar Aug 24 '20 01:08 neilh10

Just checking on the MAX485ESA , that is on the latest hybrids I have, it is only specified for Vcc 5V ±5% ~ maybe the chip is some other unnamed copycat source. IHMO the Amazon wording 3.3-5V should be viewed as "sales wording'.

https://www.digikey.com/products/en?keywords=MAX485ESA https://datasheets.maximintegrated.com/en/ds/MAX1487-MAX491.pdf

So one way would be to try the hybrid at 5V and see if it behaves.

neilh10 avatar Aug 24 '20 01:08 neilh10

@neilh10, I really appreciate the detailed reports from your scope! It's awesome to get that kind of feedback.

These electronics from unknown Chinese manufacturers that we get on Amazon are definitely not optimal, for all the reasons you describe (i.e. mixed and changing quality, no accountability). I would be grateful to find an alternative source for these RS-485 adapter/converter boards. Let me know if you find any!

Fortunately, of the 15 WingShields I made in the last week, from 3 different "vendors/batches" (all with slightly different markings), only one of them didn't start working as soon as I connected the 120 ohm resistor. I also got one of my old "failed" WingShields to work again.

Regarding power conversion, for the ~50 that I've used to date, I've powered the sensors with either 9V or 12V and used the RS-485 adapter/converter to logic-level shift to 3.3V for the Mayfly. I've never had a problem with that. Also, of the ~50 that I've made, only 2 have ever failed on me (now that I've added the 120 ohm resistor).

By the way, the reason I tried 12V logic-level-shifting (even though all the descriptions on Amazon say 3.3 to 5.0V), is that when I first ordered sensors from YosemiTech, I also ordered their RS-485 conversion box, which was set up for a 12 V battery. Eventually, I decided to break open their box, and inside, I found the same blue RS-485 board that I've been using ever since.

BTW, @SRGDamia1 has had success with a few other RS-485 converters:

  • https://www.amazon.com/gp/product/B075FP9R4N
  • Another than I can't find.

Also, @gcutrell recently had success with this: https://www.amazon.com/gp/product/B07B1WMZM8/

Maybe one of these are worth trying, or we design one ourselves from scratch, but that's a lot of work.

aufdenkampe avatar Aug 24 '20 21:08 aufdenkampe

Hi @aufdenkampe, thanks for sharing your numbers. I do really appreciate a lot of work has gone into publishing the current wingboard. Good to know the numbers that have worked for you.

Wish it had been the same for me - last week of the 4 that I had built with amazon hybrids from different sources over the last year, only one worked - and had been working for two months in a beta system and with the reliable protocol reporting. Yeah.!! I had pre-built two of them last year, and just hadn't tested them yet. The 5th board I've built from a known amazon lot purchase, works under the unloaded condition, and I have another 5boards from that lot purchase.

I was expecting it to take 5 minutes to test out the boards I had pre-built. Its a very nice simple process that building the wingboard with the +12V booster has well identified. Thankyou for all that work.

I put two days into a detailed understanding what wasn't working, using the Mayfly with its debugging and then a logic analyzer.. So that's just my data point .

Thanks for the other references for boards.

I'll keep my eyes open for other sources - I was very interested in trying out the approach through an amazon distributor. Even though amazon as a distributor is low cost, I believe the core issue is buying devices unbranded of untraceable quality through amazon, and as a low cost device there is no interest by amazon in traceability.

If there are devices that come up through distributors with support, eg Dfrobot, Adafruit, then there is a better chance of it having traceability - or at least the distributor hearing of quality issues.

Hope your run of success continues - its definitely a statistical analysis - and depends on the volume as to what is acceptable failure rate, and how well its tested.

My solution is to build the RS485 wingboard board that has traceable parts. (Ideally with an open source kicad-pcb.org .... 👍 )

Alternatively for the RS485 hybrids through Amazon , they possibly could be checked to see if it behaves with the MAX485ESA being supplied with +5V (instead of 3.3V) . and then shift the RX output to 3.3V for the Mayfly interface. Both the +5V switched and +3V are available on the Mayfly connector. But personally I'm not going down that route.

neilh10 avatar Aug 25 '20 00:08 neilh10

@neilh10, I appreciate how frustrating it is to build these things and then have them not work. That happened to me with a batch of 8 this fall and again this spring with a batch of 6. It resulted in a lot of wasted time and a lot of headache, given that I'm nearly always on a tight timeline to deliver these.

I really like your idea to build an RS485 WingShield from scratch with traceable parts, open-source the design with Kicad, and find a trusted manufacturer. Even if they work 100% of the time, it's still a lot of effort to build these, given the volumes that I typically do (i.e. for 6 to 12 stations at a time).

aufdenkampe avatar Aug 25 '20 13:08 aufdenkampe

I guess I've got a different basis, and good experience with my toaster oven https://www.youtube.com/watch?v=UgtwS7WhLeo

neilh10 avatar Aug 25 '20 15:08 neilh10

That is a very cool video of DIY circuit board making! Thanks. I've never done anything link that. Maybe I'll try that before too long!

aufdenkampe avatar Aug 25 '20 16:08 aufdenkampe

@neilh10, I just reread this thread (while helping someone troubleshoot), and I see that my poor wording in https://github.com/EnviroDIY/SensorModbusMaster/issues/14#issuecomment-680015234 -- "Even if they work 100% of the time..." -- didn't adequately specify that I was talking about my design using the blue transceiver boards from Amazon.

I had been meaning to convey that "I really like your idea to build an RS485 WingShield from scratch with traceable parts", because the approach I've been using takes a lot of labor for something that can't be fully trusted.

I'm very, very interested in your toaster oven approach to make these from scratch, which I think would be both a lot less overall work for making the large batches that I need and also a better final product. I'm very interested in helping where I can on such an effort.

aufdenkampe avatar Oct 01 '20 18:10 aufdenkampe

@aufdenkampe gosh appreciate you've been thinking about it - from the stages that this sort of innovation goes through, you tied it all together with the software stack. Its amazing the scope of getting the whole technology stack working . Now, having identified a key component has having some undefined unreliability, then we go back in and change things. I've been reflecting a bit on the challenges~ my background is electronic engineering. Professionally for companies, I end up solving these problems when there already has been large deployments. (!!) and there is a failure rate coming of manufacturing.

I've been thinking an (my) intermediate goal is to try testing the RS485hybrids that aren't working with a 5V supply, and 100K R on the output for 5V to 3.3V shifting. The MaxRS485 chip (assuming the marking is correct) is specified for 5V. There is 5V available. I have purchased a couple of the more costly RS485 hyrbrids to test as well - and got them labeled to trace them. However the bigger issue is still that the amazon marketplace is providing a key product with poor traceable sources.

From an open source view point, if we could figure out how to do the PCBs with Kicad, and the supporting footprint libs, (and of course learn the KiCad interface) then it becomes pretty trivial to just turn the PCB and send it off.

There is also an RS485 with digital Auto Direction MAX13487E/MAX13488E - so only uses two wires. Some general technical info I have bookmarked https://e2e.ti.com/blogs_/b/analogwire/archive/2019/04/09/frequently-asked-questions-and-answers-for-rs-485-transceivers

But as every its time - I'm about 20miles Sth of the Santa Rose fires, and I'm putting a focus on hardening my house in case we get subject to one of these chaotic ember storms that are being seen last weekend in the Glass fire, and also in Oregons fires. I also have a couple of technical potatoes turning over that need time.

So happy to plan it out, and then try an it make it happen.

neilh10 avatar Oct 01 '20 20:10 neilh10

An update, as a trial and to get my fingers wet with Kicad, I converted the eagle files to kicad - and it went well. It doesn't generate the BOM very nicely, but for a small board thats OK.

I've also tried one of my units that wasn't working to using the 5Vswitched for the MaxRS485 , but that didn't work either - still need to check a few things out,.

Going on to prototype with MAX134xx, with autoDirection, as a wingboard, and as an option to be pluggable into a 4pin Seeed. Assumes that it gets Vcc5vSw As an option looking to take the +12V boost power directly from a LiIon/2mm, switched by the Vcc5vSw ~ so that way for potentially heavy instrument power bypass routing the power through the Mayfly where it can potentially cause a uP reset.

Just wondering if anybody interested in the design or see any other must have "Requirements" or optional "Objectives"

neilh10 avatar Nov 02 '20 17:11 neilh10

Completed a beta board using KiCad https://oshpark.com/shared_projects/6Smc4cNd. After receiving board will test.

neilh10 avatar Nov 04 '20 20:11 neilh10

@s-hicks2 Have you seen this?

SRGDamia1 avatar Nov 09 '20 16:11 SRGDamia1

@neilh10, thanks for sharing this! I'll need to check it out this week!

Thanks for asking about "Requirements" or optional "Objectives". @s-hicks2 might pipe in with ideas, as we discussed this a year or two ago via email (I'll try to dig it up).

One idea that comes to mind, it would be nice to prevent current bleed when the Wing is powered down and the AltSoftSerial pins are left "high", as described in https://github.com/EnviroDIY/ModularSensors/issues/140.

Also, I'm connecting this to some other related issues:

  • Spin the Mayfly Wing into its own repo #8
  • Lightening protection suggestion #15

aufdenkampe avatar Nov 09 '20 16:11 aufdenkampe

Ok. This was a status update that I'm in process. Its a proto board takes some time to return and test.

neilh10 avatar Nov 09 '20 17:11 neilh10

Ok for #8, this could be done in my fork - For a starter I've created https://github.com/neilh10/SensorModbusMaster/issues/1 but I'm open to other ways of doing it. I have got status listed there.

neilh10 avatar Nov 18 '20 18:11 neilh10

I've published a proposed a new cct ~ any comments welcome https://github.com/neilh10/SensorModbusMaster/issues/1

neilh10 avatar Feb 03 '21 23:02 neilh10

@neilh10, thanks working on this and for pointing us to your designs. I'm ready to roll up my sleeves to help test and/or manufacture, as I need >30 by April. I responded in more detail at https://github.com/neilh10/SensorModbusMaster/issues/1#issuecomment-773420103

aufdenkampe avatar Feb 04 '21 16:02 aufdenkampe

This issue has been functionally moved to the https://github.com/EnviroDIY/Mayfly-Modbus-Wing repo. See:

  • https://github.com/EnviroDIY/Mayfly-Modbus-Wing/issues/1

If this issue needs further discussion, please continue it in a new issue in https://github.com/EnviroDIY/Mayfly-Modbus-Win

aufdenkampe avatar Oct 31 '23 15:10 aufdenkampe