Author Topic: PCB Review: Thermostat PCB  (Read 2093 times)

0 Members and 2 Guests are viewing this topic.

Offline Peter_GTopic starter

  • Newbie
  • Posts: 7
  • Country: us
PCB Review: Thermostat PCB
« on: July 27, 2024, 02:32:19 pm »
I'm looking for some feedback on a thermostat PCB layout I've put together.  I'm a mechanical engineer so all my PCB design knowledge is self-taught and in addition to this being the most compact board I've done, it's the first I've dealt with anything AC on my boards, so I expect there's a lot to learn here.  The AC in this case is the 24V line from my furnace which I am using for power and to enable the heat/ac/fan via some relays.

  • The power supply design is copied from the RT6362GSP datasheet.
  • The temperature sensor layout is copied from the Sparkfun TMP117 breakout board.
  • The MCU power design comes from the STM32U585CI datasheet.
  • The display is going to be a Pervasive Displays 1.97" EPD, driven via their EXT3-1 board.
  • The "radio" plug is for future plans to add connection to an RFM69HCW-based board (915MHz) for hooking into a broader home automation system I am conceiving.

I'm planning on ordering through JLCPCB and have set up my DRC via their constraints which it passes.  I've attached the schematic and layout as well as KiCAD project in case anyone wants to look at that as well.

Many thanks to anyone who wants to share feedback!
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3807
  • Country: nl
Re: PCB Review: Thermostat PCB
« Reply #1 on: July 28, 2024, 01:36:31 pm »
I very much like your schematic drawing style. Mostly keeping signal flow from left to right and voltages from top to bottom in each block makes signal flow easy to follow. I am happy you did not use the rectangles around each circuit section. Maintaining those often requires many redraws or size adjustment and they soak up a disproportional amount of time without adding anything useful. In your schematic all sections are separated by a bit of whitespace, and they have titles in big letters which makes it easy to identify the blocks.

KiCad has always been a bit "ugly" with text rendering. Make the text bold makes it easier to read when zoomed out. Making it big and bold also makes it a bit too prominent. Making it bold with a text height of around 4mm both makes it very readable when zoomed out, and saves some space on the schematic. (only 40% of space compared to 6.35mm).

You can consider replacing MMBTA06 with something similar to TDTA114Y. Such transistors have built in resistors which reduces PCB area, schematic and PCB drawing effort and PnP or hand soldering time. FET's could also be used but I have always had the perception that FET's are less robust then BJT's. Also, if a FET blows, it's easy to damage the uC too. When a BJT goes bad, there is still the base series resistor to limit the fault current into the uC.

ERC throws 999+ warnings. Many are in the form of: Warning: Pins of type Passive and Unspecified are connected Setting pins to Unspecified is problematic for ERC. Setting them to passive is nearly always a better option. After ignoring these, and the Library symbol issue ERC looks pretty clean. (Except for the PWR_FLAG

You have used very big and old fashioned and also slow "freewheel" diodes for your relay coils. A faster diode is better here, and you don't need a 1A diode. Also, it's common to have two diodes in a SOT23 package. Have a look at the ubiquitous BAT54. It comes in versions:
* Single (without suffix).
* Dual with Anodes connected (A suffix)
* Dual with cathodes connected (C suffix) (This fits your application).
* Dual in Series (S suffix)

You don't need Schottky diodes, but it does not hurt either (unless leakage is important) There are probably other diodes too, It's just a common type number that is available right from my head.

R34 and R36 are 100 Ohm. Resulting in a peak current of 33mA through the encoder switches. It's good to have these resistors, but 33mA may still be a bit much for your encoder.

I had a look at the datasheet of your G6SK Relays:
https://eu.mouser.com/datasheet/2/307/K093_E1-3446793.pdf
Contacts are rated for 250Vac, 2A, but that means the contacts themselves are capable of handing that amount of power. It does not mean that your relays have big enough internal clearances to act as an isolation barrier between live mains voltages and things you can touch with your fingers, Mains related projects always require extra attention to be in line with safety requirements, either earthed, or double isolated. For example what happens if your relay overheats (for example because of a bad contact) and partly melts. Can this put mains voltage on the relay coil contacts? Your relays are quite small and may be inadequate here. Such safety concerns are one of the reasons many relays are much bigger. Datasheets of relays do not mention whether they are suitable for use between mains to fingers isolation. It's also not my expertise, but G2R is probably a safer bet (pun intended :) ). G2R is a very popular relay and for good reasons. It is also available in latching variants.

For the schematic, I prefer local labels. Although they are functionally the same for a single sheet schematic, they are simpler without the boxes around them, and they require less editing when you want to go to a hierarchical schematic later.

Schematic & routing around the Radio Tx/Rx part is not good. First, I prefer to add series resistors for off-board connectors. Even 20 Ohm resistors significantly improve the effect of TVS diodes. Putting bidirectional TVS diodes both on GND and +3V3 is a bit excessive, but it does not hurt either, and for low number of boards the costs also do not matter much.
For the routing, it is not good to directly route from the uC pin to the connector, and have a separate track to the TVS diodes. ESD events are very fast, and the inductance of the track to the TVS diode reduces it's efectiveness. It's better to route from the connector to the TVS diode, and from the TVS diode to the uC. This always forces the ESD event to go near to the TVS diode.

You have put a few footprints on the back of the PCB. This is not a big problem, but assembly is a bit easier if all footprints can be put on the same side.

You put the feedback resistors of the SMPS close to the controller. That is good, but feedback from the 3V3 wire is very long and goes around the inductor, that increments impedance and noise pickup and that is not so good. The rest of the layout around the SMPS IC looks quite good, but I have not looked deep into details.

Overall PCB layout is somewhere between not so good and mediocre.  Most of it is drawn nicely, but you have completely cut up your GND plane into little pieces and this is very bad. This is very common with beginners though. Rick Hartley has made a 2 hour and 19 minute long video about GND planes and it is worth watching at least twice (with a few months in between). That is how important GND planes are. As is, your PCB will probably work, but it won't pass EMC tests.

Most of your uC pins are generic I/O pins. It is common to re-assign these in software to make routing easier. The goal here is to put them in such order that the front side of the PCB can be used for all the routing, and the back side can be a continuous GND plane.

The quality of your GND plane is also hard to analyze because you put GND on both layers and stitched together. Stitching them together is better then nothing, but it is a last resort. In your stitching you also have quite a lot of PCB areas that are not connected to anything. If you use GND stitching, then at least put extra via's in corners of such unconnected GND sections, and where signals leave or enter stitched GND area's.  First goal is to have a single uninterrupted GND plane. This both has better performance, and is much easier to analyze.

Near the relays, you have some horizontal tracks both on the front and on the back. These cut the GND plane into quite a lot of sections, and there is also not very much GND stitching over there. Putting all these tracks on the same layer, so the other can be a continuous GND plane is much better. Signals there don't switch often, and this reduces EMC emitted noise, but they are still directly switched from uC pins, have fast transitions, and thus need EMC mitigation techniques. Things as simple as moving the base resistors of the BJT's close to the uC instead of close to the BJT's improve EMC performance.

After this long post, Overall impression is that this project is already much better then I would expect from a beginner with PCB design / layout. Even if only the GND plane and the big fat 1N4007 diode issues were remedied, it would become difficult to see this PCB was made by a "beginner".
« Last Edit: July 28, 2024, 02:07:16 pm by Doctorandus_P »
 
The following users thanked this post: Peter_G, ahbushnell

Offline Peter_GTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: PCB Review: Thermostat PCB
« Reply #2 on: July 28, 2024, 04:50:52 pm »
Thank you so much for the detailed feedback - it's very, very much appreciated.  And thanks for the compliments as well!  It's nice to hear it sounds like I'm picking stuff up alright.  This is only the 2nd microcontroller board I've designed, but I do my best to try and learn from observing other peoples' designs and reading datasheets and I watch a lot of Altium's videos on YouTube which have been super helpful.  I also worked in an electronics lab in college as the ME that took care of the 3D printers and CNC machines, so I had the opportunity to pick up a lot of knowledge from the ECE guys there which was super helpful when first learning KiCAD.

I actually wasn't even aware of ERC and honestly didn't know what the pin type designations were for, I think I assumed they were for simulation.  I'll definitely be more deliberate about specifying those in the future and take advantage of the ERC tool.

The diodes I selected because I have a big wad of them in my stash of miscellaneous components and it seemed like they would fit the job.  I'll take a look at the alternatives you mentioned.

Good catch on the amperage for the encoder pins.  I just copy-pasted a debouncing filter circuit I've used in the past and didn't really think about it at all.  I will reevaluate those values to bring the current down.

I forgot to mention the AC input is NOT mains - it's typical HVAC 24VAC/60Hz.  Those relays are comparable to the ones on my old thermostat and I saw them recommended several times for use in HVAC applications, so I think they should work.

Thanks for the suggestions about the TVS diodes on the UART connector.  I had actually never heard of TVS diodes and somebody on Reddit said I should put those 4 ones there but didn't say much else and I figured it wouldn't hurt.  What you said about placement makes sense so I'll make those tweaks for sure.

I tried to move as much as I could to the top layer, but I'm doing the assembly myself and I have a very nice setup for soldering so I'm not too worried about doing both sides.

The routing of the 3V3 wire around the power supply is actually copied directly from the layout on pages 31/32 of the RT6362GSP datasheet.  How would you suggest routing that trace?

I'll take a look at improving my stitching of the ground planes.  I at first was trying to not interrupt the backside ground plane at all, but resorted to running a few long tracks that you see on it to get the button and display signals away from the MCU.  The long tracks going to the encoder which run by the relays are there because I wasn't sure how far I should be keeping things away from the power supply layout and looking back at it now I think I was probably way too overzealous.  I should be able to fit those on the top layer fine but they will run right close to R19-21 - is that okay?  More importantly, what should I know (or where can I learn) about spacing tracks around power supplies like that?

Thanks again for the very detailed review.  I really appreciate you taking the time to go through everything!
 

Offline Peter_GTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: PCB Review: Thermostat PCB
« Reply #3 on: July 28, 2024, 05:03:05 pm »
Sorry I'm not super familiar with how this forum works, I just noticed there's a different reply button on your post and the one I clicked was to reply to the whole thread so idk if you got notified of the reply.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3807
  • Country: nl
Re: PCB Review: Thermostat PCB
« Reply #4 on: July 28, 2024, 06:48:32 pm »
I think I've got notifications turned off for everything except maybe the few threads I've started myself. I'm more of a guy that only views foums when I'm in the mood for it.

I'm a bit surprised by the big loop in the feedback from the SMPS. I guess it works because the whole track is shielded by the GND plane.

For the rest, it makes sense that you copied circuit snippets from different sources. It's OK if you just want to build this PCB. If you are interested in more depth in your knowledge then keep on learning. The Rick Hartley video I mentioned is a good source. Searching with the magic words "Hot loop" will give hints and reasoning around layout of SMPS circuits.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7408
  • Country: ca
Re: PCB Review: Thermostat PCB
« Reply #5 on: July 28, 2024, 09:55:15 pm »
A few observations. The board looks very good for a MecE  ;)
You can get rid of many parts (23) save some room using a ULN2003LV or ULN2003A to drive the relay coils. A 63V filter cap is OK, I have seen 50V used as well but they changed to 63V in production for some reason.

My EE rule is "the fuse comes first" and your fuse is downstream so it does not cover for shorts on C3, D7.
Because HVAC 24VAC usually has one leg tied to earth ground (in the appliance), any ground-fault (JTAG or serial port included) will smoke the bridge rectifier and cause other damage with no fuse blowing for that. I have seen some designs use a half-wave rectifier instead.
The Belfuse needs a holder maybe, and if it blows since the relays are latched call for heat/cool will never end...
I dislike all the LED's being blue, I use green for power, orange for call for heat etc.
I would have a 24VAC digital input (opto coupler) option if you want to keep an eye on the furnace or A/C, if it's not working or tripping due to a flame detect issue etc.

edit: how are you saving temperature setpoint? I notice the STM32U585C has no EEPROM, there is no backup battery as well.
Also the terminal block labels look jumbled "Heat" is not pin 2 with HVAC_24VAC going to it. COM is not common. I'd have a few more via's for the ground pour near C3.
« Last Edit: July 28, 2024, 10:16:44 pm by floobydust »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf