Practical_Electronics-May_2019

([email protected]) #1
The current version of MPLAB X
IDE is v5.15, other versions close to
this should be compatible with the
project source files we will provide
on-line. Installation is straightforward,
and typically you accept all the default
settings offered. Once the IDE installa-
tion completes and you have clicked
‘Finish’, your web browser should
open several webpages on the Micro-
chip website. Select the page titled
‘MPLAB- XC Compliers’ and select
the ‘MPLAB XC8 Complier’ download.
Installation is again straightforward,
accepting the default option present-
ed. Once completed, installation of the
compiler will be automatically incor-
porated into MPLAB IDE – there are
no additional set-up steps required.
Besides the software installation you
will also require a PICkit 3 or PICkit 4
debugger device to load code onto an
actual processor. Bear in mind that on a
device of this size, debugging software
(i.e., single-stepping through each line
of execution) is not possible without
an optional adaptor board. As our pro-
grams are going to be very small, and
very simple, we have decided not to
worry with this additional cost.
Do download the datasheet for the
PIC10F200 family, which can be found
here: http://bit.ly/pe-may19-mc2

Power of C
The assembly language instruction set
of the PIC10F is very similar to other
PIC processors you may be familiar
with, including the PIC16 and PIC18
products. For the most part, however,
this will not be relevant, as we will be
developing our software in the high-
er-level programming language ‘C’.
We will demonstrate how efficient
the ‘C’ compiler is, and what tricks we
can apply to improve that efficiency
when the compiler converts our code
into assembly language. While there
are only 512 words of Flash memory,
the efficiency of the PIC microcon-
troller architecture means each one of

those words can
hold a complete
single assem-
bly instruction.
Most instructions
occupy a single
word of memory.
‘C’ language pro-
gram statements
can occupy be-
tween one and six
instructions typi-
cally, depending
on the complexi-
ty of the particular
instruction.

Our first project
For our first project we will attempt
to create the ‘smart power switch’ de-
scribed above. The circuit for this is
shown in Fig.4. A relay will be incor-
porated to allow switching of higher
voltage circuits, but we recommend that
you do not attempt to do so on Vero-
board or breadboard. The IRL510 FET
is powerful enough to switch 1A loads
directly, so the relay may well be op-
tional. What this circuit could be used
for we’ll leave to your imagination! For
lower current loads the FET could be
replaced by a simple NPN transistor.

In summary
If you think this device is only for
novelty functions, think again. It can
provide valuable services as a sub-set
of a larger circuit (just as the venerable
NE555 timer chip has done for decades.)
The author has just completed a com-
mercial project where the PIC10F200
was the central microcontroller and
has been deployed in the thousands.
In that example, the code space used
by the application was just 80 words,
35% of the available space, all written
in ‘C’. This is a device that is definitely
worth taking seriously.
While these parts are readily available
from the usual electronics distributors,
such as Farnell and RS Components,
delivery charges may be significantly
higher than the actual device costs –
these chips cost as little as 50 pence.
eBay and Amazon can be a good source,
however, just take care to check on
the postage and packaging fees. Also,
be careful to order the correct part


  • the plastic DIL package version is
    PIC10F202-I/P, while the six-pin sur-
    face mount part is PIC10F202T-I/OT.


Next month
In Part 2, next month we will look at
how the ‘C’ compiler within MPLAB can
be configured to reduce the code space
used, build the first circuit and explore
the code required to bring it to life.


  • USB

  • Et hernet

  • Web server

  • Modbus

  • CNC (Mach3/ 4)

  • IO

  • up t o 256
    microst eps

  • 50 V / 6 A

  • USB confi guration

  • Isolat ed

  • up t o 50MS/ s

  • resolut ion up t o 12bit

  • Lowest power consumpt ion

  • Smallest and lightest

  • 7 in 1: Oscilloscope, FFT, X/ Y,
    Recorder, Logic Analyzer, Protocol
    decoder, Signal generator

  • up t o 32
    microst eps

  • 30 V / 2. 5 A

  • PWM

  • Encoders

  • LCD

  • Analog inputs

  • Compact PLC


http://www. poscope. com/ epe

PoScope Mega1+


PoScope Mega50


1
2
3
4

8
7
6
5

NC
VDD
GP2
GP1

GP3
VSS
NC
GP0

IC1
PIC10F202

External
control
circuit

Relay

C1
100nF

R1
330Ω

R2
1kΩ

R2
10kΩ

TR1
IRL510

V+

V–

D1
Green

D1
1N4148

S1

Fig.4. Our first PIC10F202 project schematic
Free download pdf