This is only a preview of the March 2021 issue of Practical Electronics. You can view 0 of the 72 pages in the full issue. Articles in this series:
|
PIC n’Mix
Mike Hibbett’s column for PIC project enlightenment and related topics
Part 4: PIC18F Development Board
I
n the last PIC n’ Mix article
(January 2021), we discussed the
design requirements for a PIC18F development board, creating enough detail
that we believed this month’s task of designing the schematic and layout of the
board would be simple. Now, let’s put
that to the test.
Our goal this month is to take the highlevel schematic shown in Fig.1 and create
the design for a PCB that we can have
manufactured quickly and cheaply by a
PCB supplier. We will go with JLCPCB
based in China for this board, to test how
easy their service is to use compared to
our favourite supplier PCBWay.
We will be designing this board in
EagleCAD, which is now part of AutoDesk’s Fusion 360 product offering.
The software is still available for free to
hobbyists and small companies; and it
has been our default PCB design tool for
over a decade. We’re using it out of familiarity, but completely free CAD programs
such as KiCAD would be just as suitable.
Due to its continual development KiCAD
has become a viable alternative to commercial programs, and we will one day
move over to it. Not this month though!
PCB design process
The CAD design process for our board
will follow a fairly standard process. We
have already chosen our component technology – through hole, not surface mount
– and thanks to the relatively slow speeds
of the signals on the board, we know
that a simple double-sided board, with
components mounted on one side, will
be acceptable. We don’t have any design
constraints on the size of the PCB so we
shouldn’t need complicated ‘tricks’ like
components mounted on both sides, or a
four-layer PCB to allow the components
to be positioned close together.
Space between components will be desirable for ease of assembly and access to
pins/leads with test clips or probes. The
final dimensions of the board will only
become clear once we have placed our
components roughly in their positions.
50
We start with a large outline for the board,
iteratively place components, reduce the
board dimensions and then move components again until the right balance of
board size and component proximity is
achieved. Component placement is a
personal choice, as there are no specific
design constraints, but it seems sensible
to have power and the main I/O signals
at the edge of the board and the CPU in
the middle.
Library of parts
That’s the process but we’re getting a
little ahead of ourselves. First, we need
to create a schematic, and for that we
need a library of components to choose
from. There is a ‘chicken and egg’ situation here; while EagleCAD (in common
with all CAD programs) comes with an
extensive library of components, it is
reasonable to expect that some of our
desired components may not be present
– requiring us to design the footprint, mechanical layout and schematic symbol
for these missing parts.
Creating library parts can be a tedious
task, but a search on the Internet can
often reveal downloadable libraries created by companies and other hobbyists.
A simple Google search, such as ‘EagleCAD DC Barrel socket library’, can
often be successful, but also note that
libraries for many components are made
available by some component suppliers
such as Farnell, RS Components, Sparkfun and Adafruit.
The process for creating a component
library is complex as there are additional
features that must be drawn, including
the location of solder paste, silkscreen
and solder mask. The mechanical dimensions must be accurate too, or you
risk the component not fitting. So, finding and reusing a pre-existing library
is highly desirable, and is one of the
reasons we have stayed with EagleCAD
over the years – it seems to be the most
popular CAD program for downloadable
libraries, although KiCAD is growing
in popularity.
Our preferred approach when an existing library cannot be found is to pick an
existing component that uses the same
physical package, copy it and modify it
to the requirements of the new part. It’s
quite possible we may need to do that for
our choice of processor, at least.
Let’s begin the journey by going back
to our high-level schematic, shown in
Fig.1, attacking each circuit subsystem
in turn and identifying the required components. Once done, we can simply ‘bolt’
them together on the schematic, with
perhaps an extra decoupling capacitor
thrown in for good measure.
Power supply
We have already decided that we want
to be able to support both 3.3V and 5V
as the system voltage, since some sensors and servos run at the higher voltage.
This could be achieved using two voltage
regulators with a 0.1-inch jumper header
to select between them, but to save cost
we went with the LM317 – an adjustable
output voltage linear regulator. This is a
very simple low-cost regulator, available
in easy-to-solder packages. It’s not an
efficient regulator and will waste some
energy as heat, but since we are not targeting battery power for this board that’s
not much of an issue. Although the datasheet is difficult to read (there are many
uses for this regulator) it boils down to
the circuit shown in Fig.2, with decoupling capacitors on the input and output
power pins. We replace the single resistor R2 with two resistors, and a jumper
shorting one of them sets the desired
output voltage. The jumper allows the
‘R2’ resistor to be switched between 390Ω
and 720Ω, and a resistance of 240Ω for
R1 giving the desired voltage.
To connect power to the board we
will allow for two options – a standard
‘barrel jack’ connector, common on mains
‘brick’ power supplies, and 0.1-inch
header pins for quick wire connection.
The barrel jack presents an interesting
problem with the PCB design, which we
will pick up on later.
Practical Electronics | March | 2021
G P I O6 (U AR T2 )
G P I O4 (U AR T2 )
U S B
G P I O7 (U AR T2 )
G P I O18 (P W M)
S ervo
G P I O19 (P W M)
S ervo
Op amp
G P I O5 (U AR T2 )
G P I O8
W i-Fi
G P I O9
Op amp
G P I O10
G P I O11
I2 C
G P I O2 9 (I 2 C1)
P ower
input
G P I O3 0 (I 2 C1)
G P I O12 (S P I 1)
G P I O2 0 (P W M)
S ervo
G P I O13 (S P I 1)
Micro-S D
Media card
G P I O12 (S P I 1)
G P I O14
I2 C
G P I O15
Additional
power
headers
G P I O2 9 (I 2 C1)
G P I O3 0 (I 2 C1)
G P I O1
G P I O16
G P I O2
G P I O12 (S P I 1)
FET
FET
G P I O3
S tatus
L ED
G P I O2 1
P OR TC0
G P I O2 2
P OR TC1
3 2 kHz
crystal
S P I
G P I O12 (S P I 1)
G P I O13 (S P I 1)
G P I O14 (S P I 1)
G P I O13 (S P I 1)
G P I O14 (S P I 1)
L CD
MCL R
G P I O2 3
G P I O2 4
S P I
G P I O2 5 (ADC)
G P I O12 (S P I 1)
P OR TB 7
G P I O13 (S P I 1)
P OR TB 6
Deb ug
G P I O14 (S P I 1)
G P I O2 6 (ADC)
G P I O2 7 (ADC)
G P I O2 8 (ADC)
Fig.1. Our PIC Development Board’s high-level schematic (see PIC n’ Mix, January 2021).
USB interconnection
FET subsystem
Next, we look at the USB serial interface,
which will be based on the MCP2221A IC
from Microchip. Despite the complexity
of what it does, the support circuitry for
this device, as shown in the data sheet,
is very simple – just two capacitors – see
Fig.3. We copy this directly.
For the physical connection, USB
connectors are only available in surfacemount format. They are very challenging
to solder so we will use an off-theshelf USB connector breakout board
that provides an easy-to-solder 0.1inch header interface, which we will
connect to with a plug and socket arrangement. If you are looking to save
costs, you could take a standard USB
cable, cut the end off and solder the
wires directly to header pins.
We will tackle the FETs next. In the previous article we did not go into the details
of how the FETs would be configured,
which does leave some ambiguity. Will we
use a high-side or low-side FET switch?
By this we mean, will the FET be tied to
the positive supply line, or the ground?
We will take the simpler approach,
which is to place the FET switch in the
ground supply line. This has two benefits: the circuit will require N-channel
FETs, which tend to have a lower resistance between drain and source resulting
in a smaller-package FET that can sink
a relatively large amount of current for
its size. Second, the gate ‘on’ voltage
level only needs to be a few volts above
ground, so we can drive it directly from
the CPU, reducing component count.
L M3 17
V in
I nput
Now that choice has been made, our
design decisions become:
n What current do we want to be able
to support?
n What package are we willing to tolerate for the FET (TO92 or the larger
TO220)?
n Will the FET switch on with a digital
signal from the microcontroller?
V IN
FET
sub system
D2
1N 4 001
V out
V DD
Adj ust
R 1
1 2kΩ
L DO
3 .3 V
V U SB
R 2
20kΩ
Fig.2. Power supply schematic (from
Microchip datasheet LM317).
Practical Electronics | March | 2021
In
D+
D–
1
2
TR 1
TN 2 106
R 5
240Ω
P IC
pin 8
5V (U S B b us) or
ext ernal power supply
Output
HDR 4
P IC
pin 9
Out
HDR 5
R 7
1 Ω
D3
1N 4 001
1
2
TR 2
TN 2 106
R 6
240Ω
R 8
1 Ω
U S B
Tranceiver
Fig.3 USB interface (from datasheet
Microchip CP2221A).
0V
Fig.4. FET subsystem (the power comes
directly from the supply, not the regulator).
51
We decide to go with a TO92-packaged
TN2106N3-G, from Microchip. It has a
very low resistance, 0.35Ω; will turn on
with a gate voltage of 2.2V; and can sink
1.2A continuously. This seems a reasonable
compromise; FETs in the TO220 package
can sink tens of amps, but supporting such
a current drain would have introduced
challenges to the rest of the PCB design.
The basic building blocks for our FET
drive circuit (we decided to add two
such circuits in our design) are shown
in Fig.4. This is a simple and standard
configuration for low-side N-channel
FETs. The resistor to ground is there to
ensure that the FET does not turn on
accidentally, should the I/O pin driving it be set as an input (not a problem
if no load is connected to the FET, but
could be problematic if one were.) The
series resistor may come as a surprise
– The gate input resistance on a FET is
extremely high – in the order of 100MΩ.
What possible effect could a 220Ω resistor have?
The gate of a FET has a relatively high
capacitance, and there can be a brief but
high current surge as the gate voltage
rises and charges the gate. A low-value
series resistor is a simple and low-cost
method to reduce that current peak down
to a few tens of milliamps. As we do not
intend to be switching the FET on and off
at high frequencies, the resistor is an appropriate solution. If we were designing
a switching power supply with a gatesignal switching speed of over 100kHz,
then a dedicated high-current driver
circuit would have been required. On a
development board like this, the value
of that series resistor is fairly unimportant, so we may change the value later to a
common value used elsewhere, to reduce
the number of component variants.
As a final point, you can see in the
FET circuit that we’ve added a reversebiased diode across the header. This
is an optional component, designed
to cater for any inductive loads you
might be switching (such as motors or
relays.) These loads generate a large
back-EMF voltage spike when power
is turned off, and the diode will conduct this energy safely to ground. The
FETs have a ‘body’ diode within their
construction, but if the inductive load
is large (or you are passing a large current) a discrete diode will provide a
more powerful sink for this voltage
spike, preventing damage to the FET
and the microcontroller.
Component type count
Reducing the number of different components used is an important step in
the design of any electronic product;
for example, having 50 components
with 50 unique values on a PCB will
52
S Y S TEM_ V
P ower supply
CON 1
D1
1N 4 001
**C4 and C5 close to V DD pin of I C2
C6 close to V DD- 2 pin of I C2
S Y S TEM_ V
1
IN
OU T
2
ADJ
3
I C1
L M3 17
R 1
240Ω
R 14
240Ω
C2
100nF
R 2
0Ω
JP 2 1***
C3
1µF
HDR 1A
1
+
1
C1
10µF
3 5V
HDR 1B
+
C4 **
10µF
3 5V
C5**
100nF
C6 **
100nF
L ED2
G reen
1
2
R 3
0Ω
G N D
G N D
U S B sub system
***Fitted 3 . 3 V
N ot fitted 5V
1
11
HDR 3 *
*Can fit
a female
header
here
C11
100nF
C10
1µF
4
5
4
13
3
12
2
V DD
U R X
V SU B
U TX
R S T
5
6
10
S CL
D+
D–
G P 2
V SS
1
1
1
2
2
2
3
3
3
R C2
G N D
HDR 9
HDR 10
HDR 15
1
2
2
3
3
4
4
R B 1
S Y S TEM_ V
G N D
HDR 11
R 10
4 7kΩ
HDR 12
1
HDR 13
1
2
2
3
3
4
4
5
5
R C4
R C3
S Y S TEM_ V
G N D
G N D
HDR 14
1
R B 0
S P I Exp ansion
sub system
R C5
7
I 2 C exp ansion
sub system
R C7
S Y S TEM_ V
3
8
G P 3
I C3
MCP 2 2 2 1A
G N D
R C6
2
G P 0
G P 1
1
S ervo
sub system
9
S DA
R 11
4 7kΩ
Fig.8. Our PIC Development Board’s final schematic.
result in a higher cost than if there
were only 20 unique values – simply
because buying more of one item will
give a bigger volume pricing reduction.
This is why you may see some unusual
values chosen for certain components in
product designs – a 5.6kΩ resistor used
as a pull-up instead of the more typical 4.7kΩ, perhaps because elsewhere
on the circuit a 5.6kΩ resistor was required for a very specific reason. Such
is the life of a product design engineer!
CPU subsystem
The processor subsystem is next. This
is surprisingly simple; a standard minimum circuit from the datasheet. A
resistor-capacitor circuit on the MCLR
pin to provide the normal power-on
reset delay, plus a few capacitors on the
two voltage rails. We have decided to
add the (optional) low-frequency 32kHz
crystal, as that enables us to experiment
with very-low-current consumption application options. (The main internal
Practical Electronics | March | 2021
S Y S TEM_ V
Analogue
sub system
R 12
220kΩ
HDR 19
1
FET
sub system
HDR 2 0
R 13
220kΩ
1
R 4
4 7kΩ
11
V DD
R E0/ R D/ AN 5
V DD- 2
R E1/ W R / AN 6
R E2 / CS / AN 7
2
MCL R / V P P / R E3
R A0/ AN 0/ C12 I N 0 –
3
R A1/ AN 1/ C12 I N 1 –
4
5
6
7
14
13
3 3
3 4
3 5
3 6
3 7
3 8
3 9
4 0
12
3 1
R A2 / AN 2 / V RE F – / CV RE F / C2 I N +
R D0/ P S P 0
R A3 / AN 3 / V RE F + / C1I N +
R D1/ P S P 1
R A4 / T0CK I / C1O U T
R D2 / P S P 2
R A5/ AN 4 / S S / HL V DI N / C2 O U T
R D3 / P S P 3
OS C2 / CL K O U T / R A7
R D4 / P S P 4
OS C1/ CL K I N / R A7
R B 1/ I N T1/ AN 10/ C12 I N 3 –
R C0/ T1OS O/ T13 CK I
R C1/ T1OS I / CCP 2
R B 4 K B 10/ AN 11
R C2 / CCP 1/ P 1A
R B 5/ B I 1/ P G M
R C3 / S CK / S CL
R B 6 /B I2 /P G C
R C4 / S DI / S DA
R B 7/ B I 3 / P G D
R C5/ S DO
R C6 / TX / CK
R C7/ R X / DT
V SS
R 5
240Ω
8
JP
2
D3
1N 4 001
R 7
1 Ω
1
1
1
2
2
JP
2 3
JP
2 4
5 +
3
C7
100nF
19
2 0
R 6
240Ω
R 9
240Ω
2 1
TR 2
TN 2 106
JP
2 9
I C4 b
MCP 6 04 P
JP
2 8
3
JP
1
2
2
3
3
2 9
C8
C9
12 pF 12 pF
2 6
3 3
1
1
2
2
2
2
3
3
3
3 1
HDR 3 6
2 3
2 5
2
1
2 5
JP
3 2
X 1
3 2 . 76 8 kHz
2 4
1
1
JP
18
2 7
JP
15
17
JP
1
3 0
16
2 6
7
R 8
1 Ω
L ED1
G reen
3
JP
I C4 a
MCP 6 04 P
2
3
2
1
–
6
1
4
–
2
3
1
+
1
HDR 5
10
Op amp
sub system
2 2
3
TR 1
TN 2 106
9
2 8
R D7/ P S P 7/ P 1D
R B 3 / AN 9/ C12 I N 2 – / CCP 2
3
2 7
R D5/ P S P 5/ P 1B
R B 2 / I N T2 / AN 8
2
2
2 2
R D6 / P S P 6 / P 1C
R B 0/ I N T0/ FL T0/ AN 12
1
D2
1N 4 001
G N D
3 2
HDR 4
1
1
10 +
1
9 –
3
JP
3 0
I C4 c
MCP 6 04 P
1
8
HDR 3 4
HDR 3 5
V SS
I C2
P I C18 F4 7K 4 2
(Fit in S K T1, a 4 0-pinDI P )
MCL R
HDR 17 HDR 18
1
2
3
3
4
4
5
5
6
6
7
7
8
8
R A0
R A1
R A2
R A3
R A4
R A5
R E0
R E1
R E2
S Y S TEM_ V
G N D
R A7
R A6
OS CO
OS CI
R C2
R C3
R D0
R D1
1
2
G N D
CP U
sub system
R B 5
9
9
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
2 0
2 0
HDR 3 7
12
1
+
13
–
1
P G D
P G C
10
G N D
L CD
sub system
R B 4
R B 3
R D4
R B 2
R D5
R B 1
R D6
R B 0
TD7
S Y S TEM_ V
R A4
G N D
R A5
R D7
R A6
HDR 2
R D6
8
R D5
7
R D4
6
R C7
R C6
P G C
R C5
P G D
R C4
S Y S TEM_ V
R D3
G N D
R D2
MCL R
oscillator can be turned off completely,
while the processor wakes periodically timed by the very-low-power 32kHz
crystal.) That requires just a crystal and
two capacitors. We added a 10µF bypass
capacitor on the supply rail out of habit,
this may prove to be unnecessary but
it’s good to have the option of one on
the board. Finally, there’s an LED to one
of the GPIO pins, as everyone loves a
flashing LED. You can see the original
application circuit recommended by
Practical Electronics | March | 2021
5
4
R C4
R C5
S Y S TEM_ V
G N D
3
R D0
3
R D1
4
5
S Y S TEM_ V
11
1
HDR 3 9
G nd
HDR 8
2
4
5
6
7
8
G N D
3
R D2
R D3
R D4
6
7
8
R A7
R C3
R B 5
2
1
14
HDR 3 8
W i-Fi
sub system
HDR 16
1
I C4 d
MCP 6 04 P
S D media card
sub system
9
HDR 6
7
10
11
12
13
2
1
6
3
5
2
4
1
R A1
R C5
R C4
R C3
S Y S TEM_ V
G N D
HDR 7
4
3
R A3
R A2
S Y S TEM_ V
G N D
2
1
Microchip in Fig.5, and compare it with
the final schematic in Fig.8.
Analogue subsystem
Extending the high-level design from
last month, we decide to add an analogue subsystem. This will be two
‘trimmer’ style variable resistors, connected to the supply rails. This gives
us two variable voltages, which can be
connected to ADC inputs on the processor. Not only will this allow testing
of ADC-software designs, but also it
can provide a useful ‘user interface’ for
some projects, such as setting an audio
frequency or a delay time.
Op amp subsystem
This leaves us with the op amp circuit.
Since it’s an analogue circuit on a digital board it caused the greatest amount
of thought. We want it to be general
purpose, but the range of circuit configurations for inverting and non-inverting
53
C2
V DD
R 1
V DD
R 2
V SS
MCL R
C1
P I C18 (L )Fxx
V SS
Recommended values
C1, C2
100nF, 2 0V , ceramic
R1
10kΩ
R2
100Ω to 470Ω
Fig.5. CPU subsystem (from Microchip
datasheet 2607031).
deep within the library part of the barrel
jack, as can be seen in the PCB layout in
Fig.6, is a routing profile. This calls for a
very small routing drill, as the hole measures just 1mm wide. Thankfully, this is
a normal process requirement for PCB
suppliers, and the resulting PCB can be
seen in Fig.7, with a perfectly created
plated-through slot. You must mention
the presence of this slot to your PCB supplier though, in case they miss it.
We have no need to add bypass capacitors on the DC power input, as the voltage
regulator circuit has that covered. You do
not want to add too much capacitance
on the power rails as at some point the
input capacitance will cause large inrush
currents when the supply is turned on,
which can introduce its own unique set
of problems, typically voltage spikes on
the power lines.
amplifiers is huge – even before you
start to bring filters into the equation.
In the end, we took the lazy (and most
flexible) approach – we provide power
to the op amp and added pads on the
input and output pins to enable you to
build up any configuration you (or we)
choose in future articles.
We gave this some more thought and
came up with the idea of an ingenious
(we hope) arrangement of solder pads
that will make constructing various op
amp circuits easy. A small prototyping
area around the op amp, with three pads
connected together, will allow for mounting resistors and capacitors around the
op amps while minimising the number
of wires.
We settled on the MCP604 quad op amp
IC, again from Microchip, to minimise the
component count. Time will tell whether this prototyping layout idea works!
The Servo motors, SD-Media, Wi-Fi
and SPI/I2C interfaces are just 0.1-inch
headers with no additional components
required. When it comes to connectors,
the multitude of headers on our board
are simple to implement as these are
standard parts available within the EagleCAD libraries. The DC barrel jack on
the other hand presents something of a
challenge if you have not used one before.
The connections to the PCB are flat tabs
rather than simple round pins, which
cannot be created by drilling a hole. The
flat tab connections will require a small
slot to be milled out of the PCB. Buried
So now for the more exotic parts:
n DC Barrel Jack
n Processor
n Crystal
n MCP2221A
n LM317
n FET, TN2106
n Op amp MCP604
Fig.6. DC Barrel Jack PCB footprint, from
EagleCAD library.
Fig.7. DC Barrel Jack footprint on a real
PCB – note the slots for the jack’s pads.
54
Finally, the schematic
Now that we know the required components we are almost ready to start
drawing the schematic. We still need to
check whether the components we want
are available within the EagleCAD standard libraries. We start by looking for
the common components, which will
certainly be already present within the
library, which are:
n 1/4W resistors in an axial 10mm
pitch layout
n 1/4W resistors in a radial layout
(might save some board space)
n Capacitors on a radial 0.1-inch pitch
(low-value parts)
n Capacitors on a radial 0.2-inch
pitch (high-value tantalum or electrolytic devices)
n Diodes, similar package to the
resistors
n Header pins, on a 0.1-inch pitch,
various lengths
n Standard, single-colour 5mm LED.
To our delight the MCP604 and LM317
were already present in the library.
The crystal was slightly harder to find
(we like the cylindrical wire-ended ‘watch
crystal’ format). Two parts were found in
the library, but the package name did not
match any part we could find on Farnell,
our favourite component supplier. In the
end, we temporarily placed one of the
standard library crystals on our board,
and carefully measured the dimensions
of the holes and the silkscreen outline of
the package, then compared these to the
datasheet of parts on Farnell. We found
a match and made a note of the Farnell
part number and the library designator
for the part.
Despite an extensive collection of
Microchip processors in the EagleCAD
library, with over 17,000 processor variants and more being released each year,
it was no surprise to find our particular
device – the 40-pin DIL PIC18F47K42 –
was not present. However, what we did
find was a PIC18F43K20 in an identical
package with an identical schematic
symbol. We will simply rename the part
when we drop it into the schematic.
Again, it was no surprise to find that
our choice of FET, the TN2106 in a TO92
package was not present. As an N-channel FET has a simple 3-pin construction,
we chose the first N-channel FET already
present in the library – a 2N3819. A
quick look at the datasheet for this FET
indicated that it would not be a suitable
alternative to use directly, but the pinout
is identical to the TN2106, so again we
will just rename the part name when
adding it to the schematic.
That leaves the MCP2221A IC. A quick
search on the Internet revealed a library
created, and publicly available, on DIYmodules.org – thank you! The library
file was downloaded and copied to our
EagleCAD library directory. As with all
third-party library files, we did a careful
check of the component’s design, double
checking pin connections and the dimension and positions of holes. It’s an
important step, but thankfully reviewing someone else’s component design
is a lot easier than creating your own!
So, through a combination of luck and
searching the Internet we have found all
of our required parts. Armed with these
and the circuit subsystems, we can start
to draw the schematic, pulling in the
components we have identified. We start
with the power supply section, then the
CPU subsystem, USB IC, op amp, FETs
and finally the headers. The completed
schematic is shown in Fig.8. Note how
the schematic does not resemble a PCB
layout of the components; instead, we
keep the design in a logical block layout,
as this simplifies reviewing the parts and
the interconnections.
Practical Electronics | March | 2021
Fig.9. Initial PCB design view.
These correspond with the industry ‘default’ values and will therefore be the
cheapest option available. There are
many other options to choose from, but
for PCBWay and JLCPCB, these other options can be left at their default.
Five days after placing the order, the
package of boards shown in Fig.12 arrived
– at the same time as the components.
Assembly and testing
At the end of schematic design we
switch to the PCB layout stage. EagleCAD creates an internal datafile
called a ‘netlist’, which is a formal
description of the parts used and the
wiring connections between them. When
the PCB editor opens for the first time,
it shows the collection of parts on the
left, with an outline for a default PCB,
as shown on the right of Fig.9, which
measures 160mm × 100mm. It’s clear
that these parts will fit a PCB of this
size, but the number of interconnections
that we are required to manually route
for signal connections looks daunting!
The task becomes easier as you place
components in their approximate intended
positions. After a few hours we arrived
at the component placement shown in
Fig.10. Not too compact, yet we were able
to reduce the board dimensions down to
150mm × 100mm. Notice how we improved the legibility of the PCB by adding
helpful text and boxes to show some of
the subsystems. These additions to the
silkscreen content add no cost; it’s just
a question of how much time you want
to invest in adding and tweaking details.
The routing of the signals themselves
was a process of first connecting up all
the power rails, using nice thick tracks,
taking short routes between components. We spent an hour hand-routing
the data signals, and then allowed the
autorouter to finish of the final track
routes. The end result, with the top
layer shown in red and the bottom layer
shown in blue can be seen in Fig.11.
Note that we have placed holes in the
corners of the board to allow for mounting the PCB. Plus, there is plenty of space
on the underside for adhesive rubber feet
to allow the board, once assembled, to
rest nicely on a desk. Adhesive rubber
feet can be found in DIY hardware stores.
PCB type
2 layer
Silkscreen Colour Green
PCB thickness
1.6mm
PCB finish
Hot air surface levelling
Now for the fun part – assembling the
board. We assemble one subsystem at a
time, testing each new subsystem as we
proceed to simplify debugging. The boards
will have had a simple electrical test after
manufacture, so there should be no shorted
traces or open circuits – any issues with the
board after assembly will be caused by us!
It’s worth noting at this point that it
is rare for a PCB design to be successful
on the first iteration. In our professional
Fig.10. PCB component placement.
PCB sourcing
When sourcing the PCB from a supplier,
we had some PCB parameters to choose
from. The key points were:
Practical Electronics | March | 2021
Fig.11. PCB track layout completed.
55
Fig.12. Real PCBs!
experience over 35 years, this has never
happened. ‘Unsuccessful’ has quite a
broad range of definitions of course,
ranging from ‘it catches fire when we
apply power’ to ‘the font used on the silk
screen text is incorrect’. What might be
a failure for the likes of Apple may well
be perfectly acceptable to us. Now is the
time to find out!
Visual inspection
The first thing we do, before soldering a
single component, is visually inspect the
PCB. There is a fairly standard checklist:
n Are the PCB dimensions acceptable?
When designing a board, we sometimes need it to fit in an enclosure with
precision. We check that the PCB has
the correct outline and any slots cut
as specified. This is not an issue for
us, as we are not fitting the board into
an enclosure, but it’s worth checking
that the dimensions are correct, within
tolerance, as it confirms the quality assurance of the manufacturing process.
Errors in something as simple as the
board outline could signal more concerning issues later on.
Fig.13. Silkscreen print detail.
56
n Are all the silkscreen details pres-
ent? This is something that you can
get caught out on when designing a
board. You may put text or graphics
on a particular layer, but then forget to
include that layer in the Gerber pack
you send to the manufacturer (happened to us more than once!)
n Are all the silkscreen details legible? It’s
too easy to specify thin text or graphic
details that look great on screen, but
look terrible with the manufacturer’s
process. It’s not an exact science and
difficult to judge when you are looking at a perfectly rendered design in
a CAD package.
n Are all the holes and milling profiles
aligned? It’s possible that the centre of
the drill holes may not line up with
the PCB pads, either because of poor
manufacturing tolerance, or a misinterpretation of the CAD data (PCB tracks
and drill positions are held in different files, in different data formats.)
n Are all the holes and milling profiles
suitable for use? Sometimes, component legs may be thicker than expected,
and will not fit in the holes. Connectors with wide flat pins – like our DC
power jack – require milling rather
than drilling. Did the manufacturer
spot this, and are the dimensions OK
for your actual connector?
Once these checks are complete, you can
relax a little.
When we examined our board, we
spotted one small issue – the header
pin interface HDR8, on the top right of
the board, does not include the text ‘WiFi’, to indicate the module intended to
connect to it. This is a very small point
– people using this board will know the
purpose of the connector, and the Wi-Fi
module can fit on only one header – but
it’s an annoying omission. The silk screen
layer on the PCB is our ‘canvas’, and at
no additional cost we can print whatever
we want on it, so to miss printing something that is useful is regrettable. We will
correct that in the final PCB design. Our
smallest silkscreen print detail, shown
in Fig.13, came out very clearly with all
text visible, so that’s a plus point.
Now we can look more closely at the
manufacturing detail, with the aid of a
magnifying glass.
Are the drills nicely centred in the pad
holes? By this we mean, is there a good
amount of copper around any throughplated holes?
How well is the solder-resist aligned
with the pads? In our design, where all
components are soldered manually, this is
not an important point; but with surfacemount components, a poorly aligned solder
resist print could mask parts of pads which
should be clear. As you can see in Fig.14,
there is an offset in the solder resists outline, but it is within the manufacturer’s
stated tolerances and causes us no issues.
Then a second issue was found – the
holes for the MicroSD card holder have
the card entry slot pointing inwards,
not away from the PCB. While this will
work OK, it is not what we had intended. That was a simple design error on
our part, and rather surprising too, as
it was a point we thought about during
the design. Not sure how that slipped
through, but that is why we prototype,
check – and check again.
Initial assembly and testing
We build the power supply section first,
perform a quick continuity check across
the supply pins, then apply 9V DC input.
We measured 5.3V without the header
fitted, and 3.4V with it fitted. Current
consumption (without any load at this
stage) is 5.7mA, which is almost exactly
the current through R1, R2 and R3 – as
expected. We can now fit the power LED.
Next, the CPU subsystem – just the minimal parts: the IC socket, the PIC debug
header and the CPU. Using MPLAB IPE
Fig.14. Solder resist layer (mis)alignment.
Practical Electronics | March | 2021
www.poscope.com/epe
Fig.15. At last! – we have a built PIC Development Board. It’s not yet fully tested, but so
far it looks very promising.
we connect to the MCU. After confirming the device can be read, we proceeded
with fitting the remaining CPU subsystem
components (MCLR pull-up, capacitors
and the user LED) then checked the PIC
could be read again. Current consumption rose to 16mA, due to the processor
running ‘blank’ code.
FETs next, followed by the USB IC
and the op amp. A recheck of the current consumption shows no significant
increase, so we finish off by installing
all the 0.1-inch-pitch header pins, and
the four header sockets for the Wi-Fi,
USB and SD-Media interface boards.
Now we can test a peripheral. We start
with the easiest, a servo motor. The interface works, and with two plugged in
we check current consumption. An extra
20mA at 5V, and no significant heat increase from the regulator, even without
a heatsink fitted.
The USB interface was a joy to test
– we do not have a USB software stack
to mess with, as the MCP2221A IC provides us with a UART interface to the
processor. We simply enabled the UART
interface in software, mapped the UART
RX and TX signals to the correct pins
(as shown on the silkscreen) and success. So easy, and cheaper than buying
an FTDI USB-to-UART cable.
The Wi-Fi interface was validated by
routing the Wi-Fi’s UART interface through
the processor and out to the USB serial
interface, making the processor appear
as a ‘pass-through’ wire. With a terminal program running on a PC, we were
able to send AT commands to the ESP-01
module. Another subsystem ticked off.
Testing the other subsystems – the
Micro SD-Media interface, the analogue
and op amp circuits – will have to wait
until next time, but so far things are
looking great for the first revision of the
PIC18F development PCB.
Practical Electronics | March | 2021
Summary
In our next article we will cover the software side of testing, as this will introduce
the MPLAB-X IDE, and the MCC Code
Configurator tool, which simplifies the
setup of the drivers for the various peripherals on the microcontroller.
We will also present the parts list
and PCB ordering details once validation has completed, so you can follow
along with your own PIC Development
Board hardware.
- USB
- Ethernet
- Web server
- Modbus
- CNC (Mach3/4)
- IO
- PWM
- Encoders
- LCD
- Analog inputs
- Compact PLC
NEW!
5-year
collection
2015-2019
- up to 256
- up to 32
microsteps
microsteps
- 50 V / 6 A
- 30 V / 2.5 A
- USB configuration
- Isolated
PoScope Mega1+
PoScope Mega50
All 60 issues from Jan 2015
to Dec 2019 for just £35.95
PDF files ready for
immediate download
See page 6 for
further details
and other great
back-issue offers.
Purchase and download at:
www.electronpublishing.com
- up to 50MS/s
- resolution up to 12bit
- Lowest power consumption
- Smallest and lightest
- 7 in 1: Oscilloscope, FFT, X/Y,
Recorder, Logic Analyzer, Protocol
decoder, Signal generator
57
|