Vous êtes sur la page 1sur 3

DIY

MicroProcessors
By A A Mockford, G8ZGK'
AV E YOU EVE R
sta rted a p roject
then found that the
functions required
were not re adily
available from the chips that you
could buy? Have youhad to abandon a proj ect because the
numberol logic chips orl he board
size became unmanageable?

lf

THE ONE CHIP MPU

'"

A N EMBE DDED M ICRO


CO N TR OL LER o r one-Chip
micro-processor (MPU) cou ld be
S R80/NT
the answer. They otfer amateurs
an ideal medium to design, exe 1'182
periment and trytheir own unique
9 1'181
ideas . To gel sta rted with microII 1'187
processors requires less design
17 RAn
knowledge than analogue or digital hard wa re de sign.
RA'!RTCC
There is a range o r o ne-chi p
MPUs readily available.They are
t<l 1'18'
relatively cheap. simple 10 program and use, and are lully
11 Res
RA2 1
backed by developm ent equipLEa 2
ment and manua ls. Wil h one
12 Res
MPU ch ip you can design and
build any logic circuit you desire.
Just a few exam ples of ci rcui ts
tha t can be constructed using Fig 1: Simpl e microprocessor control 01 LEOs using ewne nee.
MPUs are lis ted below :
thing and try it again, all withi n two minu tes. It
Controller for an an tenna switc he r
can
be reprog rammed thous ands of times ,
LED driver
there fore is ideal lo r develo pme nt. No UV
PLl controller
e rase light is needed 10 wipe the me mory. In
Keyboa rd controller
fac t a project can be d esigned developed and
Serial com mun ica tion unit
put into ope raficn with jusl one chip cos ting
Very few othe r components are require d to
less than 6.50 .
make the MPU ope rate.

, '"

,, '"

,., " "'"


"'"

"

PIC MPU. 16C84


ALL PARTS DESCRIBED in this article may
be obtained from anyM ap lin store. The MPUs
desc ribe d he re are from Microchip 'tecnnct ogy Inc and are part of lhe ir PtC range. Th ey
have been available fo r several years and the
ran ge is sloWly being added to. Microchi p
also supply cost effective, well eng ineered
and well doc ume nted d evelo pment systems.
Ther e are seve ral MPUs in the PIC ran ge
offering diffe rent speeds, numbe r of conne ctions and different facilities inside. The par ticular PIC MPU, 16C84, d escribed in lh is
arti cle has an EEPROM memory. You can
program it, try its ope rat ion , change som e47 Ken.rulls Close. HIgft Wycombe. 8ucI<s. HP ' 3 m N

RADIO COMMUNICATION March 1995

D ESIGNING A PROJECT
TH ERE ARE FOUR STA GES to go throu gh
to make any MP U do what you wa nt it to do.
1. Wr ite the instructions lelling it what to do.
2. Loa d these instructions into the MPU .
3. Put the MPU chip in a ci rcuit.
4. Test its operation.
(Repeat steps 1 to 4 until satisfied wil h the
result)
To take mese steps in tu rn:
Ste p 1. Writing the instr uc tions is easie st
done on a PC com p uter, using a text editor o r
word processor. Embedde d mic rocontr ollers
are small MPUs that can not usuall y be expanded to biggermemoti es, their ins tructions
are written in Low leve l assembler language.

High level language s tike Basic ,


Algol a nd C a re gen era lly, not
very efficienl on these sm all controllers . If you wish , yo u can pla n
the inst ruct ions an d writ e then on
a writin g pa d. then type them into
the PC later. T he PIC 16CB41anguage is very simple. It is called
the 16C84 assembler lang uage
and consists o f only 3S different
ins truct ions . To write a prog ram,
you use the ins tructions in the
manual , one after the other, so
that the MPU obeys them one at
a time . The manuals are incl uded
in the Picstart168 developme nt
sys tem and give all necessary
de tails of the hard wa re and software pa rameters of all the PIC
MPUs.
Ste p 2. Lo ading the instruct io ns
into the MPU req uires a PIC prog rammer. This is includ ed in the
Prcsta rt- 168 develop men t system . Thi s will cos t abo ut 170 ,
but it may be reused lor an y
numbe r of p roject s. Maybe your
LEOI
-,
local c lub would consi der p urchase so a ll me mbe rs could use
it. It con nects to the PC computer
an d is supplie d with manuals ,
po we r supply, con necting leads
and software. You plug your PIC
16C84 MPU into the Plcstart 168 sock et,
then use the PC keyboard to ten it to load the
MPUwith the list of inst rucli ons. You w ill need
a PC with a se rial port , and prefer ably a ha rd
disk, ie practically any 286, 386 o r 486 PC .
The Picstart -168 has no requireme nt lor W indow s, addition al memory or a colour screen.
Step 3. The PIC 16C84 has 18 pins , of wh ich
13 c an be used fo r inp ut an d ou tput purposes .
Fig 1 sho ws the PIC 16C84 ina typical circuit.
It has three switches as inpu ts. and 2 LEOs as
o utputs. Very lew other com po nen ts are
needed to make it work. Its 13 pins can
sou rce o r sink up to 20mA each , so it can
d rive the LE Os dir ectly. Pull- up resistors are
not necessary on the input s as some pins can
have me se interna lly. For applications whe re
acc urate timing is not necessary a simple
ca paci tor and resistor will operate the onboa rd oscillato r. If your design needs acc urate generation of pul ses or timing, a cera mic
re sonator or crys tal can be used with the
oscillator, as sho wn in Fig 1. A stable 5 von
supply is requ ired. T his is eas ily supplie d by
a 78 05 regulato r. Th e low po wer type is ide al
as the PIC t6e84 uses less than 2mA , ma k-

67

DIY MICROPROCESSORS

"~

"."

1arrss
"""'''Ii''''ptII1ll,,,,",

.." .

00'0

iqlt lO/l
por!A.'a l

:ilislow'.tu<nl/le LED1""
,. is hogI1. M'rl t'loLEDI 0"

""

.1uml/leLED I ""

'"
'"enss
00'0

",nlIO/l
",nl2

00'0

"",, ",

:is lne rtl~we po" "9> <lI' '''

""'"
'" .,,,

:Ilislow, tum1lle LED2""


;!lIS t>9'. M'rllhe LED 2011

00'0

;goNdl 101l1tlS/1ns1tv:t>Oll

00'0

<"~

p(II\A.ral

:is 1l>e rl>l'SW A "", ~ 0I '"

-"-"""

'" .,,,

.tvm IN LED2""

Tab la 1: A a,mpl e I' at of Inal tUCUons to tern LED 1


& 2 on or oft in respo nse 10switches A & 8 in Fig 1.

ing it perfect lor ba tte ry powered equi pmen t.


Step 4. Wh en you decid e the need lor me
d evice, yo u nee d top reparea we ll defin ed list
of the Ihing s the unit will do (and not do). It
sounds ob vious, but the le sling is to e nsu re
that eve rything on the list has bee n achieved.
no more an d no le ss. Micropr oce ssors a re
simple be asts and do exact ly what they are
tol d to do. The d iflerence be tween wh at wa s
mean t to happe n an d wha t act ua lly happens
is c a lled a soft wa re 'b ug'. Bug s ca n be ha rm lessor stop the uni t trom wor king co mp letely.
the refore testing every func tion 01the uni t is
ve ry im port ant, Once w nnen and de-bugg ed.
the M PU will continue to obey its ins truct ions
perlectl y every time.

THE PROGRAM
A SI MPLE LIS T of ins tructions is sho wn in
Table 1(a p ro gra m) 10tum LEO 1 and 2 on o r
off in response to swit ches A and B in Fig 1.
W he n the s witches are closed, 0 vol ts or low
on the MP U input pins mak e the o utpu t pin s
high o r +5 volts, and the LE Os a re on . Th e
inst ruct ions a re obeyed one a ller the other.
So me ins tructions are identifi ed by labels that
may give so me indication 10 their p urpose
and a llo w a ju mp o rGOTO to that inst ruclion .
So me ins truc tions check the state of so meth ing. e g a high or low voltage on an input pin,
orth e numberin a registe r. Other ins truc tions
change things, eg t he num ber in a reg iste r,
the voltag e senrtc an output pin , o r the next
instruction to be obeyed. After each instruc tion a p lain languag e note ha s been added
afte r a semi colon , to exp lain wh at the instruc tio n is doing. Good p rog ramm ing is nor mally
writte n in small modules (typ ica lly , no more
than 100 ins tructions), an d includes ma ny
comments. This he lp s w ritin g, tes ting and
changes w hich often a re req uired a t a later
date.

SIMPLE APPLICATION
T HIS IS A S IM PLE application an d is idea l to
start learning abo ut an MPU. Each BT FSS
(bit test , skip if set) in struct ion makes the
M PU loo k at a n Input p in (Irom a switch ) and
e ither do the next instruction or the next but
one (skip o ne instruction]. In this way t he
M PU can make decis ions a nd ca n take different ac tions b y Skipp ing the ne xt in structio n. In
this examp le the different actions a re to turn
lhe cor responding LEO on with the BSF (bit
set ) instruc tio n, or oil with the BCF (b it clear)
ins truction. BSF m ake s the outpu t p in go hig h
to +5 voll s, a nd BC F ma kes it go low to 0 vo lts.
Wh en all the instructi o ns are ob eyed , the

68

...

....

MPU s ta rts to do the m a ll ove r again by


Inl lruC:lion
returning to the light 1 label. Be cau se the
BTFSS
e xam ple is usi ng a crys tal at 4MHz, each
""",~ :isthorb4-SWA pn h9' OI lOw
instruction takes 1llStowo rk.The refore when
porIA.ral ;it isktw. lJJm IIIeLEO 1 on
a switch is ope rat ed, it may be up 10 1OilS
BTF55 " ',", :istnertMWB il"Il'!igIl <ll' 1Ow
be fore the BTFSS question is as ked and the
ess
;il is ktw, Ium lI>o LED 2 ""
LED respo nds. Th is de lay is not norm ally
notice d, so re sponse a ppea rs to be instant.
B1FSC """,", ;IS t'lortMmCl"" hog/'I lltktw
Th is example doe s not need e xact timing so
00'0
;ilsNghSO OllOO....
an R-C oscilla tor co uld have been used ,
ecs porIA.ral lISktw. so IiAA LED 1 &2 o/j
saving o n cos t and c om pone nts.
The example shown in Table 1 uses etev en
oom 1.. ~t1
~ bad< '" 1$1 0'I$1tv:t>OIl
ins tructio ns , the PIC 16C 84 ha s spac e insi de
lo r up to 1024 instr uctions. In addition there
Tab le 2; 8y changing Ul e Inllruc lions, shown In
a re a furt her 64 m em o ry locations for data. a
Tab le 1. the L EOs 1 or 2 wli l ialch on wneeever
counter that can coun t the internal osci llator
switch A or 8 ls clo&ad.
signal orthe signal com ing in on pin 3. and 15
other ge nera l pu rpo se registers. The e xamseque nce through the inst ructi on s continues
ple in Fig 1 uses on ly tw o of the general
a s before. An exam p le is given in T abl e 3.
pu rpo se reg isters po rtAandportB. These are
the actua l inpu t and o utpu t pins on the chi p.
SOFTWARE SIMULATOR
Onl y 11 instructions were used and lo ur d if
Ierent one s fro m the 35 pos sible, so there is W H EN YOU WR ITE many instructions there
are ma ny oppo rtu nit ies for a bug to be inplenty of opport unity to use this controll er chip
lor qu ite co mp le x cont rolling functions.
cluded, so me tim es many bug s. To assist
By chan gin g the inst ructions as sho wn in
tes ting. a 'so ftwa re simulator' is included in
Tab le 2, the LE Os 1 or 2 w ill latch on whenthe Pic sta rt-16Bdevelop me nt sys tem . Thi s is
a PC simulation of the PIC 16C84. By loading
eve r switch A o r B is closed. The y will rema in
on unti lswi tchC is closed, this willswitc h bot h
the instructio ns to t he simu lato r p rogr am inL EOs oil again. It is very easy theref ore. to
stea d of to the Picsta rl progra mme r, it is
po ssible to see a ll the reg iste rs and int ernal
change the function of a unit by a softwar e
change witho ut having to change a ny narc- ope ratio n of the PIC 16CB4 an d to step through
ware.
the inslructions o ne at a time . Thi s enable s
O ne impo rta nt fea ture of the 16C84 conyou to see each re gister and the cha nges, at
tro ller is an 'in te rrupt struct ure '. Thi s enable s
each step of the p rogram . Th e simula tor
the MPU to respond im med iately to a change
software is included w ith the Picstart-16B
develop ment sys tem.
on one or mor e of its input pin s. For exa mple,
Tab le 1 constantly chec ks the state of the
An em bedded micr oc ontroller is a very
inpu t s witch es A a nd B a nd do es little else , so
adap ta blecontro lling device.Fig 2 ~
in this case. an interru pt rou tine wou ld have
sho ws e xamp les of a 4digit , 7no advantag e. II there were ma ny more insegment disp lay con nec ted to the
structions it cout d be some time bef ore the
PIC 16C84 , a high cu rren t 12V
q u e st i o n s
w e re
a ske d ab o ut th e
state of the inpu t
. '21,1
p ins. T his response
d elay cou ld be unaccepta ble in some
~
circuits wh ere tim ing
is critical.
B
I
I
B
In thi s case, an
in t e rr u p t r o u t i n e
-.5' 508 7
could be be neficial.
An interrupt wo rks by
the change on an
inp ut pin ca using the
ne xt inst ruc tion that
l a ""
wo uld nor m ally be
obe yed ,to be stored ,
( ' 0< '
4021
a nd a sepa rate set
O~l .
of instructions (the
in te rru pt instr uctions) to be o be yed
inst ead . It wo uld be
the interrup t in structions that would do
w hatever was nec ,,~
ess a ry. no w that the
1 2 1
change is detect ed .
4 5 , a
Whe n a ll the inter7 I 9 C
r up t in s truc tion s
e FED
have been obeyed,
the RETFIE instructio n re c o ver s the
sto red inst ruction . it
is o be yed, then the Fig 2: Microprocessor con lrol of a savan segmant displays u sing a keyp ad.

." '" -,.


<"

'"

,.

-""

I I I I

'.

1811 81181181
I

'"
,""

".

.'2V

'"'

'"
'"'

'"
".

'"'
""'

S>,':V 2'W

'"

"M ~ ,.
".

."

RADIO COMMU NICATION March 1995

I D E A S

FR OM

AB R OA D

HE EL ECT RICAL PROPERT IES

of nylon ro pe fo r guying. Fibre g lass is O K if


not st ressed beyond 20% 01 its rated br eak ing str engl h .
To redu ce the effe ct 01th e torq ue, an antiIw ist cro ssba r is used. It is a 6m long lube, of
the same materi al as t he boo m o f the a nten na, whi ch is rigidly boiled to the base p late
of the rotator. Guyed to two anchors , Fig 3,
this cro ssba r ha s the euect 01 incre asing the
tower c ross section a t the lev el of ma xim um
torqu e. Othe r, sm aller ant ennas may be
m ounted on me cross bar.

of the HB9CV can be found in


ea rlier a mateur publicatio ns [ 1J.

These also contain mechanical


designs for VHF and UHF and,
less frequently. for the higher HF bands J2].
The HB9CV is just as useful for 7MHz OX.

Homeconstruction was a challenge, which I


m etas desc ribed. [The m echa nical desig n o f

this antenna is applicable to other full-s ize


two-ele ment clos e-spaced 7MHz arrays.

Availablespacedoesnotpermitreproduction
of d etail d ra wings and photograph s - G4LOQ.

ROTATOR AND STUBMAST

SIZE AND WEIGHT

T R AN SL AT ED

T HE ANTENNA FIT S in a rectangle 012 1.5 x

BY

ER WIN

A ND

D A VID,

E DITE D
0 4 LQ I

5.5m. see FIg 1. An uncluttered assembly


are a al tha! size is re qui red, p referabl y nea r

the lower. Once

arcn. the

antenna has a

turn in g radius a! 11.5m ; make sure n coes r ot


infringe on you r ne ighbo ur's property. [In me
UK , the advice o f the local planni ng authority
sho uld be sought to avoid a pla nning application being rejected out 01 hand - G4L Qq
T he antenna eleme nts are made of d ura l
tubing; the boom is a galvan ized steel lube of
50 x 47 mm (0 0 x 10). as used fo r cemral
heating jnsteltauons: if the boom were to be
made of a lum inium alloy as well , a larger
d iameter wo uld be req uire d. Th e as sem ble d
weight of the antenna is nea r 60kg. Th e
m aximu m wi nd a rea is approx 2m ",
Fo r a rotary a rray ot this size, com m erc ial
ha rdwa re so ld lo r be am s for 14MHz a nd
a bove is def initely inadequate. The weights
a nd d imen sion s given will se rve as adva nce
19'57m

2~,,,,

S7m
21-27m

Fig 1; Gane rnl layout . nd no minal dlmen. lon s of


the 7MHI HB9CV. F6BXC gOI bllSl renulln wllh
element. 0/ BQual len gth end phae lng lines as
s hown.

lam p drive r co nnection , the connection to a f 6 key key pad , a se ria l sh ill register to prov ide eight
inputs, but using only th ree p ins on

...
Llltl

Inst....Cl II'

MIIIl

GOlO "'~

:11'" .. mulal" "",...1ope"t ,,,"


;inS!lucliGns l ~ll lIe ontjell
:< .pea lell~.

inl" rupl BIFSS portB,rb4 :is tbo rb4/SWA poll hiljh 0110"
~,
IIOM.. 1 :~ IS ""'. turn the LID t ""
m~
~,

IIOnB ,rb5
poMr.l2

:is the rb5ISWB pinhillh 0110"


:it islow. t,m tho LEO 2..,

8IFSC portB.rlit :is tho ,b6ISWC pm hillh 0110"


RElfIE
;~s hiljh SO ond "" ,nl"ru pi
OC, 110M .. ' :~S low SO 10m LEO , &2olf

OC,

RmlE

poM r~

:ond thoIIltt" upl

Ta b le 3: Prog ram u sIng Inte rrupt Instructions .

RADIO COMMUNICATIO N March 1995

A full-size 7MHz HB9CV beam is not


beyond the ability of the serious home
constructor provided adequate mechanical precautions are observed .
Daniel Caud roy , F6BXC described
how he did it in Radio-REF 10/93.
no tic e of the mag nitude of the p rojec t. II t he
lollowi ng guideline s are ad hered to, ho we ve r,
yo u will not ha ve to worry du ring ev ery ga le.
My beam has been up jcrtwo and a ha lf ye ars
now and has survived w inds up to 120k mlh.

BECAU SE COM MERCIA L AMATEUR rotators are inadeq ua te, a second -hand indu strial
m otor with a built-on reductio n gear was
used. 1/3 1/2 RPM is ebout righ t. If too test .
an additional reduction gea r m ay be used .
The ou tput shall, whi ch is d irectly co upled to
the stub mast , should be a t least 30m m dia.
The co nt rol box should pr ov ide a de lay to
prev ent the moto r f rom rev ersing d irecti o n
be fore the a nte nna ha s stoppe d co mp letely.
Wh e n the an tenn a is no t used, a servo,
co up led to a wind van e, park s the an tenna in
the posi tion presenting the m inimum are a to
w ind s over 4 0kmlh.

5 1o.Cm UI _ _

L o ,, ~r ' h..
c ma, t
""~ ~ario'>g
_ l.iPPf't anl!-1"osl

"..,.o;-'l

THE TOWER
FOR THE DESIRED LOW A NGLE radi ation ,
the antenna he ight sho uld be a t least a half
wave -leng th, te 2 1m. My tower is 16.5 m high ,
A se lf-s uppo rting latti ce towe r should have
a bott om sec tion of 70 o r 80Cm ac ross and b e
set on a concrete base of 2 m 3 [3] .
For a guyed lattic e tow er, Fig 2, a cross
sect ion 0135 - 40cm is suitable; it shoul d be
so lidly anchored to a co ncrete bas e 80cm
squ are and 50cm deep . lts guy s m ust ta ke
not on ly the w ind loa d o n the to we r and
a ntenna. bu t a lso the torque exerted by the
a nten na on th e tow e r thr ough the rotator. I
use 8 mm steel g uys , elect rically broken up by
egg in sulators; the gu y anchors a re app rop riately massive (3). 1must wam against the use

the MPU, an d an inp ut fro m a sw itch ed 12 V


sou rce.
There have been m any ca ses 01 b adly
designed m icroprocessors rad iating noise
ove r bands and d isrupting co m mu nications .
It is wort h n ot in g t ha t si ngl e c h i p
rrscrcccnncaere have a ll their hig h fr equency
swi tching elemenlsinternal. T here are nobus
and
lines to other chi ps to radi ate
noise , meretcre they are inh erently Quiet. The
co st of me Pic eren-tee is 170 incl uding
VA T from Maplins.

ccrwcr

COMPONENTS AVAILABLE
IT IS IM POSSIBLE in a few pages to p rov ide
an 'introd uction to progr am ming' co urse, howeve r, I hope that thi s arti cle ha s whetted you r
appetite to expe riment. All parts d escr ibed in
this a rticle m ay be obtained fro m any Map lin
store. The m ail o rde r addr es s is Map lins , PO
Box 3, Ray leigh, Essex SS6 a LR o r telephone 0 1702 5 54 161.11 you wi sh lotry you r

l.iPPf't Sh.cm.. ,l
~~a,...

Rol" tor

gvysl . ll

("9<' - -'V"

Fig 2, Oillgrsm of the g uyed tower, rotator , stub


masl, and sntl-twis l crossbar.

hand at progra mming PIC micr ocont rollers


an 'Aid To Easier Progra mm ing' d isk is av ailable from the author (se e bel ow ) that includes
many m ath s rounnes tnat ha ve been tr ied
and tested . It is m uch easier to use rou tines
that have been written and d ebugged than to
re-i nve nt the wheel. Th e d isk also inc ludes
seve ral useful prog ram m ing suggestio ns and
ha s a sim ple layo ut lormat to hel p you r lirst
attempts at p rogra mming to be succ essful.

NOTES
MICR OCH IP AND PIC are trademarkS cr
Arizona Microchip Inc . Diagra ms and data
ar e re produced by kind p erm ission 01Arizona
Microchi p Inc,

SOFTWARE AVAILABILITY
FOR THE Aid To Eas ie r Prog ram ming d isk
se nd a ch eque for 5 to A A Mocktord , 4 7
Ke ndalls C!ose, HighWyco mbe, Bucks HP13
7 NN .

69

Vous aimerez peut-être aussi