2
\$\begingroup\$

I'm experiencing a lot of noise in an RS485 network I've put together using ST485 chips. The cable lengths are very short (<1m total cable length), I'm properly biasing the A and B signals and I've tried both with and without a terminator (seems to make no difference), and I'm only running at 19200 baud.

I suspect the problem is ground noise, as I'm using the RS485 input signals to set PWM levels for high-power LEDs (up to 1000mA momentarily at 3.8V). I'm using a four-wire connection between each node (+12V, GND, RS485-A, RS485-B, with the RS485-A & -B a self-twisted pair of hookup wire).

Although it's not suggested in the ST485 datasheet, would it be enough to add a signal ground wire between the RS485 device ground inputs, with 100Ω resistors in series between the RS485 device ground and the signal ground wire? Or should I think about adding full isolation to the RS485 device, including a transformer for floating power supply and opto-isolators on the A and B signal lines? Or is this excessive?

Thanks in advance.

EDIT I know I'm getting noise because in order to get the desired effect (particular brightnesses of particular LED lights), I have to use a CRC-8 on each packet (to drop bad packets at the receiving end) and send every message twice (to make up for dropped bad packets), and even then I'm still getting incorrect packets showing up on the receiving end.

EDIT Removed baud-rate error comments, as baud rate is in fact very accurate.

\$\endgroup\$
  • 1
    \$\begingroup\$ you never explained how you could tell there were noise problems. Bad data? Oscope measurements, share this. People are grasping at the only thing you told them. \$\endgroup\$ – Kortuk Apr 5 '11 at 22:31
  • \$\begingroup\$ As many already noted 3.8% is excessive but what do you have on the receiving side of your 485 link? \$\endgroup\$ – jpc Apr 5 '11 at 22:32
  • \$\begingroup\$ IMHO this does not prove that noise is your main problem. It may still be the baudrate error that is causing this. \$\endgroup\$ – jpc Apr 6 '11 at 11:16
  • \$\begingroup\$ Fix the baud rate error, then see if you still have problems. You should have done that immediately you saw the magnitude of the error! \$\endgroup\$ – Leon Heller Apr 6 '11 at 12:34
  • 1
    \$\begingroup\$ Well this is embarrassing, but in the end it turned out to be a software error on the PC (transmitting) end.. Moral of the story, double check serial transmission buffer sizes + get a logic analyser to confirm. \$\endgroup\$ – damian Apr 16 '11 at 22:57
4
\$\begingroup\$

I'm guessing that the pulsed current draw on the +12v supply is what is putting the noise into the RS-485 signals. For debugging purposes, try disconnecting the LEDs. If your noise issues go away then you know that it's that pulsed 1 amp current. Assuming that's the case, then your job will be to reduce the current spikes on the +12v wire (which are also on the GND wire). A filter using an inductor+large_cap would help. Using a different cable where the power is isolated from the data could help too.

\$\endgroup\$
  • \$\begingroup\$ I'm accepting this answer as it seems most likely from an electronics point of view... \$\endgroup\$ – damian Apr 16 '11 at 22:58
  • 1
    \$\begingroup\$ +1 for pointing out that those 1A slugs of return current are sharing a wire with the 0V reference. If you have 0.5 ohm in that wire, returning the 1A LED current means the ground at your device is going to float up to (0.5ohm)(1A)=0.5V . And since you're PWM-ing this current, inductance of the return wire will only make this effect worse. It's like 'ground bounce'. \$\endgroup\$ – JustJeff Apr 16 '11 at 23:29
0
\$\begingroup\$

my actual baud is 19966, out by 3.8% - could that be my problem?

I'd tent to say yes, especially if you use 9-Bit master/slave mode. With start and stop makes this 11 Bits that have to come through. Even with "normal" 8 Bit (resulting in 10 Bit transferred) the error should be much smaller than 5%.

my F_CPU at 8MHz

How do you generate this 8 MHz? An "internal clock" usually has 1% or more error. With that 1% added, your 3.8% drops "out of the window".

Note that you also must consider the clock errors of the receiving side. This is why most people use a so called "baud rate quarz".

\$\endgroup\$
  • \$\begingroup\$ Good call. I'm using the internal clock of an ATtiny2313, but I can't change that now. The FT232R which is driving the transmitting allows setting non-standard baud rates. I'll see if I can more closely match the 19966 rate I've given myself... \$\endgroup\$ – damian Apr 6 '11 at 11:01
  • \$\begingroup\$ Perhaps you could do a quick experiment at a much slower rate -- 9600 or perhaps even 300 bps? Then if you're still getting errors, you know it must be something else. \$\endgroup\$ – davidcary Apr 8 '11 at 21:20
  • \$\begingroup\$ I finally got to try this today, and actually, according the ATtiny2313 datasheet, the baudrate I'm using is very accurate (to within 0.2% or so), so this isn't the problem. \$\endgroup\$ – damian Apr 16 '11 at 22:54
  • \$\begingroup\$ According to the datasheet, internal clock of ATtiny2313 has only 10% accuracy, this is waaaay off for UART communication. \$\endgroup\$ – Turbo J Apr 18 '11 at 9:10
0
\$\begingroup\$

A 3.8% error is too high, change your crystal or use a baud rate that has a smaller error. It won't be causing your noise problem, although noise will have more effect than if the error was smaller.

\$\endgroup\$
  • 1
    \$\begingroup\$ 3.8% isn't bad. Assuming 8 data bits, 1 stop, and 1 start bit (10 bits total) then you're 38% of one bit time off at the end of each byte. RS-232/485 will work with up to 50% of one bit time off at the end of the byte. Sure, it becomes less tolerant of noise, but there shouldn't be much noise with a 1 meter cable on a balanced signal (if things are done properly). \$\endgroup\$ – user3624 Apr 5 '11 at 21:55
  • 1
    \$\begingroup\$ It is too high. There could be some error at the other end, as well, which would make things worse. pdfserv.maxim-ic.com/en/an/AN2141.pdf \$\endgroup\$ – Leon Heller Apr 5 '11 at 22:01
  • \$\begingroup\$ Maybe so. But it should be possible to calculate the total error for both sides and see what the total error is. \$\endgroup\$ – user3624 Apr 5 '11 at 22:12
  • \$\begingroup\$ That isn't necessary with a smaller error. \$\endgroup\$ – Leon Heller Apr 5 '11 at 22:18

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.