cancel
Showing results for 
Search instead for 
Did you mean: 

My first ever PCB design. Any comments? Tips or tricks?

bepo-san
Associate II

Hello stm community. I am designing my first ever PCB board and i need some comments of yours. Here is the screenshots of the pcb schematic and pcb itself. Do you see any mistakes etc? Also I am not sure about the VCAP connection. Is it correctly made?

 

Screenshot 2024-01-21 154527.png

Screenshot 2024-01-21 154550.pngScreenshot 2024-01-21 154605.pngScreenshot 2024-01-21 154617.png

 

12 REPLIES 12
Peter BENSCH
ST Employee

Firstly, congratulations on starting a hardware design! Just a few hints:

  • With the STM8S005K6T6, you have chosen an MCU that, like all STM8s, has been on NRND for a long time and will only be produced until January 2032. If this is not a project that you only want to produce for a short time, you should switch to MCUs that are available for the longer term.
  • It is rather unusual to distribute the components at all possible angles on the board, partly because the available board space is not optimally utilised. For example, U3 could be arranged parallel to connector U4.
  • You seem to be using the module to control only four outputs via a ULN2003. Typically, this is not time-critical, so the STM8S005 should be able to manage without a crystal and you can use the HSI as a clock source. You can also calibrate HSI more accurately than the basic accuracy of +-5%, but this requires an external accurate clock source, as described in AN2822 for example.
  • While we're on the subject of crystals: if you still want to use a crystal, you should work through AN2867, where section 7 provides information on the layout. In your design you seem to have a continuous GND layer, which is not a good idea for a crystal. Also, 30pF for C2 and C3 seems far too large to me, for most 16MHz crystals 6...8pF should be sufficient.
  • L1 and L2 have an inductance of 27nH, which is far too low for decoupling the power supply. L1 should rather have 10...100µH, L2 should rather be in the range of millihenry according to the switched loads. L2 in particular must also have a saturation current of at least the sum of all switched loads, because otherwise their magnetic field can collapse, causing the inductance and thus its effect to drop to zero.

  • The value of C10 also depends on the size of the loads. If you want to switch the full 500mA per channel with the ULN2003, C10 should rather be in the range 1000...4700µF, which are of course considerably more voluminous and therefore no longer fit on the SMD land pattern. Small consolation: C11 is absolutely not necessary, as the ULN2003 is not a digital component to be buffered.

  • Micro USB connector: in your design only used as a power supply with 5V. Depending on the source of this 5V, it may only be possible to draw 100mA, the standard maximum is 500mA. However, there are also computers and power supply units that do not care about standards and supply the full specified current. You should therefore first check what total current your loads require and what current your source can supply.

Regards
/Peter

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Firstly huge thanks for giving me a such detailed feedback Peter. This will help me a lot.

  • I have chosen this MCU because the cheapest one nearby was this one. This is for a hobby project and i will build and forget it or give it to someone as gift. I think this will be enough since no long term use will bee intended.
  • At this angle the board is the shortest. If i put the ULN2003 parallel to the connector the routed lines does not fit. I made them thicker i don't know why but i thought that the thicker should be better. Maybe if i make the lines thinner your suggestion will work as you said. * Actually i will use this board as a analog clock controller board and that is the reason i put an oscillator. I am making a custom board for this specific project "https://www.instructables.com/Hollow-Clock-4/".
  • The following tips are the ones which i am mainly looking for thank you. I have corrected the design of the crystal. For the 30pF C2 and C3 i have looked the C_load for the oscillator and it was 20pF and I have seen a youtube video of a guy uses a formula as C = 2*(C_load-5pF) which came out as 30pF. I don't know where this formula came out but used it directly. How can i calculate its actual optimal value? The video was this one "https://www.youtube.com/watch?v=wLwKgMBWhpY&t=682s"
  • From the same video i have taken these values. In that video operating voltage is 3.3V, is it the reason that the values are not suitable to 5V? I will use a 28-BYJ-48 stepper motor and its operating current is around 240 mA. How can select a proper inductor for this load? You have already noticed that i do not have much knowledge about these electrical circuits :) It is because i am a mechanical engineering student but interested in these stuff. For the capacitors C10 and C11 i have applied the same configuration with the VDDA input pin. How to decide what is good? How can i learn these? 
  • I have a lot of USB phone chargers lying around so i decided to us them since these are suitable and i have a ton of them. They can supply enough current i think. Since the total consumption will not be high.

Best regards and thanks

How do you plan to load your program into MCU ? You didnt route SWIM and Reset signal...

 

I am planning to load before the soldering. Since this wont be a dev board, i will only load once it does not create a big problem i think.

Peter BENSCH
ST Employee

@bepo-san Regarding the load capacitors, you can find the basics and how to calculate them in the mentioned AN2867. If you give me the values C0, CL and ESR of the crystal, I can check the capacitors for you. The video you cited refers to the STM32, not STM8, and should be seen more as an idea of how to work with KiCAD.

As far as the coils are concerned, I had already specified the order of magnitude, approx. 47...100µH should be a suitable value for L1. In my opinion, L2, C10 and C11 are not necessary as your stepper motor is an inductive load whose current does not need to be buffered with capacitors. However, I would consider a TVS like the SMA6J5.0A or ESDA7P60-1U1M instead of C10 to protect the 5V rail (STM8 and 5V source) from spikes from the stepper motor coils (cathode to VCC, anode to GND). Such spikes are generated when the current-carrying motor coil is switched off and are limited by the freewheeling diode of the ULN2003, but can be quite disruptive or even destructive, which is why a TVS is a good idea.

And finally: @Michal Dudka's advice is definitely worth considering. At the latest when you notice a problem with the system and want to change something, you will be happy about the SWIM port.

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello again Peter. I am sorry for the late reply. Last couple of weeks were a bit bussy for me. I have read the documentations and manuels. For the crystal 16 MHz is not required since this will be just a RTC circuit. 32.768 KHz crystal should 1be enough for an RTC application. So i have replaced the crystal with this crystal. I have to ask can I use such a slow crystal with this chip? HSE should be between 1-16 MHz but i could not find an information about LSE. From what i have read about the crystal capacitors, C2 and C3 should be 15 pF i believe. I have replaced the inductors with the TVS you have mentioned. Replaced USB micro B with a USB type C socket since it is double sided and easy to use. Added some solderpads as you and Michal suggested for the RX TX GND SWIM RST pins. Here is the renewed version of the board. Is is good enough?

Screenshot 2024-02-05 180354.pngScreenshot 2024-02-05 180405.pngScreenshot 2024-02-05 180420.png

Uwe Bonnes
Principal III

Hello,

 

why is a very cheap processor important for hobby use? Go for something more recent. Probably some STM32C0 is available at a similar price. Connect USB as written in the datasheet and then you can upload  and somehow debug your program via DFU. And do yourself a favout and connect the debug pins.  The need for resoldering with every program change will be very tedious.

 

Cheers

Rodo
Senior

Hi,

I didn't read all the replies I just did a text search for vias and pads and didn't see anyone pointing out that there are vias in pads (MCU, ULN2003 GND pin and caps). That's something to avoid unless you're very very tight for space. Just draw a trace to the side and add the via. For the ULN2003 GND you could draw a square on the pad to the side and add the vias. 

Also , D1 and other components have the reference designator inside the footprint.  You won't be able to see them after you mount the components.

Hope that helps.

It is a hobby use but i will produce this board 20 pieces or so and give it to the people. And also i have this specific processor. Also since it will not be a development board. I will not change any program on it. I will upload the code and forget about it. Thats why i have choosen this one.