Professional Documents
Culture Documents
LMA) ဝင္းထက္ဝင္း PIC
LMA) ဝင္းထက္ဝင္း PIC
. ^.
a a \ /^r?a.
J U\-t-lr--A-rcJ\J
JJJ
^r
A
cobro$$o
AU J
e#&
J
{-r,:cl
r:lse:cog$ o'3$:bs3$$*:$to:{o:cce$gco-
r :be go$9o$cca6 j9 go3ogErbll$-
r:bsgrot5e'3coe:g6c:fgo
3cesgghgclbso &or:1ss:ccc:Tfee r:clbg$ee8see$: !{:bs:ce'g$ rS"6p-
r:bs:cel$ 'g"4,1}*-
iftoee'g$3o;ogog g,o:(o:cccllEco-
r:bs$g&goo3o- ph&
cce3b:3p ?Sfo"eE$ $cc:ce*g86g$gofo |.r:(uglrgco:lss:o8:gEos93$-
r:bsgoces$co 3ccc9co:pilS'$:bsr8:g $1eego g:ctb{e$ee 3{cEogcoee 6o$fl :3bF0-
rdr*c'c1osg$c83$g g$o:be:c8: ggo&r:[bs-
r:lssgcee$co 3ceesgoco:p:l$${p* :$co}rc869o:lss:c8:g:o$ee Fe$sesprbs:fpng-
r :be
EcrcesF* gb gco g ccSF? 3 t crca so
c'' h'rm * "",,mfr :T"?t# f ;hTf ft:l? _
ilss : :
$ $
eeo t :cleco g$ *ssccoccJ.$#S$ 1$:f#%;H-
u
@: f1t6l'bsg9 Sgoac k rccrlb rcorc goheeo$$ geFfl -
g
0*k ttr r
rr
@ 3l'to'$* :cee$g 3 h F0 8gg&qo
crcago tn?"$u3t.r rgu fo:tss: 3eo$$pSoe ? g t -
u
O gl't"'t* :oesscblc tF gc,ll bgl {nio$e h tlruguoo :pgm? g } i6:tss gfl F-f"e ? 3 t -
rr@3lto't* sc€s:clbg ;q$:]ee : $fp]:hr*"F! -
cxJJ:-oc,g
o
+ cncAa
.(
uaflq @oL
JVS Bo'L,2e
Frc qda6ca6@fiM
cKDg).a
-t%$-s"b cra
);j.6, + o3@ Prc Eo5o{oe$o6o o5i:qlodo3,?:(t)
oo$dc)
CodeDesigner IDE
1"11,
Q(r-J) We come to PicBasic Pro Compiler Demo Setup Wzard message box?
r-tr CodeDeslgn6r Lite r'? Desktop 6.>T€?3 Shortcut ,eQc8:S3:
,r"_l
Nompiu eamarie
ffi
T Aulo Clo:eil.mFis|urFdScrE n tl:5S€cs
3r6oT4:Gi6p%-e
^:ompiler ci -3!-+,0.;i compirer ci €
cS:q<l:6e{rye compiter pathname:
:oTcsceo{'2lr' emdd plcBasic pro Compite,
d
IP\PBPWOEI\IO.
rle Toolbar coT$ Device drop,down hst g
€€:alcsqoil6dn q(c9)c63 ercroreta
qp: (confsuration) @1ca3S:ee--:::a1 source
eo?i$6Giiotfia
---
r) CcdeDesisner I
$h@dSer'': f
Fr!!r:R tr.r n3r:rai t.a blrrrla a.r IEIJ coln=cted io RE
!
FBC
(6DyrasjLL l(:)
r. o6, cop9rioLE (cl 1ess,
Windows 95/98/[4E
C drive (C:\) €l5 toot directory c63{ear: autoexec.bat file ca8 search path c{r:o39c3
eo:qo1rl$r Autoexec oat 4 Notepad cidpo:
text eoitor c.rSqca8 edit o26e1o1o$r
(windows es *"ed{qi. msconris cA runq6$€dlo2irD
(4
8Es,{:GFd compiler line3?.?:<23 semicoon (;) @c:j cDdreS,.o,qdledn
eomn n PATH=CIWINDOWS;C:\PROGRA-I\[,]PLAB,C:\PBC
(o4
PATH=C:\W NDOWSiCIPROGRA-1\N4PLAB;clPBP
{cl. autoexec. bat file 14 edit e6E:6{..,5 c6Qqgo;:r{ restart o7 Sqcil eg) rr
Windows NT
Windows NT oBe path statement ct syslenr properties dialog box €i Environment tab
6%G€$3o1od, (lqqJtor"€rl deskiop c.JT$ ftay computer icon r'? right click
"oT€3
$6cQcfp: eroprties "
Environment tab .{ click cg8cQcAdlr SVstem Variables wndow 9
Path variable .A 60:qoso, cr,ck cy6$: highlisht of6.jlr +(o-e)q€@dolr variable g3.
?
ValLre bnboxes o?..Jel Pah info.mation 3?G3 aoT[e,,rcS3ppln EEs:c1:Qcp! compi]er
Value texLbox 3?+:6f epceS semicolon 1)@:$ cod.8E:c":6lotedr
eoo2 u %SystemRooto/o\System32\;CIPBC
(or)
%SystemRoot%\System32\ic:\PBP
Windows 2000/XP
(or)
%SystemRoot%\Syslem32\;C:\PBP
c
Fat:(r) codcoessne,rpE Pc io:.-q%;6{aD.a{:itoo!--3:Ep{9)
(9o8ql.6r n
PlcBasic compiler software g3. EPlc Programmer software 4.cf Plc
EcSa{%icD{c', ea1:q1c'dco3:qp: 3?Q3:G)o.e693.?,o)o1$or cD 9 pbc forder $3. ep c
folder o9.%€ co$e,-':coc,ia:p!rr pbc exe pbp exe, pbpw-exe, epicwin exe 9€. cdlite exe
4.cra: Hard diskol8?o>d: (eoer c:\) c63 instattcg6@:o>r:@Seqqdle$ D
-n$t)
MicroCode Studio IDE
1-crr {s1$:
:
-prck6io$iiD€7\ -ii!l
frt
vEl
1-
I il wM{eertt Fqd6)
=l
Desktop wlndow6oi[9 Start >> A I Programs >> lvicrocode Studio Fold$ >> Mrcrocode
Srudto exe tr9..Sa:E:6?c6 Microcode Studio exe .4 isht click $3J1" 6oTcvr€o' drop-clown lrsi
send To >> Desktop (create shortcut) .4 eg:qpS@: click c96o1rr {sao1 Dest<top eoTca3
9
N,,licrocode Studio uic:r, shortcut icon 6oTot6oc35.odn
Desktop 6()Tg I\licrocode Siudio shodcui .q double cticl cai,cQo5q91€ !(1 :) c23
€oTG-d:-d3rcr?6, Microcode siudio IDE desktop window GoTcu,co€el! 4Q e3,."T..;
6$6pg Maln lMenu , Edji Toolbar, compile and Program Toolbar lcD Toolbar, Code Explorer
l\4ain studio text editor o?.o1o€ @ ol 3)d n
Main studio text editor a>A! source code qp:.{ eqo:'$3opi work space o:61@3
cjb:pjrr ee1.cr:ogi source code sadL,*-,{ saeep3{1,Q@3. 6oTQ6o:dl3re! code -qF
oo:,-.$oB saeepSsaft:3,or:.4c'd: 338oE@1c6e6:nosrc39o5$3o:1o2!rr Hiehrishter optron
tab Font Propert€s, ltem Propedies 13. Reserved word rormatting eg:noS-.; {..{
%3
eo6 $3o1odr Q(t-s)"ee@d.]'
Ssecyorc$ source code ei font d1:oor:98. sSos3?o':.{ Font Propertres option
cA€eg,qjos$so1aragr ltem Properlies opton cBe source code :ac1:p1co:ro2) comment )
R;served Word, ldentifier, Symbol, slrng, Number, Assembler oi.mcari oe9€:a{1's:-,c{
eg,noS$Sola:elr Bod, ltalic, underlineu?$ styte c{copi:e6:qlosi3oileo,or2l
Resewed Word Formattins opuon €
r3:e:$.dE :co.:oJd oo:c:o,i:qP: (2oo'-
symbor, Poke) r{ uppercase, Lowercase oo2! od3i"-G$3"-,{t'G3. "OG*4-d4
eg, x,rs 3rc3e ot{ € dl a: e9 L,
varn ulnu 9 File.A click e3E: New.{ ctrcx o23c$cBea:r:aa1 header o69 r2i
:a$::ecaprf e oTc.:reoo$n { neaaer q3 Nlame, Author, copvright 9€. oate oo2)
oarJE.D.6qp: oloq@dld' Q(t-.)"a€@ddl, Header 4 ed og3opqJ€ erosram
pcader tab 4 es:qcSp: .rutnor t3. copytisht o?.ca edit ci6$3Jl-iil,, ,)(J-9)c?3lqid,jl
'
IIlCf,UDE "Froq!am.b6s"
comnre'
lnseffire' I rrosramne, I
",o)1:6oro,€o"d,
(go8qlc;rr r we.+stvl .{ PicBasic P.o complierGS.])' 3,3i:0tF3,jl Ddr)
suite
c\proqram tiler\mioorhip\Dp.sm suit(
I Fnd AutoMti.all? ll Fnd I'lan!alv,,
E ute [1PA5r4
lslpprerr
Ll5lpprerr PEc e\tensons
extensions e) nHxsr'l
ElLirrng file (,1tNNl85
I Cros' rererere Re
E care isibve
[- o"__l fr]dp I
ElLbthqr e (-1NHX85
ncase sentiilve
gaco.,5u1 source code r{ Btink bas ,{.cr" .r,rd@€. save o76c$sacgcE oeoTocS
Main lrenu $ as c{ ctict o26@ir EB save'ti&c$o$ fotdei r{eg:1<$@: save
File >> save
e6qolcdr' 4o9. save c93::$oa1 file extension ( pbc) olo€eoo blink.pbc a?86 save c'?6
eoc86.c$rr
{egao8 wtain Menu 6 Projecl >> comprte and Program .'? click o23c$rfqg3 error
o:6{o:69 e$,icn ,?(J--)Gco:lcrd window eoTcr::eoe$r o3:cg8 compilation success
86"@cer4 wndow o5eo:riag:ocSoc6.coc8.eo"pca€ Success: 103 words used c?6:;r
programmer o5 EPlcwin Programmer menu
--$,ft:@€,arTQe oe $r {Jeo? EPlc 13.
EPlCWin Configuration setection box4.oe9:oo?qr,? GoTor€co('dn
4oa1 EEo3i:qcia)d confisuralion settinss { EPlcWin configuration seleclion box
cg8eg:$,rSqolo$r
ile tarset processor
"ae -"i,GL'd
EPlCWin Programmer menu 93, Blink.hex
(Prc16F84A) 4.c{ c{acc\pc6€odos€'E:4,:G56r€c€: c G€{8ccladn {os1ca:)'@1
Q(J-cc) Success winaow, EPlCWin Configuration menu 5€. EPlcwin menu {.eollo:cQ
saa$:(q)
Using MPLAB with PicBasic Compiler
1-on $a1$:
- ir.::*opg.r
qg3 Browse. button .A click o73p: PBC exE $cc:; roTder .S'qrcSq.jl"dD
"f"pd
{egcr6.eppty button .{ cLick o,?38: oK button .{ click cf3q.jl6e9, 43,a;l MPTAB
rDE (Be PcBasrc r'? rangJage roorsrlgo bg:turf)o)?cDLg: lgo6o6c.r,.!p r
J:
"',i,1;)
u;,rg I":FLAB ri,rh p ce"s i cn,np:rer ptc
Edafi.Si6{.--r -.i,qr"":.J,ir,,(r)
I fl C:!ot'cUAr.'1FLEs\eU NK EAS
tF*.;l
t_.
I
?o o3:odo8:
PLc {d.6.8$@{o :qpo5o5:qp:(9)
t) TSesmenLDsplay
-4de)
7 Segment Display
E-"' {tl'
gl.?a$:c33 elc qda{%ico6oro.4e+:GL6: 7 sesment Display qp:ecJlc63
(disirs) +3. o.o?:qp: (characrers) QcoT$8+.{ 3,6o:86013GcDo'dl3)dn
"8i,.*$,cp'
{ sa@3 wr,ttiptexing Sd,{-"i,GE, or6oi:coo6$or 7 sesrnent Display qp:eoTcg8
cBQ:"m$:qP:e3. o.cQ:qp: +q,GEQ 3,6@.3:o?o)d, oreGcor,,jr 63r,3id,
B
G
E
c C
D D
DP DP
C
o
G F i\l A
E DC C DP
o
M
Displav o69ol9o8qp, oeqsacoa:QQ
Q(9-J) 7 sesment
c
D
DP
?(9
.)J common calhode 7 Segmenl Displav cDBi-D%3: LED qP:$o$:<D?:')
e${"il{o -?J-
1oo2 1e6
g-?n 7 Segment Program- A
MCLR
RBO
oscl RB1
RB2
osc2 RB3
RB5
R86
RP1 RPO TO PD Z DC C
DISPLAY DISPLAY
(-)
DISPLAY D]SPLAY
G)
{.8.6'',8: Q6''Tq36"r'd
Q(9 - g)oe€ -.5{e,p c8i:oor1:qp,c4+6oT6p%3 cDe:6red sesment qp: 93.{3er::
{;si",6q,cP,4 ?:Q6oTG cDr:,jt 3rd,
E 00'1111'11
B 01101101
00000110 01111101
@ @
01 01 101 T 00000111
@ @
0100111't 01111111
@ @
01100110 0110111 1
@ @
-"59.383,iqqJ6 pc
insrruction o)E?QG€.
3'dr
RAIM register cD6?cf PcL(Program Counter
Low) u?caTJloeqn
3?&):ecl RAIV register q1r:ci,33,o€ PCL %8cud: read or write o98{Ecr$r ecr
,?3 @Eq:or6eoi write q6qg€ Pc o5 lower s bits e,a!coe:: cGDS:cJ3S.:f, o{:Dd:ol
er2! {eQo3:oia3o:ein RoM addrcss sao69 eea,:cfo76:qo$ raouwr, srJBlrF, BsF
'
9€. noowF oerpi instruction qp:.{ PcL oa8 @3i:GG:, Pc o5o.liQ:o? 60o€:{3@o1a,dil
Pc 13. PcL 4..Do6r,$c{,ic{@do1 n
"o:c8olEooca€
Program Countet PCL R€glster
00A0 A0 (160)
0100 oo (0)
O3FF FF (255)
oolA 1A (26)
corts qp:c{ initialise e3E:6D3ral Pointer regrster (8 erac6ril instruction @3. zero
setr,ns cy6qdlce9N
c{ eL;le:co$<i1arg! rr
A B BesuLt
000
011
101
110
A tc. B q. o?qnc qc\,3 u l9o6t9cc:€%.qcoeall
9e
-3
aeo5qp:.4 3,.i,GL3ra)s}€1 boucins
6o?o5.?gul9:{1+;.C;"bo'0:
f.,?e1."4j,
tgtc\?oqora)e
CLOSED ...1--
SWTCH BOUNCE
; PROGRAM START
Ptc15F844
; PFOGRAM START i
AG-.c) ...$(s)a,e"oTc$oo5c"3'Q
B
3"
s!:(q) Lqu,d crystal Display(LcD) 1 Plc qo566€l6io oa:qloc3.\6:qP,(t)
-nlde)
Liquid Crystal Display(LCD) - 1
o-.. {"11
2x16 LcD modure 3?qp:9%3 :oc;Sosqq to5 (p,n) (rG)i olo€oloplrr {.er:6o:p!:
(.)"(re) .,.3 c.E("s)e"t"- 3?3-c"",8, !rd.8.'s-{,Gi.-.$.;r-d, eos+dr.S(.c) +3.
(r0)4.9r cJ,.333?cue:66p€ Oack lishtrnsF?q1.8 G8;l-d' Q(C-.)oa€ rco modure 3?{t:
3?aD:3"{Lo\ dloSQqp:4""t8-'8, eu::dc)c?3 zxto LcD modure $\ ro5lolo5qp:r€.
,D€:o?€fie5c4:oEqP:c{ coTocD.:o1Ddn
eo3(ce)1e€ rc3{tl1o6GXJ)r€i?)o?.od Q.3;o:6o3oo?e:sloacE sDi,&qqeosqp:
G6E, rc,54,jro5GXg)f31G)o?.3)d 3?dq:e05(?)iG6o,, efi,.i"E(e)e("e)",c3 eo6(o)i
of.op! e:o-,o9c8qp: G6@odn .DdNo5E:qdo$19,3.\ ..TG.l.p9'
"et'c{:oiqp,.i
r-+.1"6G).,? cG{dcq€: (0\493.oo6*csqE, i.3qdlo5(J)c{ Q.se]:3?Gol€:(+sv)
93. :o.fqcSqolo$r
r.61.1de)-d s:cu€::aeec€lconrrast; ,--.,ed,-sp,.{{i"o:ealQ.r,:
(vee).'?
c"d",r:€I3rdroS @6o1o3ir, ',ce .sv
se. cGq"S.q€'-@r: eocf]Jo6er:o$ o{:oo6
Qor€{t8o.o€rl :acu,;S9o39 qcg{8ol-p!r'
"i
o{;ea:. LcD 3adt:oa:cae vee c{ sa61d$.rl::(-zv)
3)o3€o:1o,c6,',13d,
{eio:,{c.,ae3.o)oc,53'i:0t3)d3,il vo rc3(e)
s
ype LCo :a{1:oo:ca3 back lght 3?c3.; olldl
.",q.,€€ -ri:0rlo,jr],d
@c?qlLo? or 6H
RS = 0 (lnsiruciion mode)
RS = 1 (Data entry mode)
1 Ground
2 vdd +ve suppty
3 Contrast
4 RS Register Select
5
6 E Enable
7 DO Data bit 0
8 D1 Data bit 1
9 D2 Data bit 2
10 D3 Data bit 3
'tl D4 Data brt 4
12 D5 Data bit 5
D6 Data bit 6
14 D7 Data bit 7
15 NC No Conneciion
16 NC No Connection
2x16 Lco .4
€c3a6%6@6cDr+3.o)od3,.i,,jGr3,,,Je:o5e8ci:ojqp:oi o3,3J3
o8c:.,6.i$3?ced +(3-J)'?36.J'''Gco":3)doo3c!6,c8 ,r2)eao:c6q.jled, 4oc8cD3,o?
"fi,xc8
a.5@.:r6?4-c'5o)G: o,>d€.o.q5$3dl3Jdr ""-4€,,ig4 8-way D rL (Duar rn Line)
switch Sdcoal+3:q.jl..ra)x sway D.lL swltch 6+9P%6 sub-mrniature hexadecimal rotary
swircrr
e6q:c{ 3?{:&dcud:6i$€,,t)d
Sub-m;niature hexaiiecimal roiary swjich qp:od 33{r:1Eo} fJ)ql:6J.rd,
oco6s{L:sro.:9: oN = 0 type @6@,r oN = 1 type GSdlc:air
1d--{paaD;p
.,.06-{1,*-,9" '0'6iep%39dc.a:qne
qoSsa:q, (r,2,4, s) ?3. n (conrmon) to5
c 3,@':cA; shoi' G6€qlOE:, "r" 9pca3"7p!o:::rs3 ro33'r:oi: 93. c og
open @3
.r@-d'
fc8or3,{t:3"6D:p "o'9epca3o9p)co::q1€ qds::r:q: (t, 2, a, 8) $3. n (ccmr,ron)
gc8 c a,@.,cae open G6GelOE:, 'r" 6{6p"?3eelco5,et€ eds"r:{: r€. c a:d short
Gs"+@-d'
,i(S-l--)"Se ocoosa{1:s,oc: oN = 0 type, sub miniature hexadecimal rotary switch
e6oi:c{ 3"ri:|qtco.:63, o6:"J3,rc3o,6:c4coT0cDr:S:r Q(3-j a)o3€ ro3or3,{[3eo,: oN = 1
type, sub-miniature hexadecrmal rolary switch $6oi:ci :a{:GFor:ee:r 05,rr6oc5or5:o? 6oTG
co.:dtQd,,
Hex switch ol5t3ra! eso,orq$:g uexadecima ocn$:or6qr{
'?cSoo,Gprd,, e"-,-
63o-,or$Q: $3s 4 set cjScQ::ei{alS ocoo hei iwitch ca€ ":" c{ set q8$:r qo3o hex
sw;tch %€ "8".{ set caEq<-rlc$r
6cac8 ss .43?"i;0toe:s:a1 bouncing GuJe.G6coTo'o53r03. -3,--, Q(3 e)c3
Debouncins switch <;06c.'6,,it"i ::.o:4,o6.,j1eldr (Debouncns syJrtch
".f|!-,-d
oo6c"6:o?3c!6Qci 016t1?6q:c,:co.:63r. %6Ql6oo5dodcosi:E6oca?3 €r5 o,qldfr(3o")
%3@d.jrD
o6:o6iqp:3rd write mode 4 oSoDco':E: e66.ore6dG66.,6@"€. rd4 dl
"3(c)
K/w c? uv(br\u) +c, crtcD$maDcD:eurcDr:6tor3)Pfl
,)q"odqo)€6po, vR1 Ge. 3'c.,€:/.cqq (contrasr) o?{id+3o1])eir vRi€15 E:
o:6oc6r,f qgoEcoc:eo5<oa9: aTKo flogo-::,5$ oeo13:c$3:93..Dd3cScD,:$3o13rd r (3,flc8
Q€:or36cQsa6er:: Lco module qp:3ace.t trl8:ci aTKa qogor,5d seqd{.rac:c$€:qt.
-"61.5 q,it
"2! ")
7 ttcDULE
PrN 6(E)
.jldlog€.{Eoa€ LcD op! g<ono: reset ::e@saeq@6eo: branked off t23 ocDe
olod, 4o"63:€4qr3 eea,cqp:.a coa;a€,e3,6cD$: +6or6",$eGe:('{c{ 46@3. LcD
r{ ot,t state ci.66pc66,€ insrruction @a:Go:1o1ee9n rnstruct,on qF,€@'€:oi G,-,(-l)
Binary
lnstruction Hex
D7 D6 05 D4 D3 D2 D1 DO
Crear OisPlaY 0 0 0 0 0 0 0 1 01
46?d ooicS ss(E) 4or6qtc8B6o?.Ari, Dispray ca3 cursor ])a!) uncertine @3. $o8o2o8
'
q&osG5qi.s 6,jlo,6o.36"od,, Q(r .r)"a€@aidl'
3,-l5,qJLS""Tl0ql.3
'&o:3qldG)s"oe.6
(c) Displav oN and biinkrnq cursor wiih underline G660€6-
Code = 00001111 ($0F)
51 to 58 = 00001111 ( or ) HEX-SW1 = 0; HEX SW2 = F
RS=0
E=1to0andthen1
f r) Functjon Set 12 li1e. 8-b l. sxTDixelformar
Code = 00111000 ($38)
51 to S8 = 00111000 (or ) HEX-SW1 = 3; HEX-SW2 = 8
RS=0
E=1to0andthen1
0 l 2 3 4 5 6 7 B 9 B c D E F
toDa Jnor l0l! s )r 0a IcI )l tc )llr t00c 100t 10 t0 l0l1 rll 1t4l I]IJ ll|l
0
-r00u
it I
l
lttl t'i
)n
2
r(
l.F |: I'
I
3 I
001 r
4 ._,t
I
5
Lll il I
6 f'I t! I tt -{ tt
)r rc
7
lrl I
la Ll r! f.r -.t -t..
:r II
I tt t.. !l
I
r00c
9 I t! I ,t
t00l 1 .J llr
t0i0
rl ri 1.! .L
lr'
rc
B
I q
l t- I
rl r it J'i*
C
t
I
.'|.
1
I
I
-l {.
1r0{
L.r
0 n'r J.
i'l I I I .t.
t-
t!
i!i
F t!
il tt I
o3,-3qla6(J)3e%d 3,.ari:qnSGoTEqlcS
RS=0
E=lto0andthenl
(J) Displav oN and bllnkinq cursorwith underline G66oqS-
Code:00001111 ($0F)
S1 to S8 = 00001111 ( or ) HEX SW1 = 0; HEX-SW2 = F
RS=0
(?)
Code = 00111000 (938)
51 to 58 = 00111000 ( or ) HEX-SWI = 3; HEX-SW2 = 8
RS=0
E=1lo0andthen1
to
51 to 58 = 01011010 ( or ) HEX SrVl = 5; HEX-SW2 = A
G?
sg:(J) Liqu,o c'ysrar D,sptay(LcD) i ptc qdsai,"le{,u, oi:qlodr:3:qp(9)
EtrEEEtrEEEEEEtrtrtrtrEtrtrE trtrtr8Etrtr88tr8trtrtrtrtr
trtrtrE8tr88trtr8trtrtrtrtrtrtrtr8 EEtrEEtrEEEtrEtrtrtrtrtr
20 Chabcler2 in€ (LMo32L)
trEEtrEEtrEtrEEtrtrtrtrtr
1€ Cha6dd4lne (SMCle40A OR LM041L)
EtrtrBEtrEEEtrEEtrEtrtrEtrtrEEtrEEEEEE trtrtrEEtrtrEtrEEE
trE tr tr 8trtr8tr EEtr trEtrtr EtrtrEE trtrF' E t,'E,G4 tr El I.i El t4 Et F;t Fl F;t F;t t;l G;t
o6:e>6qjc,3(?)o%c6 s'o?i:qn6GoT6ql.;
E:ga Clear Display lnstruction, Function Sel lnstruction, Display ON/OFF l€. Cursor
lnshuction o?,.8 og:6saoi€: setup e8qoled,r 4Gt.t cursor address .i 00010000($10)
ca€ set q6s$ 1OO1OOOO($90) c4coaldlr Cheracter Entry tnstruciion G663)r 00000111(907)
r{co2io1rr o€:o2! auto-incremenudisptay shift
"r,ioa63i,or6%o6{3:@<{saeqpcieg.r."r"
left instructrcn saft:saoc:@Soplrr {ei. setup o?Ep:c+,os' €<r>'d?)g "0" ro "9, 32q3.;
63ororqq:qprG6@6D 00110000 to oo111oo1 ($30 to $3s) c{ codaAS:@dqie
"""1,cp,-d e,."6-,si9 oo,e6oT-8, ( s 8 7 6 54 3 2 I 0 ) o?6rr,.,E3"oJG€.o,o5ocE3l.
,r6.i,il€: 6se.:@3idc{c%.q€o"d,
g:g. Function Set lnstruction, Display ON/OFF, Cursor lnstruction 13. Clear Display
lnsrruction o?..8 q:,is:{3: setup <\$qo]"a:r {ef,c8 cursor address 4 00000000($00)
qE set c93q$ Drsplay Address lnstruction 10000000($80) o?cDd,jlf,]d' oo5cDdd s"3i:q
$€sal ccRALa 6+rG)ics€ xc'::x"-, ci"SEer- ecp'4..18dq1 cao,' 00000000 to
00000111(soo to so7) 4.4 cDEiqlS,-dJl-dn e2!eeg.:a{1""1eo1qp, cgd.oTc.,'oo
:edr
OE (00001110) 4l s
7g p.
11 (00010001) 19 79
(00001110)
(00000100)
:>,c .TB
a4 4S
(000r1111) 1C
a4 (00000100) 40 fo
(000010i0) 4E 7E
i
11 (00010001)
!].
B
g"
o.;:(t) Liqli.l Crrstal Drsprav(LcD), 1 Flc qda4.do{M o.7'q1oo5-3:.12(9)
G)
code = 00111000 ($38)
51 to 58 = 00111000 [ or ) HEX-SW1 = 3; HEX-SW2 = 8
E=lto0andthenl
(r)
9J
,6al:(r) Lrqud crysrar D spray(LcD) - 1 F'r i.;.6€iofi€ o4:Xoo3o3:qJ',(9)
Codes = 00011111($1F)
51 to 58 = 00001110 ( or ) HEX-SW1 = 0; HEX-SW2 : E
RS=1
E - 1 to 0 and lhen 1(for each data entry)
cod313:$€c,)60,r.3)dn
oag(G)
Liquid Crystal Display(LCD) - 2
G-crr {e1{:
.16
lg:o.6ar3?6i:%a 2 tine x character (non backlit) €{fs?oc: LCD modute %€
ch qc:93, rota switch qD:.{
G3o-qP:oi cD ai-*i,+,,
+6or+d+c{ qc8qr:fe.oroa
-.Di
De5cription
Addrci: 5cl !p tjmc 140nr min
!Ah Address hold ilne 1oDs min
r0s 200ns min
IDH 2016 nrin
roA Dald ccuess ti e I
J20nq nrir
€H Enable hrgh lme rrme
I
rl50ns lnlll
IEL Enrhie lorr '-5 | 500ns min
tnf ili:c,;-.il:r'iir I
o$..4,,1ccd,€.6q8 one cycle time 9a = 1ps @6o1o$11 46@€. LcD 3?. o{$o6og2i,.
:ao3i'c63 r ri.l,o'] hslruclion {pu:d t m t,ior oata co.6qd .Q,q€6"j
G-?i BusY
prc16Fo4A
Q(G-J) 2x16 LcD modure 4 QctoficSEco{",$€.Aoc8mi:otQ
'1e
'dq:(G)
Liquid crystar Dispray(LcD)- 2 ptc idafic3io{c.- s,{:{odo3:q5,(t)
CbLCCii 0 xoc
ENDC
n.vlw 40h
..cfs z DeLayL, i
.le.fs: De Iatt, a
LcDins
bcf IORTA,.lcdRS qJii!e "instruc!ion"
calI clock
bsf PoRTA.lcdE
call clock
bcf PoRTA,lcdE
; 6fts delay between instructions
clrf Delayl, abour a 6ns delay 0 4MHz
(ovlw th
frovwf DelayH
crlp1 decfsz Delayl, F
decfsz DelayH, F
list P - 15F84a
lnclude " P]6fg 4 a. inc"
_conf ig h'3ff1'
CRYSIAL = 4MHz
I,CD RTI PIN IS TIED TO GROOND
PORTB 0 - 7 = LCD DATA PINS 0
Srrbol DescriptioD
1 Ground Vss
2 vdd Loqic supply vdd
3 LcD coNTiAsi Wiper of 5K pot connecied ber.
4 RS Regi sler se ectron RAo
5 RII Pead/firite Tred to GND
6 D E1:iil: :ta\ I
1 DBO Data bit 0 R90
8- DB1 Data bit 1 nB1
9 DB2 Dai. bia 2 RB2
10 DB3 Data bit 3 R93
l1 DB4 RD4
I2 DB5 Data bit 5
13 DB6 Data bit 6 RB5
novwf PORTB
bsf STATUS,RPo ; RAM Page 1
nowlw 0x00 ; PoRTA = alf outputs
' dolvf TRISA
novlk_ 0x00 , PoBTB = all outputs
bcf STATUS, RPo ; RAll Page 0
call LCDills
here goto here
; OUTPUT 1 INSTNUC'IION BYTE TO DISPLAY
Clo \ u 40h
movl
nowf De1ayl,
kdloop decfsz DelayL, F
goto kdloop
Funciion Set lnsiruciion ocer; data byte @6eor 0011*- 9 €ta.3.?: bit[9ho?
,"!;:(.\e . o :rJ).2;6 iT;;.rd rc?i: es:{J'-yo'j[: :'o- i :r.'ce code %LG::o:
6q:tr :9: t6orL9etc6oDPr eebr-
frov1r b'C0111000' ; function set 3 bits, 2 li.es, 5x7 ilo! forna!
call LcDins
q.P%c-
movlw b'001100Q0' , function set I bils, 1 lines. 5x7 Cot formai
call LcDins
4so.:4,6q:al6 Q(G-e)3?o?E:6%6€qedn
b , 00001100 ,
I-CDins
€{qr%c-
b | 00001111 '
LCDins
oaoT:.{Qe"T.'.Q93 source
; lcd2.asm
list P = 16F8 4a
inc lude "Pl6 8/a. 'n _ '
_conf iq h'3ff1 '
CRYSTA], = 4MHZ
CBLOCK 0x0C
DelayL
ENDC
.r..e i$6 qN
"irci
-.f:(:) Ln:rrrJc,tslal L-.i?r::rlLCD) I Plc i..5.i-;l-.!.o -.i,.rp"!o!,.r,19)
io-ll !:{!ia ; tCiliA = :r1l l.?
n..-rr lolTl
no.rtir 0!00 , aoP.lj = alL 1.:i
novri FOR!3
L - 5:A . 9
raorlv 0xC0 ; lcnll = ali .u:Prhs
nol r IiISA
Jnovlr C-.r00 ; IOR!ts - all curFut3
norit Tl15F
bci STa,TUs,tFo ; :1rx.1 Paqe 0
novlw 2..i , 25ns !oae. up deLay 0 4MHz
novrf Delayr ; ICD data shc.t says i5ms
clit Dciayl
PUPD .lecisz Dclayl, F
goto tUF 0
decf.-z D:layH,I'
goto ilLr,.J
bsf PORTA,IcdE
call cLock
bcf PO!TA,IcdE
; 6nS deIaY betwee. instructions
clrf Delay], ; about a 645 defay La 4MHz
novld Bh
- novlf Defayll
cttpl decfsz Delavt, F
goto ct1P1
decfsz DelayH.F
goto ctlP1
movlw rH'
ca]I rcDdala
calI LCDdala
calL LCDdata
caII LCDdala
novlw 'O'
calI LCDdata
call LCOdata
caII LCDdata
call LCDdata
call LCDdata
call LCOdaEa
here goto hele
cBLocK oxoc
DeIay!
DeIayH
ENDC
-3ooe
s5 {d{o dteo60S'
3?coc8dl66l.r,:flc'5oq{q e Ascll character'A s:%d HEX o,qQ,$d 41h G6E
o,4Q:-d 42h G6])dl1 {3, c"""1 csE o{Q:or6i
3. A 3,%.6 HEX o)qq A B c oo.)alG3.'A ro R'
,€c,r-q-"dr ,9.cr's 3..r[-,.:a.{. I' to c
od occQdce)o,i="T- ."To,c@.e,6%.q6,,od,
LcD module %8oe!: Plc d.3l.o8 RAI\/ location qp:od$ol3rdr rco el.co$q€:
cqctard oaci:qp,:rl€ sa{o1 anu bcat,on qle:%8 eqcpqolc6fi@o1:r$'r lco ol
controtler chip 3ral RAM location qp:%3cfcpoioio36@cc,r o"oi:9p:.'?o66.o:6€:S8 Q6,,7
co:@e:q6c$:o$qp:.{ .73"".o3eo,ci1 o$rr
LcD %3 oDe:qrD:$qroi833,ei RA[,4 loc-ation qgeol3: G")6.1-d' caeoTcQ8:q8
(eo) $p:r en+c$E:ca6 (i.)i,t-S'
o€o6rl::@3. LcD-Dc! -D4,1RA\rr tocaton (cG)e5
Qo:E:ecilcB lwinAowl oS@bdl::d Cursor or Display Shift instruciion ci eo:ciLll:e{e:
+a@r-+,GG, wrndow d
-csoos{.s8@E €O.ie,cic8ar3 'A f3. B,oi. G€.83:e
o es. n {.eorctae oc36.,rd, Q(c-3")%3@dil ,
"epda",E,
movlw b'000110!0' ; shitt display window ]eft 1 posrtion
call LCDins
novls b'00c11CC0' ; shift display LrindoN left 1 position
cal I LcDi ns
CDiOaK 0r0C
lelayL
Ell
'-
Lcdjls :q! arr / Ri! = l,Ca :lS frr
Icdi ecu -r:1 ; RAl = LC! I prr
clrf Count
Loop novf Count, vi
addlw 'A'
call tcDdatd
incf count
novla d'18' ; 18 characters co w.ite
btfss STATUS, Z
c]lf Delayl,
decfsz Delay!. F
goto ctlpl
decfsz DelayH. F
bsf PoRlA,lcdE
bcf :oRTA,lcdE
::::1lI:,:::::___::::: 9 1:l:
Clock aorLr' 4 0:l
I.rrt::).r.ri
.: !i .!r 1:.::: l-_!-lat/L/|
E--:. idi,ro:n
r:lu:n
; l..l l asn
;11': ch:iacier display on 2'd line
l:sr P = 16F84a _
ENDC
occQ:o:3cQ:r$ cdard6f.psdis{ €
set Display Data RAM acldress
o<rl€6oT6oc$q
(o"f..',ro5e-,@€. Set DD RA[, adiress)instructron c{ o+:Gtl8olodR o@tl DD RAM
address o$ oxSo (1ooooo00'in binary; @6e@:€: oc8@1eoc$ci1or$rr Set Display address
$?qc'reg: '10000000'o€G66:1r6E e. DD RAIvt address 4 ,nstruction data ab.cl.o3s"ri:GL
{eol])dll
ora?:cA,lcoe<q€:cl\t,co.lq<p9 oore{ooTcQqi€ eorS.iooft:eslcr.rf Etilogr
movlw 0x8 0
caII LcDins ; start chalacters froli l't on top -Line.
CBLOCK 0x0c
DelayL
DeIayH
ENDC
caII LCDdala
call LCDdata
caII LcDdata
ca]I LCDdata
call LCDdara
caff lcDdata
call lcDdata
caIl lcDdata
call Lcmata
calf LCDdata
calf I-CDdata
:1r::r r ?ili_::T_l:_T:i1l
I.c Ddata novwf PORTB
bsf PORTA.IcdRs
call Clock
L'sf PORTA,lcclE
cail Cl.ock
bcf gORTA,lcdE
calI clock
Q(C-cq) 1c8rl:c$8:cli
r-rcoe999 orcQ:qFoo8coTca?Q
-co-
Joo? ?r3 .EiolqN
Liquid crystal D'spray(Lco) - 2 ptc €"5a{,?i-{ca' orl:qloo8NS:qp:(t)
'ef(G)
;DEMO OF SETTING RAM ADDRESS O\ IJNE 2
lisl P = 16F84a
include "P16f84a, inc "
_coniig h!3ff1'
CRYSIAL:4MHZ
CBrcCI( OxOc
DelayL
D€]AYH
ENDC
rnovlE 20h ;
novwf D€-IayE
cllf De1ayt
gUPD decfsz DeLavt,F
goto PUPD
decfsz DelayH. F
gOtO PUPD
call LCDdata
calI Ddata
carl !CDclata
call lCDdata
novlw'I'
carL !CDdata
movlurN'
call LCDdata
novls'E'
carl, !CDdata
movt!, ' '
carl, lcDdata
nowfw12'
caIl LCDdata
!et1}'
DT
DT
glc$.e1:o:::qlc693 raber qp:G6[06r' Messr T3. Meis? 4.4 Rorl address qp:
3?G6sri:GG:cf.o6 PCL(Lower order 8 bits of Program counter) regisler modjry eSG: .{
ca.$$"o2!eoo.rcc{ qor63:66o1odll oai:b)qre ecr c{('p!af. moarry a9SQc{eq5S:
G66o3)dn or6Do8ord:poe PCLATH(write butter for upper 5 bits of the program Counter)
resister c,?cue!: set o73q$ 3?8orcq3?6eo.,ei,,
"3.aCl.$E,
messase op! pas; boundaries ooEgo8nr6 256 word .4 €6.e]E
RA[,t
""fp{-d
oa6ql 3ro30n6(,cd, e,Dosd€.nFos$5.qi€ 63o-,qp:.A ?ioisrq,{$3"ri-%"6 QQ5,p3
6cg:6r, qp!.t $i:Gt6t6ocE6.€dn
code
ecc.rcc{ etc memory e'5 eg!,.:p!ca9g€e{ 13E:co,):{eE, -€,o?.ddtr?.Gio)d
6oTqo8$e,i.{ 6c,,.oJr@ded{qlle e.o-,co:E1n3:erl 00,€6or address o? 6oTqo3Req6
6oTqo3$e,i.{ 6c,,.oJ"@ded{ee
l\.,lPAs[.l o$ assemble ec96E or{p{e.p .,51c6?qp:.4 e:Br0Le66o:dodr
movlw Tinel ; ll = 50
rlow.Iw Tine2 ;W=100
Resister cD6i.D c\)c8Sq8ca,o(')C0rG6aral 8 bits wide (o - zso coc;Q$ co$:g€:
Eq13 compiter cn wamlng message @er.:c€5.e2!'r
Ii is ai.f..i.ers 1i,i I
e is ai..iiress:1050
s is at a.iciress 105:L
s is aL adclress 1052
a is aL addlcss 1053
q rs ai address 1054
e is at address 1055
* is ar address 1056
l is at address 105?
Hig]r (l,rne1)
PCLATI]
rnr = 4th
-!.'r,c)
shd:G8. 1
dl dor6?r;il>o5gdiaG3. subroutine 4 memory o5o$og!e9epcf.e{
+-4€, rD number oai o @6q913 u.."0 cl.?Eer:E:, s?o',isd 1
G6qse
0 ol audress c{ep;$3eo:: qEe:oc8ql.6$p:r
Messaqe
EessL subroutine op! v."""q.1 €i address o?6tq?B86.rr cf6e€o,eqtd$olrrpqr
- ues.ase laber qp'ct s:rt:G1@:cr:3:4.::s! memory a €: 6dodcq6rrgo36:6od:
coropir{ eoTcao6$3o1 opi r
6o13:o,5.rd 25s cDd@:q91€ srATUs resister €rl carry flag rJe9 I G6 ?;":dl,rdn
orn<js$ edl€:coSarg! 0 {.oo?o5 255 codcc$qi3 srArus resister oi carry flas o$ 0 $6
+'.t;0' e*. "",,vn"s"i"s.-,-d-.t r @a",6{q1e ecmrn c{ rof:eocio$rr
bLfsc STA'IUS,C ; iest carly
incf PCLATH, F ; ovelflo - inc.enent PCLATH
I
Prc c:ei bit r€.436:r,r%dqlo6i4p.,?3>c@1o?3+36Jo:dj:' 16 bit t€$ecco,
ql:4@ie66o62i coae c{ es,:cBcilo{€:ee1:o::$6<ic:E)rr
%o5qo6fr
255+1=0
btfsc STATUS, C
Messases subrcurine
-d '"'"t w %€ codp:G$or":lplr
,e'
'n'o2) o cu2c8
o@e. o€:cfl QooTeo@: st.err cA or6ioi:o, eqcr;ooq: o? Q6oT6oo13d,r
sl9d,*4e, q$-e,cp,4 o6ci:qj3:qc\iE, Q6drco:,jl€oro.Odn
c ; drsplay message 0
; dispLay nessage l
i VESSAGE 0
MESSAGE 1
tligh {Messagel)
; tenp slore it
; get Page offset
; tenp slore it
; -----------------
; qtAnACtER ADDRESS CALCULAIOR
t ---"------------
Messages movf MessAddH, !i high addless byte to pcLATn
MOVHf PCLATH
rLovf MessAddl, !i qet low add.ess byte
actdef StrPEr,9l acld chalacter offser
btfsc STATUS, C ;
.tncf PCLATH,I_ overflow - ucrement PCLATH
movkf PCL i low byte to PCL
Jooe $6 GhdtlN
tiJara9' {per5"so'r9p:.t 4 bit 661)' niuote 951 @6e3?:3 moaig (.?6eo:qollo2lrr
rnrhsetion code f3. Function set insiruction 4." d-Sd,."s e@3:oi9$@ciiar$rr + ort mooe
,,"sc6 oo6co3:o:pleo:.'5Q.{ Q(G-oe)"63 6oT$co':ol",d'
LCDdata gE
bit $6a'r nibbre t6iG66s"re modify e8co:qdlcelll 4ol&La AND!W
instruction of.c{ caci,$@qcn o$l
; CRYSTAI = 4Mtlz
EN OC
LCDhd equ 0h
Joo? 6 akdiN
! i:(6) L,qu,d crystar DEpray(LcD)- 2 ptc
Q.6e{(8{@6c\rr e5i:epo5oSrqF(9)
gotd PUPD
i -------------_ --
; MAIN PROGRAM I,OOP
MESSAGE O
IIESSAGE 1
goto ctlpl
::::::_1_:i:i_:l::_::_31::il___1_:ll_T::
-acdala nc1,wf tenp ; tent save data
andle 0xF0 ; send hish nibble fllst
NOVUf PORTB
ca1l clock
,bs! PORTB,IcdRS ; tirlte "Caia"
call crock
bsf IORTB,ICdE ; clock jL in
call clock
bc! PCRTB, lcdE
caII clock
seapf tenp/li ; nov iend lo"er nibbte
ancllv 0rF0
NOVFf PORTB
call clock
bsf lCRTts,lcdRs ; HriLe "da!a"
ca.i I Clocn
trsi PORTts,1.dC , enable insriuction
ca LI atock
bci PORTB,IcdE
MESSAGE STRINCS
:a LcD modute
t8:6q"c; LCD module Cp,"""@3,.i
c.r.:""..ir , S
-4,(c)"Be ."TE.a:
."TE.d o-sv Disita
vortmeier co3d6%.q6ai6,.rc33j:€a:jr
<
o1d e
#{dG) Liquid crystal Display(Lco) -2 Plc qo5+{c8{@{o -.7,it,,o5.s6,qp(t)
500
Pause I tlait for l,co to startuP
toop: Lcdout $fe, 1 | clear I,CD screen
Lcdo'rt "ge]lo" '| Dispfav He.l]o
Pause 500 fiaiL .5 second
9o51c6r,,
. > PicBasic Pro otsa3i:G6€'-d QQ<rXEcu6c33o2l:9fie@€'ec6.qec'ogl r
@agd?)
Analog to Digital Conversion
9-c'r {s1f'
Vino
lrinl
\''in2 Sta't
virf
Vin4
Yi5 Uutprt
Vin6
Vini
Ch0 select€d
(A2D) o.3oJ6:s6653,833"8e:qP:+
Q(9-c) success:ve epproximatjon converter
I Comparator
iQ:o? -3.r
cgdeoTcD.
63,,: s6r16ocso$Q:r:a: v,no cB3o3c6p.;cw,.l>: caspec.::. Q.3:c:o? .4,rso':Gprodn
Sn4c.6 cor..o -os.c-ial:' Lolvercbn 8:4:sE€,4 :a
j",,:,',j r'rdo' co,verso,
rroc) caaldG{ cao36r:ixd, Eoc 4 software G3. o66-,.36$3c'13rd' slid,G8.
:5q6oc5o{Q,ci oor{E:6r
- 6
oqoqsqr'%6 cEd,,4 :ar,Gr{} 6,6o".,.c:dn
A2o oir".i:Grxairail r,.3Qrdc8E2.rod3,qj.33"{1.'? orSQolsd, sampre and Hord
moc$E',$d .o,.36,c'?d.-q.3,:s,€orc3 q13od:33:eca€ 3a{6or6ioiqolc:d,
orn,.,5$ o€'mocSSo-,:61 charse/discharse c.,5:6@4:%e o4:€oc8e5q3?qp:e@o:6oT6o1rr5
c{q € A13o6383'"p.S€ 6f:?J,:g: o?d63, source voltase :acaci c2$ecrqq6o6 cq$$8
eo,:eqlr {3aa'l nzo eocSqq$e3,Q.3-,:o,4Q:]]d 3,aiq.3-,:olqQ:cori eqp.gg:e1eo
og8pdn 46@13. Microchrp ?8.!5m source resistance c$.er-'1c6 source impedance c'?
roxo co.5"eoT5cg{eoqg uc3go5cor:dcrd, 4.3"G3 3,Q{4fE input capacrance d$$:
A2D e,L,c8.3.,$Q,.,? c8q.,s$3;l6rr:oG6. o:3:oi.c{ oata sheet qp:ca8 eoft
"?.],do)a!,
co::q1c3qp:cfl
"-.-@deG, osQcsq,jr3)dn
A2D oc6N6:3rd Q943'e6e3qis?%c6 ctock o€e13:o:61c$s:6<,ilo$rL conversion
or5@68:6@rc36t$3:%.3 12 crock cycte.,?sSol:ra:, ctock eli o{qe8::$ @$$3r€6l@:,il
-dil 3,3,,S6@"3.4615 A2D rrlodure trrd c8o8oncas,e6eS€3q1.: aa2!:aQ:cgo3 d
63' conversion crock speed m$.-c3ato66cEctr €@.3.G6dtrrdn(De,o4q:3,d *+d,"i,
1.6f s per clock cycre $q6dG6Jl-dr
-e'-fQ,.A rad qeaTcil:r:p!rr Q(r-.1)"a3@d.1'
Clotk I Clock 12
Sta't
I I.6uS
'(
F.oc Llir_Linrurn
{c$,Dq;1i
".i".flrd,G;-d ilr-r)ca€ p
Tad op! zsons:. sz a"s =
9p, g,e
"rpc8g,,f
or g,
i(? l) ?osrscaler +
?-Cr 0.5V
Digital Vottmeter
ftiE !- Re
s i;t
osc, i 3 6
roo.-.e e qo4"1o3qp:9€.
.. " 1o,
bnot],e,
:o
prc16r 8764 si io,+Jtotqp:9o
Qi,c6,6"oras.;qr"6qr.,d _"6d6)"nss.[;e,
.',oi,' " " -
"_."5.j1J(?_C-"?€,b;j
:
t."2 19a.+1Aq-
sol:(?) Analos 1o Dlsi[al ccnversion
3'E.''98qed"i5c$,,iqp:cf 6s,c3o13"43:
A.Q6@.d
.odcD.n6(J
*d: ee3'coc$il3?E1"33?cD"3,ip:.f
I I tr
source code %S cod?sS,6"ro,",+3:.os..o€.d
L9'r
_ _p:go
source code crf-9q.er::@:eqcc6 cBLocK directive .{
oc1:Q1p: nAM defnitions -6,'-4"-j6, rco oq.S o4:eo2j
Rs 9€. E o?.4 equ direct
; -------- ----
; RAI4 DEFINITIoNS
CBLOCK 0x20
DetayL
DeIayH
:
.Joo? ?t3 ol+olqo _rJ6_ os:@oSo€:
,s{d9) Analos to D,starconveGion P c {.to{q+@fiM o.i:qloc3o5,,rpd9)
BCDvalir
BCDvalM
!cDvalL
shiftll
shiftM
shiftL
ENDC
; INITIALISE PORTS
NOVWf PORTB
bsf PORTA,IcdRS
bsf PORTA,lcdE
bcf PORTA,lcctE
decfsz De1ayl,, F
.eEurn
Delay2S
decfsz Delays, E
goto PUPD
retu.rn
_ {.ydsetup
:o€goeal:.$.ar98 $ec:r 36q6cr:,iSor${:.,?6Jf!6}i LcD modute cae Dr
o261ci{'p!rr (-"idc)qr8
:,:1'""" lgE'. Dr directive s?]?:Gl+eg,4 *"",,E6$e;*€,b.
U:t9dorodD
, _ -j-.3G, Lco_modute oee ocosc$€:f€. roE,DC$8.4.%S messase qp::acar6
c{6pqp:c,?r,o6ec6qdl{'d!
'16,,r€o€d
; -- _-----------
; DISPI-AY MESSAGES
; oxFF in ]ast position mea.s
Dl"sp1ett novfMessP!,W
addFf PCl,, F
DT ( 0-5V ) VOIT_METER". oxFF
DT "volTsr, oaFF
; DISP]-AY TEXT
DoDsl,oop calfDisPText
xorl! oxFF
btfsc srATUs. z
return
xollw OXFF
calr l,cDdata
incf MessPt,F
goto DoDsLoop
ADRESH ADFESL
The value in the parenthesis is in lhe conditrcn immediately after the turning on.
PCFG Port
Remarks
szro 67",.iu ir.il rli.enirN irN+
lbooo n A "ua
A A A A A A
doornnnAVREF,AAA
OO]ODDDAAAAA
OO11 D D D AVFEF'A A A
O1OODDDDADAA
O1O1 D D D DVREF.D A A
O11O D D D D D D D - 0111
sameaq
orTl D D D D D D D orlo
'
1000 A A A A vn.r,v., A A
1OO1 D DA A A A AA
lOlODDAAVFEfuAAA
Itor'o D A e v"...-v^.r. p. e
Ittoo-io o te {.r.[.r-tn la 1e:nnaroqport
i1101 .D:D.Do tD
ltibi.o:o- r-o v*.,
iv*-,v*,.. n iA
!*'.. A i,q iD:Disirarport
iy 1,g'L1ll*
iriro:e:o o-r-o 5'b olA '
'"i'u?;"""'"",'"n"
:D D.,..
l-a : VREF: Low
ir1,t_ ?__o 'D VREF.:VREF-
*__ I rererence vonage
AD=NI = 0 lE;o?ii
'6G.rd r,j,do;d (isft rLrsiirred) cLilYg:r ADFNa = 1 G6q 3
€6LJ 1.);)JlJ 6 J :r,ri t ru\|,fie,])- l- ji . ,? r0:,ls i."1:[ior:[:: .rsoLro,
3.€o,re:{,G56oq$3;,zo5 ADFr,t = 1{rishi rLrsH eo .i.g,ndo1e2)l
e,:o.60I l-d r.a.-v-qp:1i.r; "!r a . coderp:." -? . Jscia:6T j^Jr
ADcs bfts qp:.{ tt <1::d9o5@: internal R-c osc ator 3,{[3"o,:.{ ce:n,$,jled
3?codo1 3retdqp,.i eoc6d code c63 e6,,1 3:Gdrc$3,j1 ud I
or?3:{1oe€ %63o?.qio':63r.
(D€:o?..i AscI characters
Q6ri.60oe:E
ADRES o4q:3ri!) ro birs
6])16€.
4"@e. -i.i,*,"i,4 Qcorqgo%.,s
60;3:cn6,,:$cqo6colle:r ASclt character
nc'j i ADREST!, u
andls b'0000001r' ; ias! un.r-:reC .l: ia
call ToASCtI
call LCDdata
+-_ _
r.2 196 eir,.1f1o
.aralog !o Oigirar Con!€sion
9oto 42Dloop
,c
:p6
j:.::;;E-u".n
roo -rqc.,s:,ra: ,,,n,u *ni0"il,Tuff,''"Pl;f;%"tlJ*,," = ,,,.
c2;1<- x.r,ear;.tno2; :Io o.l.
N!.nHr = 0 0t!
Nr.ll.o = 2 tih
ls l -. tl: = a1h
lslirL. A9r
o"f,(2) ena oe ro Dieitat conuers on p c Q.,5o{%16flM ee:qoo5o3:qp(9)
.rrE:6rr:s,"1
2FC4A8 / 3rl - Ba4n (3 065 00{,) 02j = 2996) . 3 voll
nratortl = 00h
nratolM = oEh
nratoll, = E4h
novf nrato!M, w
Jooe ees.$qdtio
-.{,. ''
n.[,{.) A]rai.c ic r !,12 cciles c,r : ., , , , :.:,i;,,(.,)
":..;: i,:,.--,,{":-S:
d).i,t:.jtr:oi BcDvsr!1 +:. ECDy:1i, d€.r,'! N rb e o,ii.j::r?
a^li-.r'rr:(l 's.r ...re :"li:. Gr:,['i':i']o5 ecG LCD cr3 .:',r.5i1..4':,
.*;dr)O..,i€rrc":q6"rJn :r. . i . ) 11{ a'o.3;:6rei:.3%;codr3:o:ir.rd i
.:1, T.r:r::i l
.r:11 laD.i:ia
movi BCDVaIL,IJ ; 'ro!: 1!!o.hs
call ToXSC I I
caIL LcD.lara
; Rj\M DEFINITIONS
CBLOCK Cx20
so$:(?)AnaostoDieitalcof"ersron plcQ.,Sa{oa4@{Mo.i:qlooso6:qj}(9)
====:
BCDvalH
BCDvatM
BCDvaU,
shiftl,
ENDC
iro Cornectioi
..to SlrarL:
i.15clI :Lldr:!C1,,1.'
.. t.! N !'
i: ::" '2'
.:.,''],
:.'-
.::lii ' 6'
.ei1r 'r'
:::tr 'E'
re'-1rr ' 9'
ie]]lH 'l'
.e.lt 'l'
r.:1,1 'C'
.:ir" 'D'
::i1iir 'n'
i=i 1Li 'a'
; ! 3!!AI IJES:ACE5
Lsf srATU5,RP0
ORTA = all outputs except for qAO
RC Mode CHo - ON
novf Nu]nbl.o, w
novwf nratolH
novf RsItaH-l.I,l
nov'rf nratolM
novf RsItaLo,tl
nowf nratorl
crrf denonH ; 102ldec = 0003FFhex
novLH 03h
novsf denonM
novlw oxFF
novr,'f denonl
call Division ; -> nlatotH nratorM nratorl
calI ToASCII
call LCDdata
; decimal point
rovf BCDvalM,It
calI ToASCII
BCDvalt, tl
0x0 F
ToASCII
BCDvalL,li
0!0F
cal I Tol,SCII
iecisz Count, I
; DISPIAY TEXT
I,ow (DispText) + 2
DoDsloop caIID.isprext
aorlw oxFF
blfsc STATOS, Z
!eLu!n
xorlu oxFF
call LCDdata
incf Messpt. F
, goto DoDsloop
cLOC(rNG DELAY_200uSG4MHz
decfsz DeIayL, F
DeIaY25
clrf Delayl
!UPD decfsz Delayl, F
qoio PUPD
decfsz DelayH, F
qoto PUPD
16 x 16 MUI-TIPI-Y
ninna -> nunb rslta 16X16-> 32 bits
Mu l!tp.Iy 15 loops
nowrf l4count
novf NunibHi, w
novwf RsltbHr
novf Nunblo, w
novsf Rsllbl,o
cl!f NumbHl
cllf Nunblo
rrf Rsltbsl, F
rrf RsMLo, F
btfss STATUS,c
novf Nunalo,Vl
addwf NulibLo, F
blfsc STATUS,C
incf Nunblh. F
novf NunaHi. W
adduf NunbHi, E
cfrf nraLorH
clrf nralorM
cLrt nratorL
cl!f remainH
clrf lenainM
clrf renainl,
bcf STATUS, C
rlf shiftL, F
rlf shiltM, F
rlf shilttl/ F
!lf renainl, F
r1f renainM, F
r1f renainH/ |
novt denonH,IJ
subwf renain8,Id
tittss STATUS, Z
novf denonM/w
subwf renainM/ u
btfss STATlls I z
movf denonl-, vi
subaf renaint, W
lrtfss sTATUS, c
decEsz Mcount. E
clrf BcDvalH
clrf BCDwaIM
c1r f BcDvall
bcf STATus, C
Ioop16 rlf Nunbl'o, F
r1f NunbHi, F
rlf BCDvalL, F
11f BCDVaIM, F
r1f BcDvalll, F
btfsc STATUS, Z
call adjBcD
novlh, BCDvalH
novwf PsR
ca.LI adjBcD
:,,ljECt)
r.l.i,J f iID!,',i
r.vHi'LerD
attsc Tenp,3
na /ri J liD!_
norilw -10n
addrif INarF,Ii
nov f Teup
blfsc Tcnp,l
novlri IliDir,
reiu.n
9.6qj.'5' o
c'fiq.i.28 P c16F876A @oal Plc16F877A ct@.i:Gpeg4qn8 LcD
o<oc6o1
nooule g3.;orS3c'5ard r,.3436p l.E1.U"Ecr,.{ 9{,"qg.6€:qld$: -8-3q.,"elr
.orr"u
"od"
c2Scopl: ri.t P - I5t871A; include 'P16f8?7A.i""" q$ e@8:otseo:
eloilrl2!'r
Ijl]R"r- A l
Jooe $5 @$rolqo
o.lt?) Analos lo Disital conveEion prc
{.5o6.e1@{M ori:qloa8N€.qlx(9)
IgiR^/F/rhv -.....-
tl^or N0 .+
RJ'\ITANI .+
llizaftz /r4. r+
RAln tiwFEr. .-
RA4/I0CX| € G
fi^&A'{49 +
iFo/FB^xt r_ 3 33
€
Rs18!EAf,J6 9
RE2IF'AN? .+
v5s + 29
OSCTCIKI{ .....- ,6
oscrrc!@uf + 11 21
FCAIIOSC'/t1CXr+ 2$
AC1'r16!CC!2 l_ 25
AC?rC4P! .+
*cascx/sc! 23
lor''sod *
FDIPSP1
-_ N
72
:
!
t
r
tt
I
it
l0 pF
f
t
I fl es:66ecuo'-"o8cu6:s::oc,5:scseocqoc.a:@q
{(2
t , t
.eG
.1."e 1e3 e$qdl{-
r) ,.{d?) Anaros to Digital conveBon
-{o o:1,qodo6,ep,(9)
Return
malnloop:
Gosub getx ' Get x value
Gosub gety ' Get y vatue
Gosub getz ' Get z va lu -.
Lcdout gfe, 1. ,,x=,,
pause 100 ::tuo 'rcv-", #y, 'z= , #z ' scnd rn r.n
aDouL 10 - -'-
trmes a second
Goto malnloop ' Do it forever
End
9o5yr5r n
€:eoXqeoop!rr
[ricrDcode Studio tDE
o.rqSeqro::ogoEeoqi
o8oo${o1
a 16!:(0) Disassembrer etc {c6.{qQo{o oQ,qtoo5o6,qF(r)
oe$:(o)
Disassem bler
o-crr {s'1{r
windowQ
{(o-3) 84 Disasm
Q(o-o)
? open .{^click
drsassemble lqo?o
di\piclab-l
jEXPTlu HEX
EXPTllB.HEX
EXPIIb HEX
EXPTlCHEI
EXPT1D HEX
EXFTIE HEX
4 source rite 4
save orSqq3?%$ Fite>save As 4
cticke3cs.EqnS +G 9)%3
.oT@cor:ard3?o?e' save As wndow 6,rTo,6oed' 33 save eSqlSDd folder rr?6e:{cSg:
Frle name egcpcg€ sourc€ file c{ enension ( asm) @3. save ca3s1o1c2!n 4se.1 {G-C)
%S@colard.oo?€: oone c2r,1$e::: dralos box e<rTcu:@: oK .i
click e6cqo6$e,."r:G€.
disassemble oi06e: eSci:oiE::9:eoeo:r.c.:$rr
.:!1r. H-=Y :l
lH*r.n"o :J
gl9$:@3. trex file c,? disassemble o76p:q$coreoc source file ogt heaoer qp'
dilrectives qpc lable qp:ie. comment ql":.{ eoT$co::@3:e$eorr eorO $. CALL instruclion
qp:oc6c,5 t-alte 6{.fJqle addre$ S€. e"TQtno:@€:ecaq6oe$r
Exptl hex
Q(o-G)o38 qo: 13. Expll asm 13. 4 disassemble q 3S: q$cule 9:c
Exptl asm o?.ci fiE:9l€l;TQ.":: ol cr$'
lrlcE5
16[654
I6F630
lD-"{l
o-?) P'c-Disasm window
] EF63l
Q
=El
I0F200 12C5M 1,1000
]2HV6DI
I2$,/615
16HV610
I CF220 t2EE5tS
I5HV540
124671
l2cE6/3
t2cE67l
.Gs
,'+(o) Disassembrer qd.n"a+-n^"
"+,
",c
8Es?ri:Dt3)d ptc *{t
3?o.,.{e8,flas@:eqao8 oisassemure ceScg-a! hex nre ca
a'n,-'5qo1"e9r Main menu 9 Fite>open .4 cttct q6$e a*o2!:e o::e:r Shon cLrr Tootbar 9
open Hex-Frle c{ cticf ca3$".:5co3l:ecm€, olcure- Load Hex-File menu box 9 Look in:
64e,€e hex fire .i QG-e).a8@d.l'l
"s'flosqo]€dn
HexFile:
Textrormat @€. Hexrite c{ eoT$cca:
@3:@6o1o2i rr
Debug:
P,c?:":T9 GoTo?o6oic3&: Prc @5 Prosram 6olr oroi:qp:.A 6oTG
co::@3:@6<;log! r PrcDisasmorai Prc E.6o{ ebusserc,4c8c,ieqln
PlcDisasm 65 [anslate-function
AsrhFit€:
4 E,-d$
HexFile r'? disassemble o76S,.qnc66l$cure], nsmrite r{eol!co::@€:@6o1o$rr
Hexdump:
Hexadecimal-Format
G3. HexFile c,icoT!cor:63:06t:1odn
<p16F64!.,IUC>
CP OFT T PI;IRTE ON
'
Orqr LiroDlD
UOVLLI 0):D1
I{OVI'IF FoRT-q.
uau tt,otu=,
ctRr toRT! "oo
IADR OXD€!6
ETISS FORT.!..'
GOTO L,\D! OXDOOTI
BsF PORT9, -
GOTO L!I,R rlxooo 6
LARI 0x!04.{
Ld ecl polra, c
GOTO L.(}R OX]D!6
-:GG
Joo? ?16 eEroilqa
6ai:(o) Disassembrs Prc €.'So{%E@{(Dr -4,ql.d-3,sd9)
tib Edr V_E,v li'o Fild ic:\usT { smbtyl\Plc LAB I ExPTs\exDr1 HEx
HexdurnP File Q
Q(o-c?)
PIC-bisasilt",'
(c! 2@1 .2007 by Norberi Haqcmdnn
*4de)
e-3r {311:
pr c
Qc&{,?1@{.-ep:43?ri,GL3)d3?e1 rxscSo:o75pegee:co8:$&,d 3'6cD.c6
-.?q.ed, .8qo-qp'G3. 83:e.Dree.,"-3:+:e€. 3,.,it:3,d66pc3s3"6{:prc6rcDrsqp:
03c,rr6o6rE 43.3.ood, gl*"i,"a; ..s:D6c8c83cor:6]],ed:c,r6:qp:83. q6a4
ei-6-qp,4 86:6.013h@6,),3:{: f €. 3,oit:])d66pd?3'$4:G663?,€ 3"3i:Grq8a .i
or30o16d,
l/Ooins 1 3 5 6 6 s
LEOs 2 6 12 20 30 42 56
q.,Sa{
%EcD{c',€,ts,€o5q o6(q)qo3€ reo (c) ii: or8.o€3"oi :GL$3Q4 Q(e -r) "a3
3,cgdeo6(r)e%6 LED (3J)cr: or3-33:3i,0rQc{ {(e-G) oe€6o1!.oe:D$
"AE-,G,
ool€:6%G3Re6,',a,dn
FlCmicao
DigllallO
ol
-03
\:
o5 06
oigital l/O i!
!!
o2
Digilal [rO
R3
PlCmlcro
obital I/o
D1 o1t
i:
oig'ral uo
R2 D2 D5 ID7 D6
i:
Dlgital I/O
R3 0l o6 D10
Dqital l,o
B
c
D
.ll"
vlumrcro
E
G
.f r"
Diq(il
3o
?(e e) 12 DlGlr [,luLTlPLEX|NG wrH oPTo-rsoLATORS
-
o3:oc3o3'
.1oo9 1e6 olqo]{o *"
*+(0) Ha'dware Technrques ror plc t\,4icrocontro ers Prc 6d!{.e{@ 05o,6:EP:(el
=ir4
G:)t4
ffif,*fi,"ffii}""J3.::,T"'"Tf*9P;
Dpd--, .o,%;6oTls
drive ot6 rr o€:0ca3
Ad.t _ "aqd-4, pruy co'otior
o%.3 3"3?: Grcor: dl opS n
P n3 A. G aE Dgnatt/O-
-i
""'-l
LrSe'ssoos:cft:P6tr.x
gccalug.tego$cogoEoc."-e 3mrirFe.to,9aolfl aqeua ,@ee$
alqesLp ro uorrecrLdde '3{
RC Watchdog Wake-up
WAKE.IJP PROCEDURE
or3:oa€ &
= 1/2nrc $d
,DocSSolsr\ cooc$8o,3.o>lQ:G6odr
ca<nc$$ vt= zeov93. t= soHz G6qg3-
nn
-). +v
f",
5lv
""e$("")
Electronic Combination Lock with PIC
co-cu {s1{,
1234r1998#1998#
dt "456b"
Ithis value is used for delay calibration. Of course, the code will run with
- ldiiferent speed hardware bs well, but faster or slower than intended.
pulsewidth EQU this Value is used to set the delay of the output pulse To calculate the
.l?l150' _ delay in seconds, use pulsewidth'20 ms -
this value sels the length ofthe code. The length is elways fixed, and yo!
cal set il much higher. unti. yoJ have avarlable_R1yaI"
"ll_
nhz Eoo D'4' ())3:oe9 delay calibration s?%o606o1-dr
pulsewidth EQU 'D'.Iso' (])6:oe) outpLrl pulse 3?gri cetayc{ set q3e,{@Eolrpirr
co-grr Hardware
cooe qp: r{
{rfcg€:epo3e Keypad .'?3:a,EFtc<.:ca!r 4x4 Keypad cr,6qo,p!n-.6
co,:rio? *,.A,jlQ(ro c)ca€ eoT@coc:,j1a:2ir1 ::.o3ol3.o'd6soc8@:e>r: ax4 Keypad ({rp
$oe1$3cllcn pustr lutton switcn(cG)1@€. 88c,3,o,d66or.3qoa$e,ic.,d,,
c
I-T-I
I $ D
t-T-l t-T-l I-T'1
i-
'- Colo bor-r coi-lcor-s
schematic
+8-3@UDC
. 7eLO5 ol TAAa
E-f_
0sc2 p32
,\'.:.::".1,':.:":::::''"
code
cacoc6cilccuc:9 download o?61car:6rrec,:6cufi asm file 13, hex nte {.c{ 9lo:3?613.
oo7c"2ino,.o",.-'r cD ch1o zip forder 3 -2)ca€:ec,,corcilo2)rr
{
part Iist
part number description
PlC16F84-10 or
tc1
. P1C16F84A - [/icroch]p microcontroLler pre-programmed
lc(min)=500 nA
inpuaPl65 of zso'
01
code
3rcodo:lcor:g download L?661.@.::6or6(r;o)d asm fite f€. hex fite o?,4 glore8f3.
eo?cDdco,co,:6o:: cD fi ch1 0 zp rotderqlS co2)cg3:eo,coc:o1op!
part list
R2 220 ohrn
0h
c3 1100 nF ceram c capaciior
software
i
i thrs s the definiton ofwhai you see on the LCD instead oflhe dqits
HIDDEN CODE (default is asier sk) lf you de ete thrs I ne, the diglts are shown as eniered
I
ihis va ue contains the LCD positlon for messages By oefau t lt contains
the address oithe firsl LCD line (ciocunrented in the LCD daiasheet)
thrs value containsthe LCD posilion for code entry By defuutt it contatns
the address ofthe second LCD line (documented in the LCD datasheet)
schematic
"I
6ND
BUZZEE
PIC16F62A ar
PICa6F62AA a.
P|C16F527 o.
prcL6F 5274
code )D?
13.oc5[
:a:gi
eco.3dleo,,g download L?€$co,:ca,oc,:3s$ asm file f€. hex fre o?.4 glaaqSl
3?o?cod6o'cca:o, cD 6 ch1 0 zip rotde, oAe ocdtrA3,6o:aa:o1 ])d,
pArt list
pre-pro9rammed
iserial LCD inledace: an HD4478o-compatibe 2x16 char LCD and some more
ielectronics
too9 i
.loo? ?+6 aE+oi qo
I:(-) Eledronic combinaton Lock with PIC
DB7
DB6
n uB5
6
i ,-NC 5
DB4
DE]
DB2
DEI
l Crn
L, r, DEO
!N
RS
G}ID
vcc
I
VL'CL
6
13 NC
n3? ( ---1r-ttA- 5
RB61 lcK
RB5 3
IO EN
2
I
_=-l
A: place lhe 3rci column of your keypad inside the box contarning the PCB and change
keylable so as onlythe 3rd column contains ihe key '''
A: Re-program the PIC chip wilh the latest HEX file you used The code will be reset to the vi
in the HEX file
A: read out the cont€nts of the PIC with a progranrrner You can find ihe actual code stored in
DATA EEPRON4 Depending onthe progranrner soflware, the code can be modifrec._ ',
Q: ls there a way to make thls design work as an on/off switch (toggle) inst, -d of a momeil
switch? ln detail, enter code to turn a sw(ch on, enter lhe code again to turn the swrtch off
A: yes- The modified 16F84 code i6 download.able here, name cl2b asm
Q: The combination lock seenrs to work (il beeps once for every keypress), but it doesn't ope
ihe relay!
A1: There can be a problem with operating your relay To check, disconnect resistot from pi
(R82) and touch t to the VDD (pin#14) lf it does not operate the relay, check your hansistor
the diode pola ty l\,4easure ihe output of pin#8 (RB2) when you eniered ihe co(ect codi
should change to +5VOC for the presettime interval then back to oVDC
A2: you possibly misconnecled some roMcolumn lines so incorrect keycodes are generated
if you swap colo and coll wires, and press the keys 1 2 3 4, it gets interpreted as 2 135