No changes between revisions
/Designs/Measuring_instruments/LCTmetr01A/SW/bin/PRG.BAT
0,0 → 1,6
call picpgr stop lpt2
call picpgr erase pic16f876 lpt2
call picpgr program lc.hex hex pic16f876 lpt2
call picpgr run lpt2
pause
call picpgr stop lpt2
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/bin/lc.HEX
0,0 → 1,639
:1000000010308A0000280000A100030E8301A20026
:100010000A08A3008A010C1C0F28A60A0C100B1D4D
:1000200025280B111530A400A40B142800003D3026
:100030008100A503031D3628000000000000000019
:1000400010100130A0008B1236280B1C2C2806083B
:100050000230A0000B1036280C1D3628241C332833
:100060002418071134280715A4090C1123088A0045
:10007000220E8300A10E210E09000A108A100A1117
:10008000820770346E3475346D340A108A100A1188
:1000900082076E3475346D3420340A108A100A11C8
:1000A000820728340C34013406340A108A100A11ED
:1000B00082070C3400340A108A100A118207203497
:1000C0002034433461346C346934623472346134C2
:1000D000743469346F346E3400340A108A100A1193
:1000E00082073034203420346E34483400340A100F
:1000F0008A100A118207203443346F346E346E3410
:1001000065346334743420344C347834203400340F
:100110000A108A100A11820730342E3430343034F9
:10012000203420347034463400340A108A100A1106
:100130008207203420344534723472346F34723480
:10014000203443347834203400340A108A100A11E1
:10015000820730342E343034203410341134433498
:1001600000340A108A100A118207203420344334E4
:100170006F346E346E3465346334743420347434C4
:1001800065346D34703400340A108A100A11820705
:1001900020342034313430347534733420342834EE
:1001A000353430344B3448347A34293400340A102E
:1001B0008A100A11820720342034323430347534E6
:1001C000733420342834323435344B3448347A3460
:1001D000293400340A108A100A118207203420348E
:1001E0003534303475347334203428343134303479
:1001F0004B3448347A34293400340A148A100A11F2
:100200008207203420343134303430347534733440
:100210002034283435344B3448347A34293400348B
:100220000A148A100A1182072034323430343034F0
:10023000753473342034283432342E3435344B340E
:1002400048347A34293400340A148A100A11820797
:100250002034203435343034303475347334203421
:10026000283431344B3448347A34293400340A1475
:100270008A100A1182072034203431346D347334EB
:1002800020342034283435343034303448347A340F
:10029000293400340A148A100A11820720342034C9
:1002A00032346D34733420342034283432343534CD
:1002B000303448347A34293400340A148A100A114C
:1002C00082072034203435346D34733420342034A4
:1002D000283431343034303448347A3429340034DA
:1002E0000A148A100A118207203420343134303441
:1002F0006D34733420342034283435343034483469
:100300007A34293400340A148A100A1182072034FE
:100310002034323430346D34733420342034283473
:100320003234353448347A34293400340A148A108B
:100330000A11820720342034353430346D3473345C
:100340002034203428343134303448347A34293459
:1003500000340A148A100A118207203420343534FC
:10036000303430346D347334203420342834313414
:1003700048347A34293400340A148A100A11820766
:1003800020342034353475347334203428343134F7
:10039000303430344B3448347A34293400340A143D
:1003A0008A100A11820704340A3411341F3480344D
:1003B00000340A148A100A11820720345634653436
:1003C0007234733469346F346E34203431342E34E3
:1003D0003034313400340A148A100A118207283468
:1003E0006334293420344F344B3431345834473457
:1003F0004C342034323430343034343400340A1045
:100400008A140A1182074D344F344434453443343E
:1004100078344E3455344C344C3400340A108A1439
:100420000A1182074D344F34443445344C34783407
:100430004E3455344C344C3400340A108A140A11AA
:1004400082074D344F3444344534203420342B3427
:1004500054344D345034203420344E3455344C34DC
:100460004C3400340A108A140A1182074D344F3478
:1004700044344534203420342B3450344C345A34F2
:1004800020345734493444345434483400346C30C4
:100490008400000803195D2A0130F800BF30F7001E
:1004A0006400F70B502AF80B4E2A4A30F700F70B7E
:1004B000572A00006400800B4C2A00340508C33919
:1004C000F300720DF700F70DFC30F70577083C39A3
:1004D000730485008514831685100000831285102F
:1004E0008316851083120034F008031D792A051045
:1004F0007A2A051483160510F10E7108F200831292
:100500005E22F10E7108F2005E220D30F700F70B4B
:10051000872A00341430EC004722C3308316850547
:10052000831205108316051083128510831685101B
:100530008312B6013608023C031CA62A0230EC00E6
:1005400047220330F2005E22B60A9A2A0D30F700E5
:10055000F70BA82A0230F2005E220D30F700F70BED
:10056000AF2AB6013608023C031CC22A36084D20C9
:10057000B700F0013708F10074220230EC00472286
:10058000B60AB22A8A110A1640280130F00038084B
:10059000F10074220034871707170A30EC00472255
:1005A00087130713003401306C02EE006D08023C23
:1005B000031DDC2A4030EE076E088038EF00F001A2
:1005C0006F08F100742200346B08F7000C307702DA
:1005D0000319F72A0A3077020319FF2A0D30770230
:1005E0000319052B0830770203190A2B0F2BF00192
:1005F0000130F10074220230EC0047221B2B013045
:10060000EC000230ED00D3221B2B0130EC00ED009A
:10061000D3221B2BF0011030F10074221B2B6B082E
:100620001F3C031C152B0730EB050130F0006B0855
:10063000F10074221B2B0034B630F700FA01F901E7
:10064000F8015A085B045C045D04031D292BF701C3
:10065000362B0310F81B352BDA0DDB0DDC0DDD0D11
:10066000FA0DF90DF80DF70B292BF8138A110A1260
:10067000DD2B5D080319AA2BE50061080319AA2BDD
:10068000E507031C442B4B2B7F30E502031CAA2BF0
:100690000319AA2B4F2B8130E5070318AA2B6508F5
:1006A000F700F801F901FA015E08E900E9175F08AF
:1006B000E8006008E7001830E500E601671C782BC9
:1006C0006408FA07031C6A2BF90A031D6A2BF80A4F
:1006D0000319E6176308F907031C712BF80A0319BD
:1006E000E6176208DF00DF175F08F8070318E61750
:1006F000E60DF80CF90CFA0CE90CE80CE70C031009
:10070000E50B5D2B0130F7070318AA2BF81B8F2B85
:10071000E90DFA0DF90DF80DF7030319AA2BE91FDE
:10072000A02BFA0A031DA02BF90A031DA02BF80A1F
:10073000031DA02BF80CF90CFA0CF70A0319AA2BCD
:100740005E08E6006208E606E61FA82BF817AE2B47
:10075000F813AE2BF701F801F901FA01000000349B
:1007600010108E018F01A6010030A00010143D3042
:1007700081000530A5000B118B16A008031DC12BAD
:10078000BD2B0F08FA000E08F7000F087A02031DB0
:10079000C12B7708D9007A08DA00FA012608F90097
:1007A0005908F7005A08F8007A08DD007908DC00DB
:1007B0007808DB007708DA001C2BE001DF01DE019E
:1007C0008130DD007A08E4007908E3007808E2006F
:1007D0007708E10039237A08D8007908D70078082B
:1007E000D6007708D5005808E0005708DF00560803
:1007F000DE005508DD005808E4005708E3005608FD
:10080000E2005508E10039230034871787160A30C3
:10081000EC00472287138712003480300318DE066D
:10082000E3015A08E2005E08E20659080319FA2CAF
:10083000E100F7005D080319032DE1020319A02C64
:100840000318232C5F2C5E08E700E7175F08E6001B
:100850006008E500E4010310E70CE60CE50CE40C8D
:10086000E10B2A2CE21F372C6314172D6310611043
:1008700063165C3084002D2D6312E21B492C611C31
:10088000542CE70CE60CE50CE40CF70A0319122DC6
:10089000542CE71B572C0310E40DE50DE60DE70D76
:1008A000F7030319122D492C6317BF2C63135A0841
:1008B000E200DA1F5D2CE7170B2DE7130B2D5D0807
:1008C000E100F7005908E1025A08E700E7175B0862
:1008D000E6005C08E500E4010310E70CE60CE50C1B
:1008E000E40CE10B6B2CE21F782CE314172DE310C2
:1008F0006110E316603084002D2DE312E21B8A2C78
:10090000611C952CE70CE60CE50CE40CF70A0319C6
:10091000122D952CE71B982C0310E40DE50DE60D28
:10092000E70DF7030319122D8A2CE317BF2CE313ED
:100930005E08E200DE1F9E2CE7170B2DE7130B2D40
:100940005E08E700E7175F08E6006008E500E21FC1
:10095000AD2CE7136315172D6311E40161105C30B2
:1009600084002D2DE21BD52C5A08E200611CBF2CFF
:10097000E70CE60CE50CE40CF70A0319122DE41F52
:10098000D02CE50A031DD02CE60A031DD02CE70A63
:10099000031DD02CE70CE60CE50CF70A0319122D09
:1009A000631B562CE31B972CF42C8030E706E71FC3
:1009B000DD2C172D5E08E200EA2C5A08E200E70859
:1009C000031DEA2CE608031DEA2CE508031DEA2CAA
:1009D000F7010B2DE71BF42C0310E40DE50DE60DDC
:1009E000E70DF70BEA2C122DE21FF82CE7170B2D61
:1009F000E7130B2D5D08F7005E08E7005F08E600CF
:100A00006008E5000B2D5908F7005A08E7005B085D
:100A1000E6005C08E5006708F8006608F90065086C
:100A2000FA004C2DF701F801F901FA014C2DE4010F
:100A3000E509E609E709E409E40A031D262DE50AAC
:100A4000031D262DE60A031D262DE70A6318362C02
:100A5000E318772C6319AC2CDA2C0008E507031C8B
:100A6000372DE60A031D372DE70A031961148403A5
:100A70000008E607031C3F2DE70A031961148403ED
:100A80000008801B442D803AE70703186114631A9D
:100A90003C2CE31A7D2CB22C0000003458080319BA
:100AA000142EE4005C080319142EE4020318592DD7
:100AB0005E2D7F30E4070318142E642D8130E4028C
:100AC000031C142E0319142E6408F700F801F90111
:100AD000FA01E3015908E200E2175A08E1005B0855
:100AE000E0001930E4005F08E0020318872D0130B0
:100AF000E1020318872DE2020318872DE302031891
:100B0000872DE30AE20AE10A5F08E007B92D5E08D3
:100B1000E1020318A22D0130E2020318A22DE30224
:100B20000318A22DE30AE20A5E08E1075F08E00766
:100B3000031CB92DE10A031DB92DE20A031DB92DCD
:100B4000E30AB92D5D088038E2020318B82D0130A0
:100B5000E3020318B82DE30A5D088038E2075E0857
:100B6000E107031C962DE20A031D962DE30A962D3C
:100B70007A14E40BBC2DC72D0310E00DE10DE20D3E
:100B8000E30D0310FA0DF90DF80DE50D732D651C3D
:100B9000CF2D0310F80CF90CFA0CE50CD22DF7034D
:100BA0000319142EE51BFB2D0310E00DE10DE20DE2
:100BB000E30D5F08E0020318E72D0130E10203189E
:100BC000E72DE2020318E72DE302031C0A2E5E085C
:100BD000E1020318F22D0130E2020318F22DE302C4
:100BE000031C0A2E5D088038E2020318FB2D013039
:100BF000E302031C0A2EFA0A031D0A2EF90A031D3A
:100C00000A2EF80A031D0A2EF70A0319142EF80CEF
:100C1000F90CFA0C5908E4005D08E406E41F122EF2
:100C2000F817182EF813182EF701F801F901FA0138
:100C3000000000340130EC00ED00D322D50155084E
:100C40000F3C031C282E2030EB00E422D50A1F2E77
:100C50000130EC00ED00D3220034861F312E061B3C
:100C6000352E1430EC0047222D2EA00100345F08F1
:100C7000E6006308E606E61F422E03110310DF1BA1
:100C80000314752E5F08E6006208E7005E08E702BD
:100C90000319502EE61F752E0308013A8300752EA6
:100CA0006308E7005F08E70203195C2EE61F752E54
:100CB0000308013A8300752E6408E7006008E70224
:100CC0000319682EE61F752E0308013A8300752E5E
:100CD0006508E7006108E7020319742EE61F752E08
:100CE0000308013A8300752E031000340130D90047
:100CF0005508F7005608F8005708F9005808FA0098
:100D0000F8137708DA007808DB007908DC007A0845
:100D1000DD00E101E0012030DF008230DE005D080F
:100D2000E5005C08E4005B08E3005A08E2003726AF
:100D3000031CB52E5808E0005708DF005608DE00F7
:100D40005508DD00CD30E400CC30E3004C30E2004B
:100D50007B30E10039237A08D8007908D700780879
:100D6000D6007708D500D90A782E5908F800003443
:100D7000071607170A30EC004722071207138A11DB
:100D80000A16DE2C8316061083120610A630F70012
:100D9000F70BC82E000083160614061483120618DB
:100DA000D42E0030F800EF2E1530F700F70BD62EBA
:100DB0000000831606148312061CE02E5010E12E4C
:100DC00050144F30F700F70BE32E00000000501CCA
:100DD000ED2E0130F800EF2EEF2E0030F800003439
:100DE000D1015108073C031C1E2F831606108312E5
:100DF00006100330F700F70BFB2E0310D00C031C7A
:100E00000B2F831606140000831206180A2F0030D9
:100E1000F800202F142F8316061083120610061CCC
:100E2000142F0030F800202F1030F700F70B162F8A
:100E30000000831606148312D10AF12E0130F80047
:100E400000348E30F7005508F8005408F900FA0114
:100E5000F808031D352F7908F800F9010830F7026A
:100E6000F808031D352FF7013D2F0310F81B3C2F09
:0E0E7000F90DF80DF703352FF81300000034CC
:101000000408DF00E001D71F0A282D30EB008A1109
:10101000E4228A15D71756080319AE287F305602E6
:10102000031C6928D600E5010430E6000310D90D41
:10103000D80DD70DE00DE60B162804305602031824
:10104000292803305602031DA3280A306002031C1E
:10105000A3280330D602E50A50210310D90DD80D7C
:10106000D70DE00D39210230E6000310E00CD70C5B
:10107000D80CD90CE60B352850210430E6000310BB
:10108000E10CE20CE30CE40CE60B3F283921502183
:101090006308E4006208E3006108E200E10139212D
:1010A00050216208E4006108E300E101E201392116
:1010B000E0191D28D608031D6228D90AD80AD70AC4
:1010C000E00AA3280310D90DD80DD70DE00DD603E3
:1010D0001D28D609D60A7F30D607E5010430E60080
:1010E0000310D90DD80DD70DE00DE60B7028043094
:1010F000D60705305602031CB02850210310D90D25
:10110000D80DD70DE00D0310D90DD80DD70DE00D7A
:1011100039210310D90DD80DD70DE00DE50A0330A4
:10112000E6000310E00CD70CD80CD90CE60B912884
:101130000330D602601E79280310E00CD70CD80CBF
:10114000D90CD6037928D609D60A0330D607650804
:10115000DB006508DD005F0ADD07DD285F0AE500CA
:101160003030EB008A11E4228A15DF080319372991
:101170002E30EB008A11E4228A156508DE00DE03BA
:101180005F085E02031CC6285F08DE00DE08031944
:10119000D0283030EB008A11E4228A15DE0BC928F2
:1011A0006508E6005F0AE60203185929D6035F0ABC
:1011B000DD006508DD025D08DB006008DA00560826
:1011C0000319E728DC000310DA0CDC0BE3285D08C8
:1011D0000319372930305A07EB008A11E4228A15A7
:1011E0005B08031DFB28DF08031937292E30EB00AD
:1011F0008A11E4228A15DB03DD0303193729560817
:1012000003190729DC000310DA0DDC0B03295A0847
:10121000E0026008E1005708E2005808E3005908BE
:10122000E4000310D90DD80DD70DE00D0310D90D32
:10123000D80DD70DE00D6408D907031C2429D80F59
:101240002429D70F2429E00A6308D807031C2B2977
:10125000D70F2B29E00A6208D7070318E00A6108B4
:10126000E0070310D90DD80DD70DE00DDD280000E3
:1012700059296408D907031C4229D80F4229D70FDE
:101280004229E00A6308D807031C4929D70F4929D6
:10129000E00A6208D7070318E00A6108E007003493
:1012A0006008E1005708E2005808E3005908E4002C
:1012B0000034000000340130C1004310CB01CA01EA
:1012C000C901C8012008023C031D9429061B6C2992
:1012D00083160614402B8312861B94294708CB00E3
:1012E0004608CA004508C9004408C8004314013034
:1012F000C1008A111A268A150630EC000130ED0073
:101300008A11D3228A15D00150088A11A5208A1586
:10131000D00AEB008A11E4228A1507305002031D1F
:1013200084298A112D268A154108FD3E03183B2B7E
:10133000033E442BC20B9E290230C1003B2B8A1175
:10134000C2268A15F808031DBC298A111A268A1597
:10135000D00150088A11B1208A15D00AEB008A11F9
:10136000E4228A150E305002031DA929CB01CA01BF
:10137000C901C80143100A2BCC30D0008A11F026D5
:101380008A15BE30D0008A11F0268A15C0014008A7
:10139000083C031CFA2936304007D000D101D101A6
:1013A0005108073C031CF22983160610831206100D
:1013B0000430F700F70BDA2900008316061400004A
:1013C0000000000000000000061483120618EA293D
:1013D0000310EB290314D20C2130F700F70BEE2990
:1013E000D10AD0295208F8005008840078088000FB
:1013F000C00AC7293630D0000930D100D501D60146
:10140000510856020318192A56085007840000088C
:10141000D3000830D20053085506D400D40C550828
:101420000318183AD500D50CD30CD20B0B2AD60AC8
:10143000002AD5080319202A0030F800222A222A7F
:101440000130F800F80803190A2B0310B60C371CFA
:101450002A2AB6173708FA003608D4003708D5000C
:101460008A1121278A157A08C7007908C6007808EA
:10147000C5007708C40003144708DC004608DB00F9
:101480004508DA004408D900E001DF01DE017D30C3
:10149000DD008A110D248A157708D0007808D10064
:1014A0007908D2007A08D300D5013C08D4008A110B
:1014B00021278A150314DC01DB01DA018330D9000E
:1014C0007A08E0007908DF007808DE007708DD00A0
:1014D0008A110D248A157708D4007808D500790878
:1014E000D6007A08D700DB005608DA005508D90084
:1014F0005408D800DF01DE01DD018330DC008A11F1
:101500004E258A1503105308DC005208DB005108F1
:10151000DA005008D9007A08E0007908DF0078087E
:10152000DE007708DD008A110D248A157A08C700CD
:101530007908C6007808C5007708C4000314470876
:10154000DC004608DB004508DA004408D9004B08F7
:10155000E0004A08DF004908DE004808DD008A1183
:101560000D248A157A08CF007908CE007808CD00BE
:101570007708CC008A111A268A154F08D8004E0821
:10158000D7004D08D6004C08D5008A1176268A155A
:101590007808063CD000EC000130ED008A11D3221F
:1015A0008A15E101E001DF01DE014F08E5004E0888
:1015B000E4004D08E3004C08E2008A1137268A1542
:1015C0000318E42A031DE92A2030EB008A11E422E3
:1015D0008A15013084004F08D9004E08D8004D0804
:1015E000D7004C08D60000202030EB008A11E422FE
:1015F0008A15431C002B1030EB008A11E4228A1557
:101600001130EB008A11E4228A154330EB008A1175
:10161000E4228A150130C1008A11C2268A15F80811
:10162000031D292B8A111A268A15D00150088A1108
:10163000B1208A15D00AEB008A11E4228A150E30F7
:101640005002031D162BCB01CA01C901C80143106A
:101650003A2BCC30D0008A11F0268A154430D000C5
:101660008A11F0268A158316061083120614043098
:10167000C200C1013B2B8A11B0238A15622983164F
:1016800083128A110A160B2F0A148A140A11820770
:101690009A290C2B9F29271127088316870083126C
:1016A0000715A40183160108C039203881000930CC
:1016B000831203178D008F0183168C130C14831271
:1016C0000C080313B6008A111A268A153608F23E52
:1016D0000318CF2C0E3E182DB70137088A11C420ED
:1016E0008A15B70AEB008A11E4228A150E303702F8
:1016F000031D6D2B0030F800043892001330831660
:101700009200831207110C30970096010A30950061
:10171000CF2CB70137088A11D7208A15B70AEB00FA
:101720008A11E4228A150E303702031D8A2B0030FD
:10173000F8000438920027308316920083120711B4
:101740000C309700960114309500CF2CB701370864
:101750008A11EA208A15B70AEB008A11E4228A1559
:101760000E303702031DA72B0030F800043892001A
:10177000633083169200831207110C309700960194
:1017800032309500CF2CB70137088A11FD208A1519
:10179000B70AEB008A11E4228A150E303702031DC6
:1017A000C42B0030F80004389200C7308316920032
:1017B000831207110C309700960164309500CF2CEE
:1017C000B70137088A1110218A15B70AEB008A1170
:1017D000E4228A150F303702031DE12B0030F80098
:1017E00005389200633083169200831207110C3083
:1017F0009700960132309500CF2CB70137088A1137
:1018000024218A15B70AEB008A11E4228A150E30CA
:101810003702031DFE2B0030F80005389200F93026
:1018200083169200831207110C30970096017D30C9
:101830009500CF2C0030F800920000308316920003
:101840008312B70137088A1137218A15B70AEB00CE
:101850008A11E4228A150E303702031D222C0B3028
:1018600097008530900003309600E830950083168D
:101870000C158312CF2CB70137088A114A218A151B
:10188000B70AEB008A11E4228A150E303702031DD5
:101890003C2C07309600D0309500CF2CB70137088C
:1018A0008A115D218A15B70AEB008A11E4228A1594
:1018B0000E303702031D4F2C1330960088309500F0
:1018C000CF2CB70137088A1170218A15B70AEB00AF
:1018D0008A11E4228A150E303702031D622C27304C
:1018E000960010309500CF2CB70137088A1183215C
:1018F0008A15B70AEB008A11E4228A150E303702E6
:10190000031D752C4E30960020309500CF2CB7016A
:1019100037088A1196218A15B70AEB008A11E4224A
:101920008A150E303702031D882CC33096005030C4
:101930009500CF2CB70137088A11A9218A15B70A5B
:10194000EB008A11E4228A150E303702031D9B2C0E
:10195000B5309000F430960024309500CF2CB701BC
:1019600037088A11BC218A15B70AEB008A11E422D4
:101970008A150E303702031DB02C83160C1100306F
:10198000F800043883129200093083169200831203
:1019900007110C309700960105309500CF2C2008D8
:1019A000023C0319D42CCF2C061BE82C831601080B
:1019B000C0390738810087308312900010108316D9
:1019C0000C1183122715270883168700142D831204
:1019D000861B122D36080D3C031DF02CB601F12C90
:1019E000B60A093003178D008F0103133608031759
:1019F0008C0083168C130C15831203130B08F7004D
:101A00008B138316031755308D00AA308D008C146C
:101A10008C18082D0C117708831203138B048A117C
:101A20002D268A15632B831683128A110A162B2FF3
:101A30000A148A100A1582076C2B892BA62BC32B3C
:101A4000E02BFD2B1A2C3B2C4E2C612C742C872C5C
:041A50009A2CAF2CF1
:1020000084011F308305073083169F00FF30831241
:10201000A700831681130108C03907388100873073
:10202000831290001010271227088316870083124E
:102030000712A71327088316870083128713A71296
:102040002708831687008312871227132708831611
:1020500087008312071327152708831687000614A5
:1020600086148312A710270883168700831287100F
:10207000A711270883168700831287110A128A2A5C
:102080000A16F0014030F1000A1274220A160230DA
:10209000EC000A1247220A160330B6008030B8005E
:1020A0000A12C5220A16B60B4E28B70137080A12C3
:1020B000CF210A16B70AB8000A12C5220A1605303F
:1020C0003702031D5628F0010330F1000A12742272
:1020D0000A160230EC000A1247220A16F0014830B4
:1020E000F1000A1274220A160230EC000A1247228A
:1020F0000A160E30B8000A12C5220A160A30B800B5
:102100000A12C5220A160E30B8000A12C5220A1693
:102110000530B6008030B8000A12C5220A16B60B88
:102120008A28F0010330F1000A1274220A160230E4
:10213000EC000A1247220A160A12CB220A1683164C
:102140000C1483128B15C0308B04B60136080A12AA
:1021500055200A1600380319B328B60AEB000A12F4
:10216000E4220A16A628B60136080A12D9210A1650
:10217000B60AEB000A12E4220A160D303602031DDD
:10218000B4280130EC000230ED000A12D3220A1606
:10219000B60136080A12EB210A16B60AEB000A123B
:1021A000E4220A160F303602031DC9280830B60093
:1021B000FA30EC000A1247220A16B60BD8280A1287
:1021C000B0230A167A08AB007908AA007808A9009B
:1021D0007708A8003510A001083003178D008F0183
:1021E00083168C130C1483120C080313B4003408E8
:1021F000FC3E0318302F043E582F3518E929BA0148
:102200003A080A1255200A16003803190D29BA0A8D
:10221000EB000A12E4220A160029BA013A080A124F
:102220005B200A16BA0AEB000A12E4220A160D30E5
:102230003A02031D0E290A12CB220A160830BA00F0
:10224000FA30EC000A1247220A16BA0B20290A12A9
:1022500005240A160830BA00FA30EC000A124722A8
:102260000A16BA0B2C290A12B0230A167A08B900EA
:102270007908B8007808B7007708B600E001DF01F8
:102280007930DE008830DD003908E4003808E300EA
:102290003708E2003608E1000A1239230A167708E7
:1022A000BA007808BB007908BC007A08BD000314A6
:1022B0002B08DC002A08DB002908DA002808D900EE
:1022C0003908E0003808DF003708DE003608DD0096
:1022D0000A120D240A163D08DB003C08DA003B0810
:1022E000D9003A08D8007A08DF007908DE007808BB
:1022F000DD007708DC000A124E250A167A08AF00C6
:102300007908AE007808AD007708AC00E630E00050
:10231000E930DF001D30DE008430DD002B08E400F2
:102320002A08E3002908E2002808E1000A123923FC
:102330000A167708BA007808BB007908BC007A084A
:10234000BD00E0007908DF007808DE007708DD00D6
:102350002F08E4002E08E3002D08E2002C08E1001D
:102360000A1239230A167708BE007808BF007908D8
:10237000C0007A08C100E0007908DF007808DE00BC
:102380007708DD00CC30E400BC30E3000C30E20024
:102390005730E1000A1239230A162830DB006B306F
:1023A000DA006E30D9009C30D8007A08DF00790856
:1023B000DE007808DD007708DC000A124E250A16D8
:1023C0007A08B3007908B2007808B1007708B00045
:1023D00035140A12CB220A160130EC000230ED004F
:1023E0000A12D3220A16B60136080A12FF210A166B
:1023F000B60AEB000A12E4220A1604303602031D64
:10240000F4290330B7002030EB000A12E4220A1648
:10241000B70B032A4330EB000A12E4220A16783085
:10242000EB000A12E4220A160330B8002030EB0059
:102430000A12E4220A16B80B162A0630B900390827
:102440000A12FF210A16B90AEB000A12E4220A1640
:102450000A303902031D1F2AC8013E30C700470851
:10246000413C031C442A470884004808C80ACA00A3
:1024700003178D008F0183168C130C1483120C0824
:1024800080000313C70A2F2A0A12B0230A167A08FB
:10249000B9007908B8007808B7007708B600200BB3
:1024A000522AA92A061B552AEE2B861BA82A3D086C
:1024B000C1003C08C0003B08BF003A08BE00C8018C
:1024C0003E30C7004708413C031C8D2A4808C80A13
:1024D000C900470884000008CA00490803178D0096
:1024E0008F0103134A0803178C0083168C130C15F5
:1024F000831203130B08F7008B1383160317553051
:102500008D00AA308D008C148C18842A0C11770849
:10251000831203138B04C70A622A0A121A260A16A8
:102520000630EC000130ED000A12D3220A16C90170
:1025300049080A1288200A16C90AEB000A12E42286
:102540000A1608304902031D982A0A122D260A1677
:10255000ED2B3908E1003808E0003708DF003608C5
:10256000DE00E501E4014830E3008530E2000A12B4
:1025700037260A16031CD72A0A121A260A16C90178
:1025800049080A1295200A16C90AEB000A12E42229
:102590000A160B304902031DC02A0330CA0021303D
:1025A000EB000A12E4220A16CA0BCF2AED2B2B08E5
:1025B000DB002A08DA002908D9002808D8003908E1
:1025C000DF003808DE003708DD003608DC000A12BC
:1025D0004E250A167708C9007808CA007908CB008A
:1025E0007A08CC0003147A08DC007908DB0078084C
:1025F000DA007708D900E001DF01DE017F30DD007D
:102600000A120D240A167708CD007808CE00790842
:10261000CF007A08D000E0007908DF007808DE00FB
:102620007708DD002F08E4002E08E3002D08E20003
:102630002C08E1000A1239230A167A08BD0079082D
:10264000BC007808BB007708BA0003143D08DC0022
:102650003C08DB003B08DA003A08D9004108E000FA
:102660004008DF003F08DE003E08DD000A120D24AE
:102670000A167A08C5007908C4007808C3007708EC
:10268000C2000A121A260A16D5014208F7004308AA
:10269000F8004408F9004508FA00F8134208D6008B
:1026A0007808D7004408D8004508D900E101E001C6
:1026B0007A30DF008830DE004508E5004408E40099
:1026C0007808E3004208E2000A1237260A16031CC3
:1026D000862B4508E0004408DF004308DE0042087E
:1026E000DD006F30E4001230E3000330E2007530AB
:1026F000E1000A1239230A167A08C5007908C400D5
:102700007808C3007708C200D50A452B5508F800A1
:102710007808C6004508D8004408D7004308D6000A
:102720004208D5000A1276260A167808063CC90027
:10273000EC000130ED000A12D3220A16E101E0019B
:10274000DF01DE014508E5004408E4004308E3003A
:102750004208E2000A1237260A160318B12B031D9D
:10276000B62B2030EB000A12E4220A16C608031D1D
:10277000C92B023084004508D9004408D80043081A
:10278000D7004208D6000A128A1500200A168A11BC
:10279000D82B033084004508D9004408D8004308EA
:1027A000D7004208D6000A128A1500200A168A119C
:1027B0000C30EC000130ED000A12D3220A16460854
:1027C0000A123D200A16C900EB000A12E4220A167A
:1027D0004630EB000A12E4220A16442AB401302FD4
:1027E0003518DC2CBA013A080A1255200A160038AE
:1027F0000319002CBA0AEB000A12E4220A16F32B82
:10280000BA013A080A125B200A16BA0AEB000A1249
:10281000E4220A160D303A02031D012C0A12CB22C3
:102820000A160830BA00FA30EC000A1247220A16DB
:10283000BA0B132C0A1205240A160830BA00FA3013
:10284000EC000A1247220A16BA0B1F2C0A12B023F8
:102850000A167A08B9007908B8007808B70077082E
:10286000B600E001DF017930DE008830DD00390894
:10287000E4003808E3003708E2003608E1000A12F5
:1028800039230A167708BA007808BB007908BC001B
:102890007A08BD0003142B08DC002A08DB00290895
:1028A000DA002808D9003908E0003808DF003708C6
:1028B000DE003608DD000A120D240A163D08DB0092
:1028C0003C08DA003B08D9003A08D8007A08DF0053
:1028D0007908DE007808DD007708DC000A124E2552
:1028E0000A167A08AF007908AE007808AD007708BC
:1028F000AC00E630E000E930DF001D30DE0084305F
:10290000DD002B08E4002A08E3002908E20028087B
:10291000E1000A1239230A167708BA007808BB00CA
:102920007908BC007A08BD00E0007908DF0078086B
:10293000DE007708DD002F08E4002E08E3002D08F4
:10294000E2002C08E1000A1239230A167708BE00BB
:102950007808BF007908C0007A08C100E000790853
:10296000DF007808DE007708DD00CC30E400BC3002
:10297000E3000C30E2005730E1000A1239230A1656
:102980002830DB006B30DA006E30D9009C30D80084
:102990007A08DF007908DE007808DD007708DC00BF
:1029A0000A124E250A167A08B3007908B200780890
:1029B000B1007708B00035140A12B82E0A1601309B
:1029C000EC000230ED000A12D3220A16B6013608D6
:1029D0000A120E220A16B60AEB000A12E4220A169E
:1029E00004303602031DE72C0330B7002030EB0023
:1029F0000A12E4220A16B70BF62C4C30EB000A122E
:102A0000E4220A167830EB000A12E4220A16033098
:102A1000B8002030EB000A12E4220A16B80B092D88
:102A20000630B90039080A120E220A16B90AEB005C
:102A30000A12E4220A160A303902031D122D04304C
:102A4000C8003E30C7004708413C031C382D4708EA
:102A500084004808C80ACA0003178D008F01831636
:102A60008C130C1483120C0880000313C70A232D47
:102A70000A12B0230A167A08B9007908B800780853
:102A8000B7007708B600200B462D9E2D061B492D5A
:102A9000EC2E861B9D2D3D08C1003C08C0003B0864
:102AA000BF003A08BE000430C8003E30C7004708E7
:102AB000413C031C822D4808C80AC900470884000D
:102AC0000008CA00490803178D008F0103134A0844
:102AD00003178C0083168C130C15831203130B0839
:102AE000F7008B138316031755308D00AA308D0025
:102AF0008C148C18792D0C117708831203138B0416
:102B0000C70A572D0A121A260A160930EC0001309E
:102B1000ED000A12D3220A16C90149080A126D20D3
:102B20000A16C90AEB000A12E4220A160530490205
:102B3000031D8D2D0A122D260A16EB2E3908E100F1
:102B40003808E0003708DF003608DE00E501E40160
:102B50004830E3008530E2000A1237260A16031CCB
:102B6000CC2D0A121A260A16C90149080A12772022
:102B70000A16C90AEB000A12E4220A160C304902AE
:102B8000031DB52D0330CA002130EB000A12E422E8
:102B90000A16CA0BC42DEB2E2B08DB002A08DA001C
:102BA0002908D9002808D8003908DF003808DE00D5
:102BB0003708DD003608DC000A124E250A167708B1
:102BC000C9007808CA007908CB007A08CC00031441
:102BD0007A08DC007908DB007808DA007708D90089
:102BE000E001DF01DE017F30DD000A120D240A164C
:102BF0007708CD007808CE007908CF007A08D00099
:102C0000E0007908DF007808DE007708DD0033088F
:102C1000E4003208E3003108E2003008E1000A1263
:102C200039230A167A08BD007908BC007808BB0071
:102C30007708BA0003143D08DC003C08DB003B08C1
:102C4000DA003A08D9004108E0004008DF003F08F8
:102C5000DE003E08DD000A120D240A167A08C500BF
:102C60007908C4007808C3007708C2000A121A263F
:102C70000A16D5014208F7004308F8004408F90095
:102C80004508FA00F8134208D6007808D70044082F
:102C9000D8004508D900E101E0017A30DF00883032
:102CA000DE004508E5004408E4007808E300420837
:102CB000E2000A1237260A16031C7B2E4508E000A4
:102CC0004408DF004308DE004208DD006F30E40006
:102CD0001230E3000330E2007530E1000A123923BC
:102CE0000A167A08C5007908C4007808C300770876
:102CF000C200D50A3A2E5508F8007808C6004508E3
:102D0000D8004408D7004308D6004208D5000A126C
:102D100076260A167808063CC900EC000130ED0062
:102D20000A12D3220A16E101E001DF01DE014508A3
:102D3000E5004408E4004308E3004208E2000A1208
:102D400037260A160318A62E031DAB2E2030EB00E3
:102D50000A12E4220A16C608031DC72E0330C90052
:102D60002030EB000A12E4220A16C90BB02E003004
:102D700084004508D9004408D8004308D700420819
:102D8000D6000A128A1500200A168A11D62E0330A0
:102D900084004508D9004408D8004308D7004208F9
:102DA000D6000A128A1500200A168A110C30EC008F
:102DB0000130ED000A12D3220A1646080A124520F5
:102DC0000A16C900EB000A12E4220A164830EB008A
:102DD0000A12E4220A16382D0230B400302F0A12EB
:102DE00005240A160130EC000230ED000A12D3224D
:102DF0000A16B60136080A121D220A16B60AEB0098
:102E00000A12E4220A1610303602031DFA2E1010A0
:102E10000A128A155B290A168A110330B400302F72
:102E20000A1205240A160130EC000230ED000A12E5
:102E3000D3220A16B60136080A1232220A16B60A38
:102E4000EB000A12E4220A1610303602031D1B2F73
:102E50000A128A154B2B0A168A110130B400302F42
:102E6000083003178D008F010313340803178C00FB
:102E700083168C130C15831203130B08F7008B13A6
:102E80008316031755308D00AA308D008C148C18D2
:102E9000472F0C117708831203138B040A122D2677
:102EA0000A160A30EC000A1247220A16F7286300B5
:102EB0000A148A140A158207F02BFD28EF2E102F12
:1042000000000000000000000000000000000000AE
:0442100001000D009C
:02400E00393F38
:00000001FF
;PIC16F876
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lc.PJT
0,0 → 1,138
[PROJECT]
Target=lc.HEX
Development_Mode=2
Processor=0x876F
ToolSuite=CCS
 
[Directories]
Include=C:\PROGRAM FILES\PICC\DEVICES\;C:\LIBRARY\CCS;C:\Program Files\PICC\Drivers;
Library=
LinkerScript=
 
[Target Data]
FileList=lc.c;
BuildTool=C-COMPILER
OptionString=+FM;
AdditionalOptionString=
BuildRequired=0
 
[lc.c]
Type=4
Path=
FileList=16F876.H;16F877_R.H;LC.H;LCD.C;
BuildTool=
OptionString=
AdditionalOptionString=
 
[Fuses]
Frequency=4000000.000000
ClockSource=1
Mode=0
WDTEnable=0
WDTBreak=0
WDTPrescale=710
StackBreak=0
Freeze=1
EmulatorMemory=1
ShortWrites=0
PwrSetting=0
OSC_Settings=1
ProgBankRegEnable=0
BankRegStartAddress=0
BankRegEndAddress=0
DisableIoPins=0
12CXXX_MCLR_ENABLE=0
CPP2_ENABLE=0
LPSC_ENABLE=0
MCLRPU_ENABLE=0
 
[Trace-Config]
GetAddress=1
AddressWidth=5.000000
GetOpcode=1
OpcodeWidth=5.000000
GetLabel=1
LabelWidth=8.000000
GetInstruction=1
InstructionWidth=10.000000
InstructionRaw=1
GetSrcAddr=1
SrcAddrWidth=4.000000
SrcAddrRaw=1
GetSrcValue=1
SrcValueWidth=4.000000
GetDstAddr=1
DstAddrWidth=4.000000
DstAddrRaw=1
GetDstValue=1
DstValueWidth=4.000000
GetExtInputs=1
ExtInputsWidth=9.000000
ExtInputsHexFmt=0
GetTimeStamp=1
TimeStampWidth=11.000000
TimeStampDiplay=0
TraceLines=100
TraceFull=0
CodeCoverageReset=1
 
[16F876.H]
Type=5
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[16F877_R.H]
Type=5
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[LCD.H]
Type=5
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[LCD.C]
Type=5
Path=C:\LIBRARY\CCS\
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[LC.H]
Type=5
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[KBD.C]
Type=5
Path=C:\LIBRARY\CCS\
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=d:\pefi\projekty\lcmetr\lc.h
2=c:\library\ccs\lcd.c
3=d:\pefi\projekty\lcmetr\lcd.h
4=lc.c
 
[Windows]
2=0000 d:\pefi\projekty\lcmetr\lc.c 25 65 589 488 9 0
1=0020 681 10 1081 572 9 0
0=0010 66 135 546 707 2 4 16
Stopwatch=454 404 722 563 9 0
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lc.c
0,0 → 1,883
//**********************************************************************
// LCT-METER/PULSER
//**********************************************************************
// (c) OK1XGL 2004
// verze 1.00 - uvodni verze 10.1.2004
// verze 1.01 - pridano ukladani vlastni Cp/Lp do pameti EEPROM
// - pridano ukladani stavu (mod, parametry modu ) do pameti EEROM
//
//
// Popis funkcnosti:
// -----------------
// Meri kapacitu, indukcnost, teplotu a jako doplnek obsahuje generator impulzu.
// Jednotlive druhy mereni se prepinaji stiskem tlacitka MODE. Stiskem tlacitka NUL lze
// vynulovat mereni (odecteni vlivu mericich privodu, u mereni teploty odecteni napr. pro mereni otepleni).
//
// Mereni L a C:
// -------------
// Mereni se provadi merenim kmitoctu mericiho oscilatoru. Neznama Lx se pripojuje do serie s vnitrni L oscilatoru.
// Neznama Cx se pripojuje paralelne k vnitrni C oscilatoru. Vypocet nezname Cx/Lx se provadi pomoci nasledujicich vzorcu:
// Cx=((f1^2/f2^2)-1)*C Lx=((f1^2/F2^2)-1)*L
// Pripadne se od vysledku odecte hodnota Cv nebo Lv, ktera se ziska stisknutim NUL
// f1 - kmitocet mericiho oscilatoru, ke kteremu neni pripojena zadna Lx nebo Cx, ziska se pri kalibraci
// f2 - kmitocet mericiho oscilatoru s pripojenou neznamou Lx nebo Cx
// C - kapacita vnitrniho C oscilatoru, ziska se pri kalibraci
// L - indukcnost vnitrni L oscilatoru, ziska se kalibraci
//
// Kalibrace:
// ----------
// Provadi se pri zapnuti pristroje a probiha takto:
// Zmeri se kmitocet mericiho oscilatoru f1 ,ke kteremu neni pripojena zadna Lx nebo Cx.
// Pripoji se kalibracni kondenzator Ck o zname hodnote, mel by byt co nejpresnejsi a nejstabilnejsi.
// Zmeri se kmitocet mericiho oscilatoru f2.
// Vypoctou se hodnoty L a C podle vzorcu:
// C=(Ck*F2^2)/(F1^2-F2^2) L=(1/(4*PI^2*F1^2*C)
// Odpoji se kalibracni kondenzator Ck a pristroj je pripraven k mereni L a C
//
//
// Mereni teploty:
// ---------------
// Kladna merici svorka je pripojena primo na vstup procesoru. Pro mereni teploty se pouziva teplomer
// fy Dallas DS18B20, se kterym se komunikajue po I2C sbernici.
//
//
// Generovani pulzu:
// -----------------
// Kladna merici svorka je pripojena primo na vstup procesoru. Jsou generovany kladne pulzy se zvolenou sirkou.
// Nulove pulzy maji stejnou sirku, tedy perioda je dvojnasobek sirky pulzu.
//
//
//
// Poznamky k implementaci:
// ------------------------
//
// 1) mereni L a C
// ----------------
// Zakladem je mereni kmitoctu. Presnost mereni byla zvolena na 4Hz, tedy merici perioda bude 250ms. Pro citani impulzu je
// pouzit 16 bitovy citac TMR1, ktery je rozsiren o dalsich 8 bitu promennou counter_H. Pretecenim TMR1 se v preruseni zvysi
// hodnota counter_H o jednicku. Merici periodu odmeruje 8 bitovy citac TMR0, kteremu je predrazen preddelic :256. Cita
// takty procesoru. TMR0 pretece kazdych 50ms. Promenna sampler_H obsahuje pocet potrebnych 50ms jednotek pro dosazeni
// pozadovaneho casu. Prommena sampler_H se dekrementuje v preruseni. Po uplynuti merici periody (250ms) se zastavi citani
// TMR1, ktery spolu s hodnotou v counter_H bude obsahovat mereny kmitocet s presnosti 4Hz.
// Promenou freq_done se oznami ukonceni mereni kmitoctu. Hodnota v TMR1 a counter_H se prevede na realne cislo, ktere se
// dale pouzije pro vypocty.
//
// 2) mereni teploty
// -----------------
// Vyuziva se teplomeru fy Dallas DS18B20, ktery komunikuje po I2C sbernici. Pro tento mod se sepne rele, ktere pripoji
// kalibracni kondenzator Ck. Tim dojde k pripojeni svorek na vstup portu pro teplomer. Mereni teploty probiha tak, ze se
// vysle prikaz do teplomeru aby zmeril teplotu a po uplynuti potrebne doby konverze se z teplomeru precte zmerena teplota a
// zobrazi se. Pro odmereni doby konverze se vyuziva mereni frekvence, ktere trva 250ms.
//
// 3) Generovani pulzu
// -------------------
// Pro tento mod se sepne rele, ktere pripoji kalibracni kondenzator Ck. Tim dojde k pripojeni svorek na vystup portu
// pro pulser. Pro generovani pulzu je vyuzivana jednotka PWM1 pro pulzy do sirky 1ms a pro pulzy delsi pak jednotka CCP1.
// Generovani pulzu PWM1 jednotkou je zcela autonomni, jednotce se nastavi perioda (dvojnasobek sirky pulzu) a sirka pulzu
// a generovani probiha mez zasahu programu. Jednotka CCP1 generuje periodicke preruseni po dobe urcene sirkou pulzu.
// Vlastni impulz je generovan v preruseni, kde se periodicky strida nastaveni portu do log.1 a do log.0
//
// 4) Cteni tlacitek
// -----------------
// Pro cteni tlacitek je vyuzivano preruseni od zmeny na portu B. Pri zmene stavu nektereho z tlacitek toto preruseni
// nastavi promenou freq_done. Na miste v programu, kde se testuje tato promenna se precte stav tlacitek a podle
// jejich stavu se dal pokracuje.
//
// 5) Zakladni smycky programu
// ---------------------------
// Hlavni smycka programu je koncipovana jako stavovy automat, kdy jednotlive stavy predstavuji jednotlive mody mereni.
// V jednotlivych stavech se volaji hlavni funkce jednotlivych modu mereni. Tyto funkce jsou koncipovany jako stavove
// automaty, ktere provedou podle potreby uvodni akci a dale sleduji stav promenne freq_done. Na zaklade tohoto stavu
// pokracuji dale nebo prechazeji do stavu jineho. freq_done ma tyto stavy:
// F_PEACE -klidovy stav
// F_DONE- mereni kmitoctu dokonceno
// F_KEY- mereni kmitoctu preruseno stiskem nejakeho tlacitka.
// Stav F_DONE je vyuzivan v modu mereni Lx a Cx a dale v modu mereni teploty se vyuziva k odmerovani casu.
// Pri stavu F_KEY se precte stav tlacitek a pri stisku tlacitka MODE se opousti hlavni funkce aktivniho modu mereni a
// prechazi se zpet se do hlavni smycky programu. V hlavni smycce programu se nasledne prejde do nasledujiciho modu mereni.
// Pri stisku tlacitka NUL se provede pozadavana akce, a zustava se v danem modu mereni.
 
 
 
#include <16f876.h>
#include <16F877_reg.h>
#include "lc.h"
#include <lcd.c>
#include <tm.c>
#include <math.h>
 
//#define FREQ // jen mereni frekvence mericiho oscilatoru, urceno pro jeho kalibraci
// pripojime citac na vystup mericiho oscilatoru a musi ukazovat totez co je na displeji, pokud tomu tak neni,
// napravu provedeme zmenou konstanty CORIG v lc.h pripadne zmenou kondenzatoru u oscilatoru procesoru
 
/*****************************************************/
/************* PRERUSOVACI RUTINY ********************/
/*****************************************************/
 
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
 
// prerusovaci rutina spolecna pro vsechny preruseni, napsana v assembleru, protoze cecko to dela neefektivne
#int_GLOBAL
void int_handler()
{
// uloz W, STATUS a PCLATH
#asm
movwf W_TMP
swapf STATUS,W
clrf STATUS
movwf F_TMP
movf PCLATH,W
movwf PCLATH_TMP
clrf PCLATH
 
btfss PIR1,_TMR1IF
goto NO_T1_L
// preruseni od timeru1
incf counter_h,F // +1 na nejvyssim radu citace impulzu
bcf PIR1,_TMR1IF // nuluj priznak preruseni
// pokracujeme hned testem preruseni od timeru0 (odmeruje periodu mereni)
NO_T1_L:
btfss INTCON,_T0IF
goto NO_T0_L // na dalsi druhy preruseni
// preruseni od timeru 0
bcf INTCON,_T0IF // nuluj priznak preruseni
movlw CORIG // pridane spozdeni, aby byl odmereny cas timerem 0 presne
movwf INT_TMP
LOOP:
decfsz INT_TMP,F
goto LOOP
nop
movlw TIME_1S_L // znovu natahni timer0
movwf TMR0
decf sampler_H,F // -1 na citaci opakovani zakladni periody timeru0
btfss STATUS,_Z // perioda mereni vyprsela?
goto END_INT_L // koncime,abychom nezdrzovali dalsimi zdroji preruseni na nich jiz casove nezalezi
nop
nop
nop
nop
bcf T1CON,_TMR1ON // zastav citani impulzu
movlw F_DONE
movwf freq_done // priznak ukonceni citani - mereni OK
bcf INTCON,_T0IE // zakaz preruseni od timeru0
goto END_INT_L // koncime,abychom nezdrzovali dalsimi zdroji preruseni na nich jiz casove nezalezi
 
NO_T0_L:
btfss INTCON,_RBIF
goto NO_RB_L
// preruseni od tlacitek na brane B
movf PORTB,W
movlw F_KEY
movwf freq_done // nastav priznak , ze mereni frekvence nedopadlo dobre (stisknuto nektere z tlacitek)
bcf INTCON,_RBIF
goto END_INT_L
 
NO_RB_L:
btfss PIR1,_CCP1IF
goto END_INT_L
// preruseni od komparacni jednotky, pouziva se pouze v rezimu pulser pro generovani pulzu od 1ms vyse
// nasledujici konstrukce zajistuje pro 1 i 0 nastaveni pinu ve stejny okamzik, doba do bodu B je tez stejna
btfss INT_TMP,0
goto A
btfsc INT_TMP,0
bcf PORTC,2
goto B
A:
bsf PORTC,2
goto B
B:
comf INT_TMP,F // priste budeme nastavovat opacnou hodnotu
bcf PIR1,_CCP1IF // nuluj priznak preruseni od CCP1 jednotky
 
END_INT_L:
// obnov W, STATUS a PCLATH
movf PCLATH_TMP,W
movwf PCLATH
swapf F_TMP,W
movwf STATUS
swapf W_TMP,F
swapf W_TMP,W
#endasm
} // int_handler
 
 
 
 
 
 
/**************************************************/
/*********** FUNKCE MERENI KMITOCTU ***************/
/**************************************************/
// zahajeni mereni frekvence
//
void start_freq()
{
#asm
bcf T1CON,_TMR1ON // zastav citac TMR1
clrf TMR1L // nuluj citac TMR1, ktery cita vstupni implulzy
clrf TMR1H
clrf counter_H
movlw F_PEACE
movwf freq_done // nuluj priznak dokonceni mereni frekvence
bsf T1CON,_TMR1ON // spust citac TMR1
movlw TIME_1S_L // natahni casovac TMR0, ktery meri periodu mereni
movwf TMR0
movlw TIME_1S_H
movwf sampler_H
bcf INTCON,_T0IF // nuluj priznak preruseni od timeru0
bsf INTCON,_T0IE // povol preruseni od timeru0
#endasm
} // start_freq
 
 
// zmereni frekvence a jeji umocneni
//
float mfreq_sqr()
{
float f;
 
start_freq(); // odstartuj mereni frekvence
while(freq_done==F_PEACE); // cekej na dokonceni zmereni frekvence
f=F_CORRECT*(float)make32(counter_H,get_timer1()); // preved zmerenou frekvennci na float
#ifdef FREQ
return(f); // pro mereni frekvence vracej frekvenci
#else
return(f*f); // vrat kvadrat
#endif
} // mfreq_sqr
 
 
 
 
 
/*******************************************************************/
/*********** FUNKCE PRO PREPINANI TYPU MERENI (rele) ***************/
/*******************************************************************/
// prepne rele na mod mereni C
//
rele_measure_C()
{
output_high(RE1_B);
output_high(RE2_B);
delay_ms(RELE_PULSE);
output_low(RE1_B);
output_low(RE2_B);
} // rele_measure_C
 
 
// prepne rele na mod mereni L
//
rele_measure_L()
{
output_high(RE1_A);
output_high(RE2_B);
delay_ms(RELE_PULSE);
output_low(RE1_A);
output_low(RE2_B);
} // rele_measure_L
 
 
// prepne rele na kalibraci a tez na mody mereni teploty a pulser
//
rele_calib()
{
output_high(RE1_B);
output_high(RE2_A);
delay_ms(RELE_PULSE);
output_low(RE1_B);
output_low(RE2_A);
} // rele_calib
 
 
 
 
 
/*******************************************************************/
/*********** POMOCNE FUNKCE JEDNOTLIVYCH MODU MERENI ***************/
/*******************************************************************/
// vraci cislo radu (0=1E0, 1=1E3 2=1E6 atd.) a upravi parametr aby byl do 999.999
//
int8 range(float &Xv)
{
int8 ret_val;
 
ret_val=0;
while(fabs(Xv)>1E3)
{
Xv=Xv*1E-3;
ret_val++;
}
return(ret_val);
} // range
 
 
// vraci pocet celych cislic realneho argumentu
//
int8 num_int_digit(float X)
{
int8 ret_val;
 
ret_val=1;
while(fabs(X)>1E1)
{
X=X*1E-1;
ret_val++;
}
return(ret_val);
} // num_int_digit
 
 
// smaze 1.radek LCD displeje
//
clr_1Line()
{
int8 i;
lcd_gotoxy(1,1);
for(i=0;i<16;i++) lcd_putc(' ');
lcd_gotoxy(1,1);
}
 
 
//cekani na uvolneni tlacitek
//
wait_release_keys()
{
while(!input(NUL_KEY) || !input(MODE_KEY)) delay_ms(20); // cekej na uvolneni tlacitka
freq_done=F_PEACE;
} // wait_release_keys
 
 
// kalibrace
//
void calibration(float &f1_sqr, float &C, float &L)
{
float f2_sqr;
 
lcd_putc("\f");
printf(lcd_putc,CALIB_MSG);
rele_measure_C(); // rele do stavu odpojeni kalibracniho kondenzatoru a oscilator musi bezet
delay_ms(FREQ_CALM_TIME); // pockej na ustaleni oscilatoru
// mereni f2
rele_calib(); // pripni kalibracni kondenzator
delay_ms(FREQ_CALM_TIME); // pockej na ustaleni oscilatoru
f2_sqr=mfreq_sqr(); // zmer kvadrat f2
// vypocet C a L
C=(C_CALIB*f2_sqr)/(f1_sqr-f2_sqr); // C1 v pF
L=1e9/(39.4784176*f1_sqr*C*1e-12); // L1 v nH
/*
// zobraz zmerene kalibracni hodnoty
lcd_putc("\f");
printf(lcd_putc,"C=%3.2f pF",C);
lcd_gotoxy(1,2);
printf(lcd_putc,"L=%3.2f nH",L);
while(input(NUL_KEY)); // cekej na stisk klavesy
lcd_putc("\f");
*/
} // calibration
 
 
 
 
 
/******************************************************************/
/*********** HLAVNI FUNKCE JEDNOTLIVYCH TYPU MERENI ***************/
/******************************************************************/
// mereni L
//
#inline
void measure_L(float &f1_sqr,float &C,float &L)
{
 
float f2_sqr; // kvadrat kmitoctu mericiho oscilatoru s pripojenou Lx
float X; // zmerena hodnota Lx
float Xp; // vlastni Lp (odecita se od vysledku)
float Xv; // vysledna hodnota Lx
int8 prefix; // index do poli urcijici pismenko radu
int8 Xp_p; // pointer na promennou Xp
int8 ee_adr; // adresovy citac pameti EEROM
 
 
// vyzvedni vlastni indukcnost
ee_adr=LP_ADR_LOW;
for(Xp_p=&Xp;Xp_p<&Xp+4;Xp_p++) *Xp_p=read_eeprom(ee_adr++);
for(;;)
{
f2_sqr=mfreq_sqr(); // zmer kvadrat F2
if(freq_done!=F_DONE) // zmerena frekvence neni platna (stisknuto nektere z tlacitek)
{
if(!input(MODE_KEY)) break; // stisknuto tlacitko mode, koncime
if(!input(NUL_KEY))
{
// stisknuto tlacitko NULL, poznamenej si vlastni L
Xp=X;
// uloz vlastni indukcnost
ee_adr=LP_ADR_LOW;
for(Xp_p=&Xp;Xp_p<&Xp+4;Xp_p++) write_eeprom(ee_adr++,*Xp_p);
clr_1Line();
lcd_gotoxy(9,1);
printf(lcd_putc,"0 nH");
wait_release_keys(); // cekej na uvolneni tlacitka
}
} else
{
if(f2_sqr<1E2) // bezi oscilator? (kmitocet pod 10Hz povazujeme za nebezici oscilator)
{
// oscilator NEBEZI
clr_1Line();
printf(lcd_putc,CONNECT_LX_MSG);
} else
{
// oscilator BEZI
X=(f1_sqr/f2_sqr-1)*L; // vypocti hodnotu Lx
Xv=X-Xp; // odecti vlastni L
// zobraz hodnotu Lx
clr_1Line();
prefix=range(Xv); // uprav rozsah a zjisti cislo radu
lcd_gotoxy(6-num_int_digit(Xv),1); // umisti hodnotu tak, aby radova carka zustavala na stejnem miste
if(Xv>=0F) lcd_putc(' '); // kladne cislo nema minus, vloz mezeru
if(prefix==0) printf(lcd_putc," %3.0f",Xv); // u nH zobrazuj jen cela cisla
else printf(lcd_putc,"%6.3f",Xv); // u ostatnich na 3 desetinna mista
// zobraz jednotky
lcd_gotoxy(12,1);
lcd_putc(L_PREFIX[prefix]);
lcd_putc('H');
}
}
} // od hlavni smycky (for(;;))
} // measure_L
 
 
// mereni C
//
#inline
void measure_C(float &f1_sqr,float &C,float &L)
{
 
float f2_sqr; // kvadrat kmitoctu mericiho oscilatoru s pripojenou Cx
float X; // zmerena hodnota Cx
float Xp; // vlastni Cp (odecita se od vysledku)
float Xv; // vysledna hodnota Cx
int8 prefix; // index do poli s pismenky radu
// int8 pom;
int8 Xp_p; // pointer do promenne Xp
int8 ee_adr;
 
// vyzvedni vlastni kapacitu
ee_adr=CP_ADR_LOW;
for(Xp_p=&Xp;Xp_p<&Xp+4;Xp_p++) *Xp_p=read_eeprom(ee_adr++);
for(;;)
{
f2_sqr=mfreq_sqr(); // zmer F2
if(freq_done!=F_DONE) // zmerena frekvence neni platna (stisknuto nektere z tlacitek)
{
if(!input(MODE_KEY)) break; // stisknuto tlacitko mode, koncime
if(!input(NUL_KEY))
{
// stisknuto tlacitko NULL, poznamenej si vlastni Cp
Xp=X;
// uloz vlastni kapacitu
ee_adr=CP_ADR_LOW;
for(Xp_p=&Xp;Xp_p<&Xp+4;Xp_p++) write_eeprom(ee_adr++,*Xp_p);
clr_1Line();
lcd_gotoxy(6,1);
printf(lcd_putc,"0.00 pF");
wait_release_keys(); // cekej na uvolneni tlacitka
}
} else
{
if(f2_sqr<1E2) // bezi oscilator? (kmitocet pod 10Hz povazujeme za nebezici oscilator)
{
// oscilator NEBEZI
clr_1Line();
printf(lcd_putc,Error_Cx_MSG);
} else
{
// oscilator BEZI
X=(f1_sqr/f2_sqr-1)*C; // vypocti hodnotu Cx nebo Lx
Xv=X-Xp; // odecti vlastni Cp
// zobraz hodnotu Cx
clr_1Line();
prefix=range(Xv); // uprav rozsah a zjisti cislo radu
lcd_gotoxy(6-num_int_digit(Xv),1); // umisti hodnotu tak, aby radova carka zustavala na stejnem miste
if(Xv>=0F) lcd_putc(' '); // kladne cislo nema minus, vloz mezeru
if(prefix==0) printf(lcd_putc,"%5.2f",Xv); // u pF zobrazuj na 2 mista
else printf(lcd_putc,"%6.3f",Xv); // u ostatnich na 3 mista
// zobraz jednotky
lcd_gotoxy(12,1);
lcd_putc(C_PREFIX[prefix]);
lcd_putc('F');
}
}
} // od hlavni smycky (for(;;))
} // measure_C
 
 
// mereni teploty
//
#separate
void measure_T()
{
int8 record[10]; // bafr pro ulozeni zaznamu z teplomeru
int8 i;
int8 stat; // stavovy automat mereni teploty
int8 wait; // pro odmereni casu prevodu teplomeru
int1 delta; // oznamuje, ze merime rozdil teplot
float temp; // zmerena teplota
float temp_p; // odecitana hodnota teploty pri mereni rozdilu teplot
float temp_v; // vysledna teplota
 
stat=T_MEASURE; // zahajime mereni teploty
delta=0; // nemerime teplotni rozdil
temp_p=0; // nic od zmerene teploty neodecitame
 
for(;;)
{
if(freq_done==F_KEY) // stisknuto nejake tlacitko
{
if(!input(MODE_KEY)) // stisknuto tlacitko mode, koncime
{
#USE STANDARD_IO(A)
#USE STANDARD_IO(B)
#USE STANDARD_IO(C)
output_float(TM_PIN); // TM jako vstup, muze zustat jako vystup pri preruseni mereni
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
break;
}
if(!input(NUL_KEY)) // stisknuto tlacitko NULL, budeme merit rozdil teplot, zapamatuj si aktualni teplotu
{
temp_p=temp; // zapamatuj si aktualni hodnotu teploty
delta=1; // oznam, ze merime rozdil teplot
stat=T_MEASURE;
clr_1line();
lcd_gotoxy(6,1);
printf(lcd_putc,"0.0 \20\21C"); // \20 je znak delta \21 je znak stupen
wait_release_keys(); // cekej na uvolneni tlacitka
}
}
// STAVOVY AUTOMAT MERENI TEPLOTY
switch(stat)
{
case T_WAIT:
if(--wait==0) stat=T_DISPLAY; // cekej az teplomer zmeri frekvenci
break;
case T_DISPLAY:
if(!TM_present())
{
// teplomer NENI pritomen
clr_1line();
printf(lcd_putc,CONNECT_TEMP_MSG);
temp_p=0; // nuluj pripadnou teplotu pro odecteni
delta=0; // zrus pripadne mereni rozdilu teplot
} else
{
// teplomer JE pritomen
TM_write_byte(0xCC); // prikaz preskoc na dalsi sadu prikazu
TM_write_byte(0xBE); // prikaz precti zmerenou teplotu
for(i=0;i<9;i++) record[i]=TM_read_byte(); // precti zaznam do buferu
if(TM_check_CRC(record,9)) // kontrola CRC
{
// vypocet teploty viz datasheet
record[0]=record[0]>>1; // zahod rad 2^-1,
if(bit_test(record[1],0)) bit_set(record[0],7); // je-li cislo zaporne, je treba nejvyssi bit nastavit na 1
temp=(float)make16(record[1],record[0]); // prechod na realna cisla
temp=temp-0.25+((0x10-(float)record[6])/0x10); // zvetseni presnosti na 12 bitu
temp_v=temp-temp_p;
clr_1line();
lcd_gotoxy(6-num_int_digit(temp_v),1); // umisti udaj tak, aby radova carka byla porad na stejnem miste
if(temp_v>=0F) lcd_putc(' '); // pri kladne hodnote zobraz misto minus mezeru
printf(lcd_putc,"%4.1f ",temp_v);
if(delta) lcd_putc('\20'); // pri mereni rozdilu teplot zobraz znak delta
lcd_putc('\21'); // znak stupne
lcd_putc('C');
}
}
stat=T_MEASURE; // prejdi do stavu vyvolani mereni teploty
case T_MEASURE:
if(!TM_present())
{
// teplomer NENI pritomen
clr_1line();
printf(lcd_putc,CONNECT_TEMP_MSG);
temp_p=0; // nuluj pripadnou teplotu pro odecteni
delta=0; // zrus pripadne mereni rozdilu teplot
} else
{
// teplomer JE pritomen
TM_write_byte(0xCC); // prikaz preskoc na dalsi sadu prikazu
TM_write_byte(0x44); // prikaz zmer teplotu
#USE STANDARD_IO(A)
#USE STANDARD_IO(B)
#USE STANDARD_IO(C)
output_high(TM_PIN); // vystup do 1, zajistuje napajeni behem mereni teploty
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
wait=CONV_WAIT;
stat=T_WAIT; // prejdi do stavu cekani na dokonceni mereni (konverze)
}
break;
} // od switch
mfreq_sqr(); // zastupuje zde spozdeni 250ms, ktere lze prerusit stiskem tlacitka
} // od for(;;)
} // measure_T
 
 
// generovani pulzu
//
#separate
void pulser()
{
int8 pulse;
 
#USE STANDARD_IO(A)
#USE STANDARD_IO(B)
#USE STANDARD_IO(C)
output_high(PULSER_PIN); // pin pulseru naorientuj jako vystup
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
 
INT_TMP=0; // pouzije se jako zrcadlo vystupniho pinu generatoru pulzu (vystup do 0)
setup_timer_0(RTCC_EXT_L_TO_H); // zastav TMR0, vadil by nam v preruseni, (preruseni od nej zastavuje TMR1)
pulse=read_eeprom(WIDTH_ADR); // vyzvedni naposledy pouzitou sirku impulzu
 
for(;;)
{
clr_1line();
switch(pulse)
{
case P_10US:
printf(lcd_putc,PULSE_10us_MSG);
setup_timer_2(T2_DIV_BY_1,20-1,1); // perioda 20us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 20/2; // strida 1:1
break;
case P_20US:
printf(lcd_putc,PULSE_20us_MSG);
setup_timer_2(T2_DIV_BY_1,40-1,1); // perioda 40us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 40/2; // strida 1:1
break;
case P_50US:
printf(lcd_putc,PULSE_50us_MSG);
setup_timer_2(T2_DIV_BY_1,100-1,1); // perioda 100us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 100/2; // strida 1:1
break;
case P_100US:
printf(lcd_putc,PULSE_100us_MSG);
setup_timer_2(T2_DIV_BY_1,200-1,1); // perioda 200us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 200/2; // strida 1:1
break;
case P_200US:
printf(lcd_putc,PULSE_200us_MSG);
setup_timer_2(T2_DIV_BY_4,100-1,1); // perioda 400us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 100/2; // strida 1:1
break;
case P_500US:
printf(lcd_putc,PULSE_500us_MSG);
setup_timer_2(T2_DIV_BY_4,250-1,1); // perioda 1000us
setup_ccp1(CCP_PWM); // generujeme pomoci PWM jednotky
CCP_1 = 250/2; // strida 1:1
break;
case P_1MS:
setup_timer_2(T2_DISABLED,0,1);
printf(lcd_putc,PULSE_1ms_MSG);
setup_ccp1(CCP_COMPARE_RESET_TIMER); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);
CCP_1 =1000; // pulz 1ms - perioda 2ms
enable_interrupts(INT_CCP1); // povol preruseni od CCP1 jednotky
break;
case P_2MS:
printf(lcd_putc,PULSE_2ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
CCP_1 =2000; // pulz 2ms - perioda 4ms
break;
case P_5MS:
printf(lcd_putc,PULSE_5ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
CCP_1 =5000; // pulz 5ms - perioda 10ms
break;
case P_10MS:
printf(lcd_putc,PULSE_10ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
CCP_1 =10000; // pulz 10ms - perioda 20ms
break;
case P_20MS:
printf(lcd_putc,PULSE_20ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
CCP_1 =20000; // pulz 20ms - perioda 40ms
break;
case P_50MS:
printf(lcd_putc,PULSE_50ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
CCP_1 =50000; // pulz 50ms - perioda 100ms
break;
case P_500MS:
printf(lcd_putc,PULSE_500ms_MSG); // generujeme pomoci CPP1 jednotky ( portem se hejbe v preruseni)
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
CCP_1 =62500 ; // pulz 500ms - perioda 1000ms
break;
case P_5US:
printf(lcd_putc,PULSE_5us_MSG);
disable_interrupts(INT_CCP1); // zakaz preruseni od CCP1, pro kratke casy ji nepouzivme, pouzivame PWM jednotku
setup_timer_2(T2_DIV_BY_1,10-1,1); // perioda 10us
setup_ccp1(CCP_PWM); // pouzivame PWM jednotku
CCP_1 = 10/2; // strida 1:1
break;
} // od switch
while(freq_done!=F_KEY); // cekame na stisk nejakeho tlacitka
if(!input(MODE_KEY)) // stisknuto tlacitko MODE, koncime
{
// uved preruseni a nastaveni timeru1 do puvodniho stavu a konci mod
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256); // pro mereni periody vzorkovani (500ms)
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1); // pro citani vzorku//
bit_clear(*T1CON,_TMR1ON); // zastav citani impulzu
disable_interrupts(INT_CCP1); // cakaz preruseni od CCP1 ednotky
#USE STANDARD_IO(A)
#USE STANDARD_IO(B)
#USE STANDARD_IO(C)
output_float(PULSER_PIN); // vystup pulseru jako vystup
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
break; // koncime
}
if(!input(NUL_KEY)) // stisknuto tlacitko WIDTH
{
if(pulse==P_5US) pulse=P_10US; // po dosazeni stavu P_5US se posloupnost opakuje
else pulse++;
write_eeprom(WIDTH_ADR,pulse); // uloz novou sirku impulzu
wait_release_keys(); // cekej na uvolneni tlacitek po nastaveni sirky pulzu
}
}
} // pulser
 
 
 
 
 
/*************************************************/
/******** HLAVNI FUNKCE PROGRAMU ****************/
/*************************************************/
 
void main()
{
float f1_sqr; // kvadrat kmitoctu mericiho scilatoru bez pripojene Lx nebo Cx
float C; // hodnota kondenzatoru v mericim oscilatoru v pF (ziska se kalibraci)
float L; // hodnota indukcnosti v mericim oscilatoru v nH (ziska se kalibraci)
int8 MODE; // promenna stavoveho automatu hlavni smycky (mod mereni)
int1 _calib; // priznak, ze jiz doslo ke kalibraci
 
 
// nastaveni citacu
port_b_pullups(TRUE); // zapnu puulupy na brane B (pro tlacitka)
setup_timer_0(RTCC_INTERNAL | RTCC_DIV_256); // pro mereni periody vzorkovani (500ms)
setup_timer_1(T1_EXTERNAL | T1_DIV_BY_1); // pro citani impulzu z mericiho oscilatoru
bit_clear(*T1CON,_TMR1ON); // zastav citani impulzu
 
//nastaveni vstupu a vystupu
#USE STANDARD_IO(A)
#USE STANDARD_IO(B)
#USE STANDARD_IO(C)
output_low(RE1_A); // signaly relatek jako vystupy a do 0
output_low(RE1_B);
output_low(RE2_A);
output_low(RE2_B);
output_float(PULSER_PIN); // signal pro pulser jako vstup
output_float(TM_PIN); // vstup pro TM jako vstup
output_float(TM_PULLUP); // zapni pullup pro TM
output_low(PIN_C1); // nepouzit,dej do 0
output_low(PIN_C3); // nepouzit,dej do 0
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
 
lcd_init();
lcd_define_char(0,LCD_CHAR_DELTA); // nadefinovani znaku delta
lcd_define_char(1,LCD_CHAR_DEC); // nadefinovani znaku stupen
rele_measure_C(); // rele do stavu odpojeni kalibracniho kondenzatoru a oscilator musi bezet
input_b();
enable_interrupts(INT_TIMER1); // povol preruseni od citace impulzu mericiho oscilatoru
enable_interrupts(INT_RB); // povol preruseni od tlacitek
enable_interrupts(GLOBAL);
 
 
#ifdef FREQ
// pro kalibraci mereni kmitoctu
for(;;) {
f1_sqr=mfreq_sqr();
lcd_putc("\f");
printf(lcd_putc,"F=%6.2f KHz",f1_sqr*1E-3);
delay_ms(500);
}
#endif
 
// UVOD
lcd_putc("\f");
printf(lcd_putc,VERSION_MSG);
lcd_gotoxy(1,2);
printf(lcd_putc,COPYRIGHT_MSG);
delay_ms(FREQ_CALM_TIME); // pockej na ustaleni oscilatoru
f1_sqr=mfreq_sqr(); // zmer f1
_calib=0; // kalibrace neni provedena
freq_done=F_PEACE;
mode=read_eeprom(MODE_ADR); // vyzvedni naposledy pouzity mod
 
// VLASTNI MERICI SMYCKA
for(;;)
{
switch(mode)
{
case MODE_C: // mereni Cx
if(!_calib)
{
calibration(f1_sqr,C,L); // proved kalibraci (vypocti L a C)
_calib=1; // poznamenej si, ze se kalibrace uz provedla
}
rele_measure_C();
lcd_gotoxy(1,2);
printf(lcd_putc,MODE_CX_NULL_MSG);
measure_C(f1_sqr,C,L);
// prechazime na mereni L
mode=MODE_L;
break;
case MODE_L: // mereni Lx
if(!_calib)
{
calibration(f1_sqr,C,L); // proved kalibraci (vypocti L a C)
_calib=1; // poznamenej si, ze se kalibrace uz provedla
}
rele_measure_L();
lcd_gotoxy(1,2);
printf(lcd_putc,MODE_LX_NULL_MSG);
measure_L(f1_sqr,C,L);
// prechazime na mereni T
mode=MODE_T;
break;
case MODE_T: // merei teploty
rele_calib();
lcd_gotoxy(1,2);
printf(lcd_putc,MODE_TMP_NULL_MSG);
bit_clear(*T1CON,_TMR1ON); // zastav TMR1, vadil by
measure_T();
// prechazime na generovani pulzu
mode=MODE_P;
break;
case MODE_P: // generovani pulzu
rele_calib();
lcd_gotoxy(1,2);
printf(lcd_putc,MODE_PLZ_WIDTH_MSG);
pulser();
// prechazime na mereni C
mode=MODE_C;
break;
} // od switch
write_eeprom(MODE_ADR,mode); // uloz ktery mod je nyni aktivni
wait_release_keys(); // cekej na uvolneni tlacitek
delay_ms(10);
} // for(;;)
} // main
 
// End of File
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lc.h
0,0 → 1,132
//**********************************************************************
// LCT-METER/PULSER - HLAVICKOVY SOUBOR
//**********************************************************************
// (c) OK1XGL 2004
// verze 1.00 - uvodni verze 10.1.2004
// verze 1.01 - pridano ukladani vlastni Cp/Lp do pameti EEPROM
// - pridano ukladani stavu (mod, parametry modu ) do pameti EEROM
//
 
#use delay (clock=4000000,restart_wdt)
#fuses XT,NOWDT,NOPROTECT,NOBROWNOUT,NOLVP
 
// LCD display
#define LCD_RS PIN_A0 /* rizeni registru LCD displeje */
#define LCD_E PIN_A1 /* enable LCD displeje */
#define LCD_DATA_LSB PIN_A2 /* pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) */
#define LCD_CHAR_DELTA "\x80\x80\x80\x04\x0A\x11\x1F\x80" /* symbol delta */
#define LCD_CHAR_DEC "\x0E\x0A\x0E\x80\x80\x80\x80\x80" /* symbol stupen */
 
// rele pro prepinani modu mereni
#define RE1_A PIN_C4
#define RE1_B PIN_C7
#define RE2_A PIN_C5
#define RE2_B PIN_C6
#define RELE_PULSE 10 /* delka prepinaciho pulzu pro rele v ms jednotkach */
 
// tlacitka (libovolne na brane B)
#define NUL_KEY PIN_B7 /* pro nulovani pocatecni C nebo L NEBO T, pri generovani pulzu prepina sirku pulzu */
#define MODE_KEY PIN_B6 /* pro prepinani modu mereni */
 
// pulser (nelze zmenit, vystup PWM a CPP1 jednotky je jen zde)
#define PULSER_PIN PIN_C2 /* vystup pulseru */
 
// teplomer (POZOR NA VSTUPY SE SHMIDTOVYM OBVODEM, NELZE POUZIT!!!!!)
#define TM_PIN PIN_B0 /* pin, na kterem je teplomer pripojen */
#bit TM_PIN_BIT = PORTB.0 /* totez, ale definovan jako bit */
#define TM_PULLUP PIN_B1 /* pullup pro teplomer */
 
// konstanty pro mereni frekvence
#define TIME_1S_L 0xff-194 /* urcuje dobu, za kterou vyprsi timer0 (zde 50ms),meri interval doby mereni frekvence */
#define TIME_1S_H 5 /* rozsiruje timer0, aby bylo mozne odmerit delsi casy zde 250ms */
#define CORIG 21 /* pro korekci intervalu doby mereni frekvence aby byla presne (vliv doby preruseni a nepresnost oscilatoru) */
#define FREQ_CALM_TIME 2000 /* cas pro ustaleni frekvence oscialtoru v ms jednotkach */
#define C_CALIB 996 /* hodnota kalibracniho kondenzatoru v pF */
#define F_CORRECT 4 /* korekce zmereneho kmitoctu, aby byl v Hz a ne v napr. v 4Hz jednotkach jako zde */
 
// adresy parametru v pameti EEROM
#define CP_ADR_LOW 0 /* pro ulozeni vlastni kapacity 4 bajty*/
#define LP_ADR_LOW 4 /* pro ulozeni vlastni indukcnosti 4 bajty*/
#define MODE_ADR 8 /* uchovani modu zarizeni viz promenna mode */
#define WIDTH_ADR 9 /* uchovani sirky pulzu v modu pulser viz promenna pulse_width */
 
// konstanty pro mereni teploty
#define CONV_WAIT 4 /* cas cekani az teplomer zmeri teplotu v jednotkach doby citani impulzu pri mereni frekvence */
 
// konstanty pro promennou mode ve funkci main()
#define MODE_L 0 /* mereni indukcnosti */
#define MODE_C 1 /* mereni kapacity */
#define MODE_T 2 /* mereni teploty */
#define MODE_P 3 /* generator pulzu */
 
// konstanty pro promennou pulse_width ve funkci pulser()
#define P_10US 0
#define P_20US 1
#define P_50US 2
#define P_100US 3
#define P_200US 4
#define P_500US 5
#define P_1MS 6
#define P_2MS 7
#define P_5MS 8
#define P_10MS 9
#define P_20MS 10
#define P_50MS 11
#define P_500MS 12
#define P_5US 13
 
// konstanty pro promennou status ve funkci measure_T()
#define T_WAIT 0 /* odmer 1000 ms */
#define T_MEASURE 1 /* posli prikaz ke zmereni teploty */
#define T_DISPLAY 2 /* precti zmerenou teplotu a zobraz ji */
 
// konstanty pro promennou freq_done
#define F_PEACE 0 /* klidovy stav tuto hodnotu nemenit !!!! */
#define F_DONE 1 /* mereni frekvence dokonceno */
#define F_KEY 2 /* stisknuto tlacitko, mereni frekvence preruseno */
 
// texty zobrazovane na 1.radku LCD displeje
#define VERSION_MSG " Version 1.01"
#define COPYRIGHT_MSG "(c) OK1XGL 2004"
#define CALIB_MSG " Calibration"
#define CONNECT_LX_MSG " Connect Lx !!!"
#define ERROR_CX_MSG " Error Cx !!!"
#define CONNECT_TEMP_MSG " Connect temp"
#define PULSE_5us_MSG " 5us (100KHz)"
#define PULSE_10us_MSG " 10us (50KHz)"
#define PULSE_20us_MSG " 20us (25KHz)"
#define PULSE_50us_MSG " 50us (10KHz)"
#define PULSE_100us_MSG " 100us (5KHz)"
#define PULSE_200us_MSG " 200us (2.5KHz)"
#define PULSE_500us_MSG " 500us (1KHz)"
#define PULSE_1ms_MSG " 1ms (500Hz)"
#define PULSE_2ms_MSG " 2ms (250Hz)"
#define PULSE_5ms_MSG " 5ms (100Hz)"
#define PULSE_10ms_MSG " 10ms (50Hz)"
#define PULSE_20ms_MSG " 20ms (25Hz)"
#define PULSE_50ms_MSG " 50ms (10Hz)"
#define PULSE_500ms_MSG " 500ms (1Hz)"
 
// texty zobrazovane na 2. radku LCD displeje
#define MODE_CX_NULL_MSG "MODE Cx NULL"
#define MODE_LX_NULL_MSG "MODE Lx NULL"
#define MODE_TMP_NULL_MSG "MODE +TMP NULL"
#define MODE_PLZ_WIDTH_MSG "MODE +PLZ WIDTH"
 
// konstantni pole pro prefix radu
int8 const C_PREFIX[4] = {'p','n','u','m'};
char const L_PREFIX[4] = {'n','u','m',' '};
 
// uvodni nastaveni parametru v pameti eeprom
#rom 0x2100={0,0,0,0,0,0,0,0,MODE_C,P_5US}
 
// globalni promenne
int8 freq_done; // stav procesu mereni frekvence
int8 W_TMP; // pro ulozeni W v prerusovaci rutine
int8 F_TMP; // pro ulozeni F v prerusovaci rutine
int8 PCLATH_TMP; // pro ulozeni PCLATH v prerusovaci rutine
int8 INT_TMP; // pomocna promenna pro preruseni
int8 sampler_H; // rozsireni timeru0 ,ktery meri dobu citani impulzu mericiho oscilatoru v tmr0 jednotkach
int8 counter_H; // rozsireni timeru1, ktery slouzi pro citani impulzu mericiho oscilatoru
 
// End of File
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lib/16f877_reg.h
0,0 → 1,288
////////////////////////////////////////////////////////////////////////////
// ////
// DEFINICE REGISTRU PROCESORU PIC16F877 ////
// ////
////////////////////////////////////////////////////////////////////////////
// ////
// PEFI S.ICZ a.s 2002 ////
// ////
// Verze 1.0 ////
// ////
////////////////////////////////////////////////////////////////////////////
 
 
 
// registry v bance 0
#define INDF 0x00
#define TMR0 0x01
#define PCL 0x02
#define STATUS 0x03
#define FSR 0x04
#define PORTA 0x05
#define PORTB 0x06
#define PORTC 0x07
#define PORTD 0x08
#define PORTE 0x09
#define PCLATH 0x0A
#define INTCON 0x0B
#define PIR1 0x0C
#define PIR2 0x0D
#define TMR1L 0x0E
#define TMR1H 0x0F
#define T1CON 0x10
#define TMR2 0x11
#define T2CON 0x12
#define SSPBUF 0x13
#define SSPCON 0x14
#define CCPR1L 0x15
#define CCPR1H 0x16
#define CCP1CON 0x17
#define RCSTA 0x18
#define TXREG 0x19
#define RCREG 0x1A
#define CCPR2L 0x1B
#define CCPR2H 0x1C
#define CCP2CON 0x1D
#define ADRESH 0x1E
#define ADCON0 0x1F
 
// registry v bance 1
#define OPTION 0x81
#define TRISA 0x85
#define TRISB 0x86
#define TRISC 0x87
#define TRISD 0x88
#define TRISE 0x89
#define PIE1 0x8C
#define PIE2 0x8D
#define PCON 0x8E
#define SSPCON2 0x91
#define PR2 0x92
#define SSPADD 0x93
#define SSPSTAT 0x94
#define TXSTA 0x98
#define SPBRG 0x99
#define ADRESL 0x9E
#define ADCON1 0x9F
 
// registry v bance 2
#define EEDATA 0x10C
#define EEADR 0x10D
#define EEDATH 0x10E
#define EEADRH 0x10F
 
// registry v bance 3
#define EECON1 0x18C
#define EECON2 0x18D
 
// bity v registru STATUS
#define _IRP 7
#define _RP1 6
#define _RP0 5
#define _NOT_TO 4
#define _NOT_PD 3
#define _Z 2
#define _DC 1
#define _C 0
 
// bity v registru INTCON
#define _GIE 7
#define _PEIE 6
#define _T0IE 5
#define _INTE 4
#define _RBIE 3
#define _T0IF 2
#define _INTF 1
#define _RBIF 0
 
// bity v registru PIR1
#define _PSPIF 7
#define _ADIF 6
#define _RCIF 5
#define _TXIF 4
#define _SSPIF 3
#define _CCP1IF 2
#define _TMR2IF 1
#define _TMR1IF 0
 
// bity v registru PIR2
#define _EEIF 4
#define _BCLIF 3
#define _CCP2IF 0
 
// bity v registru T1CON
#define _T1CKPS1 5
#define _T1CKPS0 4
#define _T1OSCEN 3
#define _NOT_T1SYNC 2
#define _T1SYNC 2
#define _TMR1CS 1
#define _TMR1ON 0
 
// bity v registru T2CON
#define _TOUTPS3 6
#define _TOUTPS2 5
#define _TOUTPS1 4
#define _TOUTPS0 3
#define _TMR2ON 2
#define _T2CKPS1 1
#define _T2CKPS0 0
 
// bity v registru SSPCON
#define _WCOL 7
#define _SSPOV 6
#define _SSPEN 5
#define _CKP 4
#define _SSPM3 3
#define _SSPM2 2
#define _SSPM1 1
#define _SSPM0 0
 
// bity v registru CCP1CON
#define _CCP1X 5
#define _CCP1Y 4
#define _CCP1M3 3
#define _CCP1M2 2
#define _CCP1M1 1
#define _CCP1M0 0
 
// bity v registru RCSTA
#define _SPEN 7
#define _RX9 6
#define _SREN 5
#define _CREN 4
#define _ADDEN 3
#define _FERR 2
#define _OERR 1
#define _RX9D 0
 
// bity registru CCP2CON
#define _CCP2X 5
#define _CCP2Y 4
#define _CCP2M3 3
#define _CCP2M2 2
#define _CCP2M1 1
#define _CCP2M0 0
 
// bity v registru ADCON0
#define _ADCS1 7
#define _ADCS0 6
#define _CHS2 5
#define _CHS1 4
#define _CHS0 3
#define _GO 2
#define _NOT_DONE 2
#define _GO_DONE 2
#define _ADON 0
 
// bity v registru OPTION
#define _NOT_RBPU 7
#define _INTEDG 6
#define _T0CS 5
#define _T0SE 4
#define _PSA 3
#define _PS2 2
#define _PS1 1
#define _PS0 0
 
// bity v registru TRISE
#define _IBF 7
#define _OBF 6
#define _IBOV 5
#define _PSPMODE 4
#define _TRISE2 2
#define _TRISE1 1
#define _TRISE0 0
 
// bity v registru PIE1
#define _PSPIE 7
#define _ADIE 6
#define _RCIE 5
#define _TXIE 4
#define _SSPIE 3
#define _CCP1IE 2
#define _TMR2IE 1
#define _TMR1IE 0
 
// bity v registru PIE2
#define _EEIE 4
#define _BCLIE 3
#define _CCP2IE 0
 
// bity v registru PCON
#define _NOT_POR 1
#define _NOT_BOR 0
 
// bity v registu
#define _GCEN 7
#define _ACKSTAT 6
#define _ACKDT 5
#define _ACKEN 4
#define _RCEN 3
#define _PEN 2
#define _RSEN 1
#define _SEN 0
 
//bity v registru SSPSTAT
#define _SMP 7
#define _CKE 6
#define _D 5
#define _I2C_DATA 5
#define _NOT_A 5
#define _NOT_ADDRESS 5
#define _D_A 5
#define _DATA_ADDRESS 5
#define _P 4
#define _I2C_STOP 4
#define _S 3
#define _I2C_START 3
#define _R 2
#define _I2C_READ 2
#define _NOT_W 2
#define _NOT_WRITE 2
#define _R_W 2
#define _READ_WRITE 2
#define _UA 1
#define _BF 0
 
// bity v registru TXSTA
#define CSRC 7
#define TX9 6
#define TXEN 5
#define SYNC 4
#define BRGH 2
#define TRMT 2
#define TX9D 0
 
// bity v registru ADCON1
#define _ADFM 7
#define _PCFG3 3
#define _PCFG2 2
#define _PCFG1 2
#define _PCFG0 0
 
// bity v registru EECON1
#define _EEPGD 7
#define _WRERR 3
#define _WREN 2
#define _WR 1
#define _RD 0
 
// masky pro nastaveni orientace I/O pinu
#define PIN0_IN 0x01
#define PIN1_IN 0x02
#define PIN2_IN 0x04
#define PIN3_IN 0x08
#define PIN4_IN 0x10
#define PIN5_IN 0x20
#define PIN6_IN 0x40
#define PIN7_IN 0x80
 
#define PIN0_OUT ~0x01
#define PIN1_OUT ~0x02
#define PIN2_OUT ~0x04
#define PIN3_OUT ~0x08
#define PIN4_OUT ~0x10
#define PIN5_OUT ~0x20
#define PIN6_OUT ~0x40
#define PIN7_OUT ~0x80
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lib/TM.C
0,0 → 1,189
////////////////////////////////////////////////////////////////////////////
//
// KNIHOVNA PRO PRACI S TOUCH MEMORY FY DALLAS
//
////////////////////////////////////////////////////////////////////////////
//
// PEFI S.ICZ a.s. 2002, 2003
//
// Verze 1.0
// 1.1 - pridana podpora vypinani pullupu
// pres pin TOUCH_PULLUP_PIN
// 1.2 - vyrazena podpora pullupu, do obecne knihovny nepatri
// - funkce checkCRC se stala soucasti fce read_sn
// - upraveny nazvy funkci, zpetna kompatibilita neni potreba
// 1.3 - pridana samostatna funkce pro kontrolu CRC
//
///////////////////////////////////////////////////////////////////////////
//
// funkce:
// int8 TM_present()
// - vraci TRUE, pokud je TM pritomna
//
// int8 TM_read_byte()
// - precte bajt z TM
//
// int8 TM_write_byte(int8 data)
// - zapise bajt do TM a vraci TRUE, pokud se to povedlo
//
// int8 TM_read_sn(int8 *sn)
// - precte seriove cislo z TM pomoci prikazu 0x33
// - vraci TRUE, pokud je SN platne (spravne CRC)
//
// definice a prepinace
// #define TM_PIN /* pin, na kterem je touch memory pripojena */
// #bit TM_PIN_BIT /* totez, ale definovan jako bit */
//
//
// defaultni definice
#ifndef TM_PIN
#define TM_PIN PIN_B0
#bit TM_PIN_BIT = PORTB.0
#endif
 
 
 
 
 
/****************************************************************************************************/
// Privatni sekce, cist jen v pripade, ze neco nefunguje
/****************************************************************************************************/
// precte bajt z touch memory
//
int8 TM_read_byte() {
int8 i,data;
 
for(i=0;i<8;++i) {
output_low(TM_PIN);
delay_us(14);
output_float(TM_PIN);
delay_us(5);
shift_right(&data,1,input(TM_PIN));
delay_us(100);
}
return(data);
}
 
 
// zapise bajt do touch memory
//
int8 TM_write_byte(int8 data) {
int8 i;
 
for(i=0;i<8;++i) {
output_low(TM_PIN);
delay_us(10);
if(shift_right(&data,1,0)) {
output_float(TM_PIN);
delay_us(1); // k vuli nabehu jednicky pres pullup
if(!TM_PIN_BIT) return(0);
} else {
output_low(TM_PIN);
if(TM_PIN_BIT) return(0); // k vuli nabehu nuly
}
delay_us(50);
output_float(TM_PIN);
// delay_us(50);
}
return(TRUE);
}
 
 
// testuje pritomnost touch memory, pri pritomnosti vraci TRUE
//
int8 TM_present() {
int1 present;
 
output_low(TM_PIN);
delay_us(500);
output_float(TM_PIN);
if(!input(TM_PIN))
return(FALSE);
delay_us(65);
present=!input(TM_PIN);
delay_us(240);
if(present)
return(TRUE);
else
return(FALSE);
}
 
// zkontroluje CRC zaznamu, vraci TRUE, pokud je zanam spravny
//
int8 TM_check_CRC(unsigned int8 *sn, unsigned int8 num)
{
#ifdef CRC_TAB
// tabulka pro vypocet CRC
const int8 TouchCRC[256]= {
0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31, 65,
157, 195, 33, 127, 252, 162, 64, 30, 95, 1, 227, 189, 62, 96, 130, 220,
35, 125, 159, 193, 66, 28, 254, 160, 225, 191, 93, 3, 128, 222, 60, 98,
190, 224, 2, 92, 223, 129, 99, 61, 124, 34, 192, 158, 29, 67, 161, 255,
70, 24, 250, 164, 39, 121, 155, 197, 132, 218, 56, 102, 229, 187, 89, 7,
219, 133, 103, 57, 186, 228, 6, 88, 25, 71, 165, 251, 120, 38, 196, 154,
101, 59, 217, 135, 4, 90, 184, 230, 167, 249, 27, 69, 198, 152, 122, 36,
248, 166, 68, 26, 153, 199, 37, 123, 58, 100, 134, 216, 91, 5, 231, 185,
140, 210, 48, 110, 237, 179, 81, 15, 78, 16, 242, 172, 47, 113, 147, 205,
17, 79, 173, 243, 112, 46, 204, 146, 211, 141, 111, 49, 178, 236, 14, 80,
175, 241, 19, 77, 206, 144, 114, 44, 109, 51, 209, 143, 12, 82, 176, 238,
50, 108, 142, 208, 83, 13, 239, 177, 240, 174, 76, 18, 145, 207, 45, 115,
202, 148, 118, 40, 171, 245, 23, 73, 8, 86, 180, 234, 105, 55, 213, 139,
87, 9, 235, 181, 54, 104, 138, 212, 149, 203, 41, 119, 244, 170, 72, 22,
233, 183, 85, 11, 136, 214, 52, 106, 43, 117, 151, 201, 74, 20, 246, 168,
116, 42, 200, 150, 21, 75, 169, 247, 182, 232, 10, 84, 215, 137, 107, 53};
#else
int8 j,k,l; // promenne potrebne pro algoritmicky vypocet CRC
#endif
int8 CRC; // prubezne CRC
int8 i;
 
 
#ifdef CRC_TAB
// vypocet CRC tabulkou
CRC=0;
for(i=0;i<num;i++) CRC=TouchCRC[CRC ^ *(sn+i)];
if(CRC!=*(sn+7)) return(0);
else return(1);
#else
// vypocet CRC algoritmicky
CRC=0;
for(i=0 ;i<num;i++) {
k=*(sn+i);
#asm
movlw 8
movwf j // citac bitu
loop:
movf k,W // presun bajt do W
xorwf CRC,W // prixoruj CRC a uloz do w
movwf l
rrf l,F // naxorovany bit do CY
movf CRC,W
btfsc 3.0 // preskoc, je-li CY nulove
xorlw 0x18
movwf CRC
rrf CRC,F // rotuj CRC
rrf k // na dalsi bit
decfsz j,F
goto loop
#endasm
}
if(CRC!=0) return(0);
else return(1);
#endif
}
 
 
// precte seriove cislo z touch memory, vraci TRUE je-li platne (spravne CRC)
//
int8 TM_read_sn(unsigned int8 *sn)
{
int8 i;
// precteni SN z touch memory
TM_write_byte(0x33);
for(i=0;i<8;i++) *(SN+i)=TM_read_byte(); // precti SN do buferu
 
if(*sn==0) return(0); // family kod je nulovy a to je chyba, timto nahrazujeme precteni samych nul, coz ma platne CRC, ale neexistuje
return(TM_check_CRC(SN,8));
}
// End of FIle
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/Designs/Measuring_instruments/LCTmetr01A/SW/lib/lcd.c
0,0 → 1,300
// LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem
// (c)miho 2002
//
// Historie:
//
// 0.00 Uvodni verze se snadnou definici portu LCD displeje
// 0.01 Oprava portu (zapomenute stare identifikatory)
// 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty
//
//
// Funkce:
//
// lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni
//
// lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky
// \f = \x0C - nova stranka - smazani displeje
// \n = \x0A - odradkovani (prechod na druhou radku)
// \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet
// \r = \x0D - goto home to position 1,1
// \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM
// \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM
// Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce)
//
// lcd_gotoxy(x,y) presune kurzor na uvedenou adresu
// nekontroluje parametry
//
// lcd_cursor_on zapne kurzor
// lcd_cursor_off vypne kurzor
//
// lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho
// retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM.
// Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7.
// Na konci se provede lcd_gotoxy(1,1).
// Na konci teto knihovny je priklad pouziti definovanych znaku
//
//
// Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port
//
// #define LCD_RS PIN_B2 // rizeni registru LCD displeje
// #define LCD_E PIN_B1 // enable LCD displeje
// #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
//
//
// Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov)
//
// #define LCD_RS PIN_B2 // rizeni registru LCD displeje
// #define LCD_E PIN_B1 // enable LCD displeje
// #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty
// #define LCD_D1 PIN_C3 // D1
// #define LCD_D2 PIN_C4 // D2
// #define LCD_D3 PIN_C5 // D3
 
 
 
 
// Privatni sekce, cist jen v pripade, ze neco nefunguje
 
 
 
 
#ifdef LCD_DATA_LSB
// Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne
// bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva
// v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu
//
#define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu
#define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu
#define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru
#define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu
//
#if LCD_SHIFT>4 // kontrola mezi
#error LCD data port LSB bit not in range 0..4
#endif
#endif
 
 
// Definice konstant pro LCD display
//
#define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem
#define LCD_CURSOR_OFF_ 0x0C // zadny kurzor
#define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky
 
 
// Definice rezimu LCD displeje
//
BYTE const LCD_INIT_STRING[4] =
{
0x28, // intrfejs 4 bity, 2 radky, font 5x7
LCD_CURSOR_OFF_, // display on, kurzor off,
0x01, // clear displeje
0x06 // inkrement pozice kurzoru (posun kurzoru doprava)
};
 
 
// Odesle nibble do displeje (posle data a klikne signalem e)
//
void lcd_send_nibble( BYTE n )
{
#ifdef LCD_DATA_LSB
// data jsou za sebou na 4 bitech jednoho portu
*LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej
#else
// data jsou na libovolnych 4 bitech libovolnych portu
output_bit(LCD_D0,bit_test(n,0));
output_bit(LCD_D1,bit_test(n,1));
output_bit(LCD_D2,bit_test(n,2));
output_bit(LCD_D3,bit_test(n,3));
#endif
output_bit(LCD_E,1); // vzestupna hrana
delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
}
 
 
// Odesle bajt do registru LCD
//
// Pokud je Adr=0 .. instrukcni registr
// Pokud je Adr=1 .. datovy registr
//
void lcd_send_byte( BOOLEAN Adr, BYTE n )
{
output_bit(LCD_RS,Adr); // vyber registr
swap(n);
lcd_send_nibble(n); // posli horni pulku bajtu
swap(n);
lcd_send_nibble(n); // posli spodni pulku bajtu
delay_us(40); // minimalni doba na provedeni prikazu
}
 
 
// Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje
//
// Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur
//
void lcd_init()
{
 
int i; // pocitadlo cyklu
 
delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni
 
#ifdef LCD_DATA_LSB
// data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy
*LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD
#endif
 
output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav
 
for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
{
delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
lcd_send_nibble(3); // rezim 8 bitu
}
 
delay_us(40); // cas na zpracovani
lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
delay_us(40); // cas na zpracovani
 
for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
{
lcd_send_byte(0,LCD_INIT_STRING[i]);
delay_ms(2);
}
}
 
 
// Proved presun kurzoru
//
// Pozice 1.1 je domu
//
void lcd_gotoxy( BYTE x, BYTE y)
{
 
BYTE Adr;
 
Adr=x-1;
if(y==2)
Adr+=LCD_LINE_2;
 
lcd_send_byte(0,0x80|Adr);
}
 
 
// Zapis znaku na displej, zpracovani ridicich znaku
//
void lcd_putc( char c)
{
 
switch (c)
{
case '\f' : lcd_send_byte(0,1); // smaz displej
delay_ms(2);
break;
case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
case '\r' : lcd_gotoxy(1,1); break; // presun home
case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
lcd_send_byte(1,c); break; // zapis znak
}
}
 
 
// Zapni kurzor
//
void lcd_cursor_on()
{
lcd_send_byte(0,LCD_CURSOR_ON_);
}
 
 
// Vypni kurzor
//
void lcd_cursor_off()
{
lcd_send_byte(0,LCD_CURSOR_OFF_);
}
 
 
// Definice vlastnich fontu
//
// Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje
// Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden
// priklad pouziti definovanych znaku.
 
 
// Pomocna procedura pro posilani ridicich dat do radice displeje
//
void lcd_putc2(int Data)
{
lcd_send_byte(1,Data);
}
 
 
// Pomocne definice pro programovani obsahu CGRAM
//
#define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2)
#define lcd_define_def(String) printf(lcd_putc2,String);
#define lcd_define_end() lcd_send_byte(0,3); delay_ms(2)
 
 
// Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def
//
#define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end();
 
 
// Pripravene definice fontu vybranych znaku
// V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80
//
#define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */
#define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */
#define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */
#define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */
#define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */
#define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */
#define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */
#define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */
#define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */
#define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */
#define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */
#define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */
#define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */
#define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */
#define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */
#define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */
#define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */
#define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */
#define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */
#define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */
#define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */
#define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */
#define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */
#define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */
#define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */
#define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */
#define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */
#define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */
#define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */
#define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */
#define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */
#define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */
#define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */
#define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */
#define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */
 
 
// Priklad pouziti definovanych znaku
//
//
//void lcd_sample()
//{
// lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0
// lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2
// // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji
// // jediny definicni retezec)
// printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3
// delay_ms(1000);
// lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0
// delay_ms(1000);
//}
Property changes:
Added: svn:executable
+*
\ No newline at end of property