5
\$\begingroup\$

I created a Raspberry Pico based PLC board which worked perfectly alone, however once I placed it into a distribution box and started switching a fairly large (7.5kW) contactor, the on-board seven segment display started glitching by displaying random digits and eventually turning off. This happens every time I power on the system and must restart it manually once the display turns off.

The contactor is switched on 230V mains by a +5V relay and the relay has flyback diode across its coil, so it should not create much noise theoretically on the low voltage side.

After inspecting the traces between the Raspberry Pico and the MAX7219M seven segment driver IC, I noticed that the clock signal, as well as the +5V are really noisy as you can see here: Noisy clock signal Noisy +5V

So far I tried removing all unnecessary connections and upgrading the +24V 2A PSU (which feeds the on-board +5V switching regulator) to a 10A one, but the problem still persists.

I did some research and realized that I probably should have added a ground plane to the PCB to reduce EMI, however I already ordered them and look for a solution that does not require redesigning and reordering them.

Any suggestions how to minimize the noise?

DDistribution box Schematic PCB

\$\endgroup\$
9
  • 2
    \$\begingroup\$ Contractors is a great way to pre-compliance test your boards for EMC problems, as it turns out. I recall rigging a PCB of mine next to some industrial contactors in a basement and having them toggle on/off repeatedly :) \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 10:02
  • \$\begingroup\$ What baudrate are you using for SPI? \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 10:04
  • 3
    \$\begingroup\$ No ground-plane on your circuit board not only means a high risk of EMI affecting the design but an almost impossible task of making any decent noise measurements with an oscilloscope. \$\endgroup\$
    – Andy aka
    Commented Mar 21, 2023 at 10:29
  • \$\begingroup\$ The SPI baud rate is irrelevant. The 5V LED chip needs 5V SPI bus but MCU has 3.3V SPI bus. See my answer for further info. \$\endgroup\$
    – Justme
    Commented Mar 21, 2023 at 11:29
  • \$\begingroup\$ @Lundin I decreased SPI baudrate as much as I could, the clock speed is 1.9KHz measured. \$\endgroup\$
    – SmileXS4
    Commented Mar 21, 2023 at 13:46

4 Answers 4

3
\$\begingroup\$

I'm sorry, but I strongly suspect that you can't salvage this design. Misc EMC and design remarks:

  • Yes, using 4 layer PCBs with dedicated ground planes helps EMC immensely. There aren't any good reasons not to use 4 layers whenever dealing with QFP/QFN/BGA parts. This is the major problem with your design.

    Particularly the blue traces (ground?) look like it could make a pretty good PCB antenna. It's hard to say if the noise is picked up at the SPI lines or by the ground traces, or the supply, or all over the place. And as noted by @Andyaka in comments, it will be a pain to track down the source with no good ground references for your scope probes anywhere. Troubleshooting ground noise in particular is difficult.

  • Using a hobbyist board mounted on header strips is less than ideal. I don't know how (un)suitable this board is for industrial applications, but even ignoring that, this board-to-board solution forces you to route the signals in strange ways. The header strips make for half-decent antennas, as do the long traces on the bottom PCB.

    Since you only seem to need GPIO + SPI, why not CAD the MCU straight onto the bottom PCB?

  • As a longtime user of the Simple Switcher buck regulators (I've been using them since the first generation released by National), I have absolutely nothing good to say about them except "they are cheap". Like any switching regulator, the layout is a very delicate matter and you can't expect to make a good one without a 4 layer board. As for how to do it, it's a big topic and I'm far from an expert on that. But this regulator and its layout is pretty much dead certain one of your EMC problems or I'll eat my hat.

    You could check if the frequency of the noise matches the switching frequency of the regulator. If so, well... bingo. Then maybe ditching the regulator for a better one will solve a lot of problems.

  • This board too is suffering from "hobbyist board optocoupler disease", a recurring problem with all these Arduino/Pi designs. There's absolutely no reason why you'd need to use optocouplers here, it's just extra cost and something extra that might break. Optocouplers are kind of infamous for being unreliable over time.

  • If you have 24VDC available then why use 5V relay coils? You could as well power these from 24V which is a more common industry standard. That way you'll get less load on the switching regulator too. You'll have to redesign the BJT (or MOSFET) around the coils accordingly. You can probably use one of the "ULN" BJT array parts to simplify the BoM.

  • At a bare minimum place a TVS on the incoming raw 24V. Typically you'd pick one rated around 30-33V. This will help a lot in reducing spikes coming in from that direction.

  • Keep SPI baudrate as low as possible. For this 7 seg IC you'll hardly need anything faster than 100kHz and you can probably stop the speed even more. Probably reduced drive/slope control could be used, or you could add small RC lowpass filters on the SPI lines.

\$\endgroup\$
7
  • \$\begingroup\$ Thank you for all the useful informations! When I designed the board a while ago I did not pay attention to most of the things you pointed out, but will definitely pay attention in the future. To clear some uncertainties: I used two layer PCB to reduce costs; the blue color indicates the bottom layer; many parts of the schematic are copied from other sources, that's why they don't make sense. \$\endgroup\$
    – SmileXS4
    Commented Mar 21, 2023 at 13:39
  • \$\begingroup\$ @SmileXS4 There are barely any cost differences between 2 and 4 layers these days. Costs rather depend on the amount of copper and current copper prices. Also "cheap but doesn't work" is actually very expensive... \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 13:43
  • 1
    \$\begingroup\$ Also if cost is an issue then the first thing to do is to get rid of the MAX part. You can bit bang these segments manually through software, it's not hard. You'll probably need some shift register etc instead though. But Maxim historically has a long tradition of shameless price escalations. What will happen now that they are part of AD, nobody knows. \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 13:49
  • \$\begingroup\$ You are absolutely right, at least so far the lesson didn't cost as much as it could have. I built something similar before using 75hc595's, but in this case they would be disturbed by the noise too I guess. \$\endgroup\$
    – SmileXS4
    Commented Mar 21, 2023 at 13:59
  • \$\begingroup\$ @SmileXS4 For a 7 seg you actually don't have to run a shift register like 74HC595 from SPI, you can manually bit bang the clock, long as you keep updating it quick enough for the human eye not to notice the flickering. Although I kind of suspect that your EMC problems aren't related to SPI as such, but rather to the supply and board layout. \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 14:07
3
\$\begingroup\$

Most likely cause is the relay contacts arc and spark if there is no snubber to suppress the inductive kick, not at the relay contacts, nor at the contactor coil drive input.

Also some of the spikes you see may be due to incorrect probing techniques, if you simply have the long crocodile clip lead going to some place far away from what you are measuring with the probe tip.

And finally, you may have to redesign the board anyway. If you use the MAX7219 with 5V supply, it officially is not specified to work with 3.3V SPI bus, as the minimum input voltage for logic high is 3.5V. It is possible that no matter what you do to filter out all electrical disturbances, some boards may not work at all because chips requiring 3.5V don't have to work with 3.3V signal.

The optoisolators between relay transistor and RPi look like just are copied from somewhere. They are quite useless as they are not used for isolation. They could be removed to make cheaper design with less components, which also uses a bit less power to drive the relay. But they do no harm either.

\$\endgroup\$
5
  • \$\begingroup\$ Thank you! I might add a snubber network to see whether EMI decreases. I do regret that I did not place a 3.3V to 5V level shifter between the Pico and the MAX7219. You are right about the probing too, I should place test points next time in addition to a ground plane. \$\endgroup\$
    – SmileXS4
    Commented Mar 21, 2023 at 13:45
  • \$\begingroup\$ How can you tell that the SPI signals are 3.3V? The Rasp Pi board is supplied with 5V, but maybe it got a 3.3V regulator on board? \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 13:46
  • \$\begingroup\$ @Lundin The Pico has an on-board 3.3V regulator, the signal levels are 3.3V. \$\endgroup\$
    – SmileXS4
    Commented Mar 21, 2023 at 13:47
  • \$\begingroup\$ @SmileXS4 I'd probably just get rid of the MAX part entirely. You can control the 7 seg through shift registers or similar. \$\endgroup\$
    – Lundin
    Commented Mar 21, 2023 at 13:51
  • \$\begingroup\$ @Lundin RPi and similar devices are powered from 3.3V, they can't handle 5V. It has onboard regulator like Arduinos. And scope traces say 3.3V signals. \$\endgroup\$
    – Justme
    Commented Mar 21, 2023 at 14:04
1
\$\begingroup\$

One dirty solution which does not fix the root of problem, but at least makes the board partially usable, is to continuously reset the MAX7219M and display the values in a loop. This way glitching can be seen only for a brief moment and in case the displays turn off, they turn on again instantly thanks to restarting the MAX7219M. Or even better, only enable the MAX7219M in idle mode (when no relay or contactor is switching).

Extra measures could be taken to reduce the noise, but at the end, the board has significant flaws as pointed out by @Lundin and @Justme, so a redesign is inevitable for better (or even industrial) reliability.

\$\endgroup\$
1
\$\begingroup\$

Current flows in loops. Rule 1 of signal integrity is to minimise loop area. The greater the loop area the greater the unwanted magnetic coupling.

When routing single ended signals, it's easy to forget about the ground side of the loops. Ground planes can help, but on 2 layer boards if you are not very careful they can become so "cut up" that they aren't all that helpful. This is where multilayer boards really shine, you can dedicate whole layers to power and ground.

There is a lot of misinformation about "ground loops" out there. There are some very-specific situations in which a tree approach to grounds makes sense, but high speed digital work is emphatically NOT one of them.

You seem to have completely ignored the ground pin on the pico that is closest to the SPI signal lines. Runing a wire from that pin directly to the ground pin on the LED driver may well help and seems like the easiest thing to try without re-doing the whole board.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.