EEVblog Electronics Community Forum

Electronics => PCB/EDA/CAD => KiCad => Topic started by: newtekuser on March 04, 2023, 04:37:52 am

Title: Do I need to move to a 4 layer PCB
Post by: newtekuser on March 04, 2023, 04:37:52 am
Long story short, I have a project using a PIC16F887, some darlington transistors ICs, a schmitt trigger IC and a 16x2 LCD. All ICs are in TQFP format, lots of pins are used and I am unable to route the traces between all connections (using Kicad6) using a 2 layer board.
There's always some trace, or more that overlaps another.

Do I need to move to a 4 layer layout, or is there something I'm missing in PCB design to make this happen?

Thanks!
Title: Re: Do I need to move to a 4 layer PCB
Post by: ataradov on March 04, 2023, 04:54:30 am
Can you post pictures of what you have so far? Overlapping traces are fine as long as you still have place for vias. I don't see why PIC16 and a couple other ICs would need 4 layer board.
Title: Re: Do I need to move to a 4 layer PCB
Post by: fourfathom on March 04, 2023, 05:12:49 am
You may not *need* a four-layer board, but (at least with JLCPCB) the cost difference is essentially zero.  I have a few boards that I was able to route on two layers, and they worked fine.  But I switched to four layers a few revisions back and got a much cleaner layout with good power and ground planes.  It may not have been necessary, but I'm much happier with the layout, electrically and aesthetically.  I used KiCad v6, and KiCad v7.
Title: Re: Do I need to move to a 4 layer PCB
Post by: mariush on March 04, 2023, 05:24:41 am
I'd also like to see what you have so far.

Consider adding some 0 ohm resistors / jumper links to go across some top traces if needed, this way you wouldn't have to break the bottom ground layer or you could use both top and bottom for traces.
If the 16x2 LCD wiring causes issues maybe you could add a serial to parallel IC and have the microcontroller push 8bits through 2 traces. It's a few cents, may be cheaper than going to 4 layers.
Title: Re: Do I need to move to a 4 layer PCB
Post by: wraper on March 04, 2023, 06:58:29 am
You only need 4 layers if you cannot route the thing on 2 or for signal integrity and EMI reasons if circuit has very fast signals. As of your description, sounds like it can be done on single layer with some jumpers.
You may not *need* a four-layer board, but (at least with JLCPCB) the cost difference is essentially zero.
Only for small batch of tiny PCBs and only on special offer, so likely will change after some time.
Title: Re: Do I need to move to a 4 layer PCB
Post by: newtekuser on March 04, 2023, 03:32:46 pm
My routing situation can be seen in the attached picture. I do like the convenience of dropping vias to the ground plane and connect ground pins, so will stick with at least a two layer board and as fourfathom mentioned, the cost difference to move to a 4 layer board is negligible.
Also like mariush's idea of using zero ohm resistors to jump across traces.

Title: Re: Do I need to move to a 4 layer PCB
Post by: fourfathom on March 04, 2023, 03:56:03 pm
You only need 4 layers if you cannot route the thing on 2 or for signal integrity and EMI reasons if circuit has very fast signals. As of your description, sounds like it can be done on single layer with some jumpers.
You may not *need* a four-layer board, but (at least with JLCPCB) the cost difference is essentially zero.
Only for small batch of tiny PCBs and only on special offer, so likely will change after some time.

I assumed that given the OP's questions they were likely doing a small run of small boards.  I could be wrong...
Title: Re: Do I need to move to a 4 layer PCB
Post by: newtekuser on March 04, 2023, 04:05:20 pm
You only need 4 layers if you cannot route the thing on 2 or for signal integrity and EMI reasons if circuit has very fast signals. As of your description, sounds like it can be done on single layer with some jumpers.
You may not *need* a four-layer board, but (at least with JLCPCB) the cost difference is essentially zero.
Only for small batch of tiny PCBs and only on special offer, so likely will change after some time.

I assumed that given the OP's questions they were likely doing a small run of small boards.  I could be wrong...

Correct, it's going to be a small batch for SW development, tired of keeping everything together on breadboards.
Title: Re: Do I need to move to a 4 layer PCB
Post by: woofy on March 04, 2023, 04:20:32 pm
Don't forget you can change the cpu pin numbers as you please to make routing easier. If you are using any specific peripherals then a newer cpu such as the pic16f18877 will give you peripheral pin select so you can move those too. You should be able to place all the lcd pins together and in the correct order. You could also move things around, the programming connector doesn't really need to cross over the transistor drivers.
Title: Re: Do I need to move to a 4 layer PCB
Post by: Jeroen3 on March 04, 2023, 04:37:36 pm
Aside from the noise advantages a 4-layer board in signal-gnd-power-signal stackup offers, your design does not look like a difficult challage for 2-layer board design.
First route the power, oscilliators and analogs, than just go up&down and zigzag the digital lines around all the obstacles.
Title: Re: Do I need to move to a 4 layer PCB
Post by: wraper on March 04, 2023, 04:41:21 pm
This can be done on singe layer with a few jumpers.
Title: Re: Do I need to move to a 4 layer PCB
Post by: ataradov on March 04, 2023, 05:05:08 pm
My routing situation can be seen in the attached picture.
But nothing is routed yet here. This is a trivial board that absolutely does not need 4 layer board no matter how cheap it is. More layers does not always mean better. Board with hidden layers are harder to debug and fix,for example.

I do like the convenience of dropping vias to the ground plane and connect ground pins
You have a ton of space for the ground planes here. This is not even remotely a problem.

Looking at the ratsnest is not helpful here. They always look like nothing will work. Start routing majority of the traces that you can route without interference on a single layer and then see how many unrouted nets you actually have left. Then use via to the second layer.

Also like mariush's idea of using zero ohm resistors to jump across traces.
This is 100% not necessary here.
Title: Re: Do I need to move to a 4 layer PCB
Post by: Doctorandus_P on March 04, 2023, 05:29:43 pm
Footprint placement is a very important step during PCB design. If you do that wrong, then routing a PCB becomes a big mess easily, and it is a factor that beginners sometimes do not realize.
For a project like this, It is often easiest to start with the output connector, and then connect it to the darlington driver IC (I assume its somewhat like the ULN2803) without wires crossing. Then from the darlington IC, you can draw the wires to your microcontroller in a convenient routing pattern, And as a last step, you adjust the software definitions to use the pin layout you created. KiCad does not have special functions for this "reverse design", but you can have both the schematic and PCB open at the same time, and there is cross probing which also helps.


 Another big factor is making the PCB too small, so there is not enough room for the tracks, but that is probably not the issue here.
Title: Re: Do I need to move to a 4 layer PCB
Post by: SiliconWizard on March 04, 2023, 06:54:45 pm
Show a schematic, and your goal. Is this going to be a product? Is this just a hobby board?

Chances are you'd only need a single-layer board as some have said, I've certainly prototyped this kind of stuff on single-layer PCBs back when I prototyped boards making my own PCBs with the toner transfer method.

Now if you're going to have the PCB manufactured, single-layer almost doesn't make any sense these days, as now only very few companies offer single-layer PCBs, at least for individuals at low quantities (only big companies making millions of products still use single-layer boards for the most part, even sometimes not FR4, for things like power supplies, panel PCBs holding buttons and  LEDs, etc.)

With a few exceptions and special deals, 4-layer PCBs unsurprisingly cost approx. twice what 2-layer PCBs of similar class do. And you probably don't need 4-layer here, but again if you can share a schematic and the application, we may have more accurate advice.
Title: Re: Do I need to move to a 4 layer PCB
Post by: newtekuser on March 06, 2023, 01:57:18 am
Problem solved! As suggested, I reassigned some pins and was able to route everything. :-+
Title: Re: Do I need to move to a 4 layer PCB
Post by: asmi on March 08, 2023, 03:06:15 am
Nowadays I always go for at least 4 layer PCBs because my time and sanity is worth more to me than the price difference between 2 and 4 layer PCBs. Once you get power and ground out of contest for routing space, things tend to become much easier.
Title: Re: Do I need to move to a 4 layer PCB
Post by: TomS_ on April 02, 2023, 06:57:45 am
Problem solved! As suggested, I reassigned some pins and was able to route everything. :-+
I hope you've checked the datasheet to be sure the functions you are using are available on the pins you have chosen.

The 16F887 is an oooooold PIC that very much pre-dates remappable IOs, so not all functions are available on all pins...

Newer families don't seem to have any peripherals that can't be remapped last time I looked, I was somewhat surprised. If you can switch to something more modern it would be very much recommended by a lot of people I'm sure...
Title: Re: Do I need to move to a 4 layer PCB
Post by: mikeselectricstuff on April 02, 2023, 09:35:46 am
Quote
Newer families don't seem to have any peripherals that can't be remapped last time I looked, I was somewhat surprised. If you can switch to something more modern it would be very much recommended by a lot of people I'm sure...
This does vary between parts - some parts can map pretty much anything to anything  some have restrictions, and restriction types differ between families
e.g. on the 32MM, only the second peripheral (UART2, SPI2  etc.) can be remapped
On the 16F1535x, most peripherals can only map to only two  of the three port groups (porta,b,c) , and the useable ports vary between peripherals
On the 32MX1xx each peripheral can only map to 1 of up to 8 pins. Except SCLKs Choosing which peripheral (Uart1/2 etc.) to use effectively doubles the choice, but if you're using a lot of peripherals, very careful planning is needed.
PIC24F can map pretty much anything to anything ( except I2C)

There is usually no reason to use the older PICs- the more recent ones are generally better in all respects and cheaper. Availability seems to be getting pretty good again.
Title: Re: Do I need to move to a 4 layer PCB
Post by: woofy on April 02, 2023, 11:06:51 am
PPS is great in the latest controllers, but if there is another feature I'd like to see its an internal matrix to route peripherals internally. In a recent design I needed to route a CLC output to a UART Rx. It's possible to route the CLC output to a pin and use the same pin for Rx, but an internal connection would have been nicer, saving a used but otherwise unconnected port pin.
Title: Re: Do I need to move to a 4 layer PCB
Post by: newtekuser on April 06, 2023, 03:50:08 am
I did try to move my project to a PIC18 family but had some issues getting things to work the same as on the 887 and gave up. However, I do intend to pick this up again with the 18F at some point as the parts are cheaper.
Title: Re: Do I need to move to a 4 layer PCB
Post by: TomS_ on April 16, 2023, 08:06:03 pm
Peripherals tend to get more complex as you move up through the families. They'll have more options that need to be configured and/or different ways to be interacted with.

It can take a bit of time to get used to the changes in a similar peripheral between something like a PIC16 and a PIC24 or PIC32 for example.
Title: Re: Do I need to move to a 4 layer PCB
Post by: mikeselectricstuff on April 23, 2023, 08:39:01 am
Peripherals tend to get more complex as you move up through the families. They'll have more options that need to be configured and/or different ways to be interacted with.

It can take a bit of time to get used to the changes in a similar peripheral between something like a PIC16 and a PIC24 or PIC32 for example.
[/quote
This is true, but they are usually backwards compatible,and will default to the behaviour of the earlier versions until you start playing with addiitonal registers