This commit is contained in:
lukario 2021-06-16 17:38:28 +02:00
parent 4c8ac7f1ba
commit 13d468e62c
27 changed files with 36998 additions and 0 deletions

View File

@ -0,0 +1,32 @@
Wichtig:
Bei bestückter Platine die Prozessorpins 20 (+5V) und 21 (VREF des ADC) durch eine Zinnbrücke verbinden, damit auch VREF auf +5V gelegt wird.
Bauteilliste
Bezeichnung Beschreibung
C1, C2, C3, C4 100n, RM5
D1, D2 1N4004
F1 Sicherungshalter und Sicherung RM 22,5
IC1 AT MEGA8-P DIP
IC2 78S05
IC3 LM35 TO92
ISP STK200 10 x 2 pol. Stifte Anschluss zur Programmierung
LED1 grün, 2mA, 3mm
LED2 rot, 2 mA 3mm
Q1 IRF510, TO220
R1,R4, R8 10k
R2 1 Ohm, 1 W
R3 10k, 1%
R5, R6 1k8
R10 10k Trimmpoti PT6-L
S1, S2 DT6 up Taster DT6
SV1 Buchsenleiste 14 pol. für LCD
X1 Anschlussklemmem AK300/2 RM 5
X5 Anschlussklennen AK300/4 RM 5

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,256 @@
:1000000012C0189518951895189518951895189563
:100010001895189518951895189518951895189578
:100020001895189518958FE58DBFC0E4E0E44E2E25
:1000300084E08EBFD4E0F4E05F2EEEEFF3E0A0E6C4
:10004000B0E088278D933197E9F786E089B980E0A1
:1000500080BD88E18AB96FD366248FEF87BBB99AD8
:1000600083E88FBD81E08EBDA098A198A298A39847
:10007000A498AC9AA598AD9A83E086B980E487B934
:10008000889A899AA0EBB0E0E2EAFFE01FD3E6EAA3
:10009000FFE056D6E0EBF0E0FBD400D6FF27EDE022
:1000A000ADECB0E02DD7E6EAFFE04AD6E0EBF0E0B9
:1000B000EFD4E5D5FF27EDE0A1EDB0E021D7EAEAE6
:1000C000FFE03ED6EDECF0E0E3D4E8D5FF27EDE02D
:1000D000A5ECB0E015D7EAEAFFE032D6E1EDF0E0BA
:1000E000D7D4CDD5FF27EDE0A9ECB0E009D7A5ED39
:1000F000B0E0EEEAFFE0EAD2AFEDB0E0E6EAFFE022
:10010000E5D2ABEDB0E0E2EBFFE0E0D2A3EEB0E091
:10011000E2EBFFE0DBD282E390E0A7EEB0E08D936C
:100120009C93A9EEB0E0EAEAFFE0D0D2F894909870
:1001300020D084EF91E0ADEEB0E08D939C93ADEED6
:10014000B0E08D919C9190934B0080934A008CE09D
:100150003ED3D7D28FE714E0E3D2E6ECFFE0CBD278
:10016000E5E0F0E0DFD2CDD204D05BD2F6D17BD097
:10017000FBCF379AEBE7F0E0AFE7B0E0C1D680E421
:10018000806487B93ED4A0E6B0E08D939C9381E46F
:10019000806487B936D4A1E7B0E08D939C9382E464
:1001A000806487B92ED4A9E9B0E08D939C9383E451
:1001B000806487B926D4ABE9B0E08D939C93E6EBDD
:1001C000FFE0BED5E0E6F0E0D190E080FF2400271C
:1001D00083D424D5FF27EDE0A2E6B0E091D6E6EB8C
:1001E000FFE0AED5E1E7F0E0D190E080FF2400270A
:1001F00073D414D5FF27EDE0A3E7B0E081D6EAEB96
:10020000FFE09ED5E3E7F0E043D408D5FF27EDE01B
:10021000A7E7B0E075D6E7E7F0E0ABE7B0E070D66F
:10022000E6EBFFE08DD5EBE9F0E0D190E080FF2434
:10023000002752D4F3D4FF27EDE0ADE9B0E060D65B
:10024000EDE9F0E0A1EAB0E05BD6EEEBFFE078D5B7
:10025000E1EAF0E01DD4E2D4FF27EDE0A1EAB0E04E
:100260004FD637980895EBE7F0E012D4E5ECF0E0D4
:1002700014D46FD510F009F001C005C0A5EDB0E0B1
:10028000E2ECFFE023D2EBE7F0E002D4E0EBF0E0B9
:1002900004D45FD510F009F02FC0EBE7F0E0F8D3FD
:1002A000E1EDF0E0FAD355D508F01EC0ADEEB0E0B8
:1002B0000D911C91A7EEB0E04D915C91041B150BC4
:1002C000ADEEB0E00D931C93ADEEB0E00D911C913E
:1002D000003050E015070CF401C006C080E090E04B
:1002E000ADEEB0E08D939C93ADEEB0E08D919C911E
:1002F00090934B0080934A00EBE7F0E0C9D3EDEC1C
:10030000F0E0CBD326D510F009F001C0E1C0E0EB5E
:10031000F0E0C3D3EBE7F0E0BBD3B1D4FF27EDE0CF
:10032000A3EEB0E0EDD5E9EEF0E0B7D3E3EEF0E018
:10033000AFD374D4FF27EDE0A3EEB0E0E1D5E3EE58
:10034000F0E026D6FF27EDE065D3A7EEB0E0EE0C97
:10035000000FE794DD92EC92A7EEB0E00D911C91B6
:10036000013050E015070CF401C006C081E090E0B8
:10037000A7EEB0E08D939C93EBE7F0E089D3EFE735
:10038000F0E08BD3E6D410F009F001C00EC0ADEE62
:10039000B0E00D911C91A7EEB0E04D915C91040F7F
:1003A000151FADEEB0E00D931C93EBE7F0E070D3BA
:1003B000EFE7F0E072D3CDD408F00EC0ADEEB0E0C0
:1003C0000D911C91A7EEB0E04D915C91041B150BB3
:1003D000ADEEB0E00D931C93EBE7F0E059D3EFE7FF
:1003E000F0E05BD3B6D409F00CC0ADEEB0E00D91F7
:1003F0001C914AE050E0040F151FADEEB0E00D93E4
:100400001C93ADEEB0E00D911C910F3F53E015072A
:1004100014F009F001C006C08FEF93E0ADEEB0E03C
:100420008D939C93ADEEB0E00D911C91003050E0A7
:1004300015070CF401C006C080E090E0ADEEB0E01E
:100440008D939C93ADEEB0E08D919C9190934B0079
:1004500080934A00EBE7F0E01BD3E5ECF0E01DD31E
:1004600078D408F035C0919AEBE7F0E016D3E5ECCC
:10047000F0E00ED304D4FF27EDE0AFEEB0E040D5BE
:10048000EFEEF0E00AD3EBEDF0E002D371D3FF27FB
:10049000EDE0A5EDB0E034D5EFEDF0E0FED2E5ED16
:1004A000F0E0F6D2BBD3FF27EDE0A5EDB0E028D514
:1004B000E5EDF0E0EDD2EBEDF0E0EFD24AD410F054
:1004C00009F001C005C0EBEDF0E0A5EDB0E018D5F6
:1004D000EBE7F0E0DDD2E5ECF0E0DFD23AD410F06B
:1004E00009F001C006C09198A5EDB0E0E2ECFFE094
:1004F000EDD0E5EDF0E04CD5FF27EDE08BD2A9ED96
:10050000B0E0EE0C000FE794DD92EC92A9EDB0E0C4
:100510000D911C91003050E0150714F009F001C056
:100520001BC080E090E0AFEBB0E08D939C93A9ED11
:10053000B0E04D915C91AFEBB0E00D911C910417D0
:10054000150714F009F008C084E690E06CD169D07A
:10055000AFEBB0E0C2D0EBCF0895A8E2B4E0AF9328
:10056000BF93E7E7F0E094D26DD111E001E0BF91D5
:10057000AF9112D4E8E2F4E0AEE8B0E0BCD4A8E277
:10058000B4E0AF93BF93E1EAF0E082D25BD111E037
:1005900001E0BF91AF9100D4E8E2F4E0A5EAB0E059
:1005A000AAD4A8E2B4E0AF93BF93E0EBF0E070D23E
:1005B00049D111E001E0BF91AF91EED3E8E2F4E060
:1005C000A4EBB0E098D48FE711E0AAD0AEE8B0E099
:1005D0008CD0E2EDFFE08FD08FE717E0A1D0E6ED01
:1005E000FFE089D0A4EBB0E080D0EEEDFFE083D057
:1005F0008FEB11E095D0A5EAB0E077D0E0EEFFE018
:100600007AD08FEB19E08CD0E6EEFFE074D0A8E250
:10061000B4E0EDEEF0E01ED466D0EEEDFFE06BD07E
:100620000895BB27A3E38C9184FBA1ECB0E088275D
:1006300080F98D9388278C93BB27A3E38C9185FB4E
:10064000A3ECB0E0882780F98D9388278C93A1ECE8
:10065000B0E00D911C91003050E0150709F00FC07B
:10066000E6EAFFE06DD3E0EBF0E012D217D3FF270C
:10067000EDE0A0EBB0E044D48CE291E0D4D0A3EC68
:10068000B0E00D911C91003050E0150709F00FC04B
:10069000E6EAFFE055D3E0EBF0E0FAD1F0D2FF2735
:1006A000EDE0A0EBB0E02CD48CE291E0BCD0E0EB2C
:1006B000F0E0EED1E6EAFFE043D34BD308F005C00B
:1006C000A0EBB0E0E6EAFFE001D0089584E0C89531
:1006D00031960D928A95D9F70895ED91FC91319656
:1006E000FC93EE930895A8E2B4E08D91882311F075
:1006F00068D0FBCF089520D3802D11F062D0FBCFBE
:10070000089581E064D014D080E861C08FE7213083
:1007100039F08FEB223021F08FE8233009F08FEC95
:10072000810F55C088EE93E07ED03197D9F70895B8
:1007300083E0992778C08AEF90E075D08F9A8E9ADF
:100740008D9A8C9A8B9A8A9A9298EF93FF93E5E10F
:10075000F0E05DD0FF91EF91939897989698959AD5
:10076000949A939AEF93FF93E5E1F0E050D0FF91D4
:10077000EF91939855D0939AEF93FF93E5E1F0E0D2
:1007800046D0FF91EF9193984BD0939AEF93FF93BC
:10079000E5E1F0E03CD0FF91EF91939841D094983F
:1007A000939AEF93FF93E5E1F0E031D0FF91EF9161
:1007B000939836D088E20BD08EE009D086E007D03F
:1007C0000895929A829505D004D02AD008959298DF
:1007D000F9CF859510F4949A01C09498859510F4FA
:1007E000959A01C09598859510F4969A01C09698AF
:1007F000859510F4979A01C09798939AEF93FF9379
:10080000E5E1F0E004D0FF91EF91939808953197DE
:10081000F1F70895689462F80895E89462F80895ED
:1008200081E090E000C0EF93FF93EE27E82BE92BE7
:1008300031F0EAEFF0E03197F1F70197D1F7FF914E
:10084000EF9108958DE207FD8D938F2D881F802FE6
:10085000881F8F57082F6894F7F8802F87FF15C0DF
:1008600080958395082F80E38D938EE28D93802F62
:10087000815228F080E38D9399279C930895442713
:100880000A95802F09F192D01FC0805230F09EE46B
:100890009D9381E48D939D93EFCF4427DF92EF9258
:1008A000FF920F938FE1801B11F0082F7FD085D02E
:1008B0009EE29D930F91FF90EF90DF904427039568
:1008C000003209F4D7CF27D03F93ECE4F9E038E1C8
:1008D0002F2D1E2D0D2DFF24EE24DD244427000F87
:1008E000111F221F88F42F923F9226D2102C24D25F
:1008F000202C22D2302C20D23197410DD21CE31C67
:10090000F01C3F902F9001C0339631963A9539F7FD
:100910003F9107D0B3CFDD0CEE1CFF1C0A95D9F731
:100920000895002719E058D08F93802B11F003957C
:1009300001C08F911A95B9F7802F882309F49ACFB7
:100940008F91805D8D930A95D9F796CF0065CD1D67
:1009500080B2E60E40597307A0ACB90350D6DC0153
:10096000286BEE0094357700CA9A3B0065CD1D00D8
:10097000B2E60E0059730700ACB90300D6DC0100E3
:100980006BEE0000357700009A3B0000CD1D0000A3
:10099000E60E000073070000B9030000DC01000050
:1009A000EE000000770000003B000000F694E794A2
:1009B000D79447950A95D1F7089500270DD08F93C6
:1009C00003958F2D8E298D29842BC1F78F91805D02
:1009D0008D930A95D9F750CF1F930F93002710E2FC
:1009E000440FDD1CEE1CFF1C001F802F9AE0890BBA
:1009F00010F0082F43951A9599F7802F0F911F91AA
:100A00000895369A3699FECF369A3699FECF84B13C
:100A100095B108953DD0992711278F2D880F80E833
:100A2000F82A802F881F08F41FEF41F08F57082FF6
:100A300007FD04C0003240F08FEF01C08827982FD7
:100A4000D82EE82EF82E09C08FE1801B082FF694CF
:100A5000E794D79497950A95D1F7112351F0909583
:100A6000D094E094F09481E0980F8827D81EE81E77
:100A7000F81E0F2DFE2CED2CD92E0895D094E09465
:100A8000F09491E0D90E9927E91EF91E109508956A
:100A9000D190E190F190019108952191319141918E
:100AA00051910895102F90E8FF0C001F0927990F0E
:100AB000F7941078652F90E8440F551F5927990F28
:100AC0004795607800380895FF0C90E89027110F43
:100AD0009795F794092F0895102FBD2CDE2CEF2C3D
:100AE000F02E11234AF4B094D094E094F0949FEF48
:100AF000B91AD90AE90AF90A0EE1FF2039F4FE2CE5
:100B0000ED2CDB2CBB240850C2F766C032F00A95EE
:100B1000BB0CDD1CEE1CFF1CF9CF01D0D5CFB7FEFE
:100B2000089590E8B91611F4D0FE08959FEFD91AF0
:100B3000E90AF90A09F403950895502F2D2D3E2D49
:100B40004F2D612F08952DEC3CEC4CEC5DE36627B6
:100B50000FC09EDFF2DFDD24EE2490E8F92E0FE3D4
:100B600007C09BDF05C02227332740E251E46627F8
:100B7000552351F1002381F195DF71F116270058BB
:100B800050580894050B18F407FD03C025C007FD55
:100B900023C0469537952795F694E794D79422D0AD
:100BA000FF202AF0DD0CEE1CFF1C015073F09D2D80
:100BB000969548F0DD203AF4EE202AF491E0D90E23
:100BC0009927E91EF91E80CF07C09FE7092FF92A50
:100BD0009FEFD92EE92E0895DD24EE24FF2400276F
:100BE000112708959F929924AA24BB2488E1D21644
:100BF000E306F40628F0D21AE30AF40A089401C0C6
:100C00008894991CAA1CBB1CDD0CEE1CFF1C8A9549
:100C100071F7D92CEA2CFB2C9F90089543DFE1F269
:100C20005038D1F21627005850580894051F12F476
:100C300018F4CBCF08F0D0CF0AD0FF202AF0BB0C9D
:100C4000DD1CEE1CFF1C40CF0F5FFBF13DCF9F92E0
:100C50009924AA24BB24992788E1990CAA1CBB1CBF
:100C6000DD1CEE1CFF1C30F4920EA31EB41ED91E18
:100C7000E91EF91E8A9589F79F9008950EDF12DF0D
:100C8000503829F090E869270CC00AF045D01CCFF5
:100C90005FE322273327442701C0FFDE03DF5038FC
:100CA000B1F3003899F3902F951B8BF312F434D0E5
:100CB000FACF983118F0222733274427983028F0AC
:100CC000232F342F44279850F9CF992329F04695A4
:100CD000379527959A95D9F7912F962742F014D0FA
:100CE000B0F6F794E794D7940F5F8BF66ECF10D0E1
:100CF00051F008F4C3DEFF2052F2DD0CEE1CFF1CA5
:100D00000150CBF762CF68CFD20EE31EF41E0895D8
:100D1000D21AE30AF40A0895DF92EF92FF920F933A
:100D20001F93D22EE32EF42E052F162F6F915F9175
:100D30004F913F912F910895C895319600200895C5
:100D4000FBDF202DF9DF302DF7DF402DF5DF502DB3
:100D5000089507FB00680EF40F7757FB50680EF4F8
:100D60005F7707FD02C057FF05C0D216E306F40601
:100D7000050708952D153E054F055007089599273D
:100D80008D9193958823E1F7939511968C93119704
:100D90008E919A95D1F70895EA2FFB2F00244C915C
:100DA0008D9103948E32E1F711248D911394882351
:100DB000E1F71A94101640F41197202F211923956A
:100DC00080E38D932A95E9F7113039F59927AE2FF5
:100DD000BF2FA00DB91FA00FB91F8C919C93853315
:100DE00008F421C031E08E918E32E9F38D3241F06A
:100DF000830F8A3319F480E331E001C033278C93E9
:100E0000AE1789F7332341F0AE2FBF2FB8DF81E350
:100E10004D3209F43196808308958827E00DF81F3C
:100E2000E00FF81F80830895000F111F221F331F4A
:100E3000089500951095209530950F5F1F4F2F4F07
:100E40003F4F0895019110810EC0019111912191A0
:100E500030810BC00191108117FF05C03FEF2FEFCC
:100E600004C0008111272227332737FF03C0E1DFA9
:100E70008DE28D93CF93DF93CF92DF92EF92AA24EE
:100E8000BB24CC24DD24EE2440E2CAE0DD2755E07B
:100E900093E38881890F87FD9F7083FD907F891B75
:100EA00089935A95A9F7C0DFAA1CBB1CCC1CDD1C7A
:100EB000EE1C4A9551F7E894EFE0FF2782910ED09F
:100EC000EB30E0F71EF068948A2D0CD088278D93C4
:100ED000EF90DF90CF90DF91CF910895982F82957A
:100EE00001D0892F8F70805D26F0803309F408953A
:100EF00068948D93089581918D938823E1F70895E7
:100F000094E081918D939A95E1F70895C1DD80E099
:100F100003C0BEDD802F8078882321F0DF92EF921E
:100F2000FF920F938F93BEDD802F839512F454DED2
:100F30001BC080958A95885E0AF415C088501AF403
:100F40000CD0D92210C0DD2488501AF406D0E92232
:100F50000AC0EE2402D0F92206C09FEF8770990FD5
:100F60008A95EAF70895B0DD8F918823D9F35F91D0
:100F70004F913F912F910F93ECDE0F9199F390F3E6
:100F800002D050688BCE5FE340E8332722270895D4
:100F90007FDD0F930F777CDEBDDF8F918078082B8C
:100FA00008950000E0410000803F00002041000063
:100FB000C841000048420000A03B0000C8420000B9
:100FC0007A44000000004C75656674657220312E0D
:100FD00034002043200020536F6C6C3A0000200046
:0C0FE0006D412020000050776D3A0000A9
:00000001FF

View File

@ -0,0 +1,3 @@
rem Batchdatei zum Programmieren des Proz. mit AVR-Dude
rem ISP-AVR-Programmer an der parallelen Schnittstelle
avrdude -p m8 -c stk200 -U flash:w:luefter1.hex

View File

@ -0,0 +1,302 @@
$regfile = "m8def.dat" ' ATMega8
$crystal = 1000000 ' 1 MHz ist schnell genug
Const Const5 = 0.0048828125 ' 5Volt / 1024 (10-Bit-ADC)
Dim Adc0 As Word ' Wert vom NTC
Dim Volt0 As Single ' Volt vom NTC
Dim Disp_volt0 As String * 10 ' für die LCD-Anzeige
Dim Adc1 As Word ' Wert vom LM35
Dim Volt1 As Single ' Volt vom LM35
Dim Templm35 As Single ' Temperatur (celsius) von LM35
Dim Isttemp As Single ' aktuelle Temperatur in Celsius
Dim Letzter_isttemp As Single ' Messwert davor
Dim Disp_volt1 As String * 10 ' zur LCD-Anzeige
Dim Disp_templm35 As String * 10 ' zur LCD-Anzeige
Dim Adc2 As Word ' nicht benötigt
Dim Adc3 As Word ' Wert vom ADC vom IRF510
Dim Volt3 As Single ' Volt vom IRF510
Dim Strom As Single ' Strom vom IRF510
Dim Disp_strom As String * 10 ' zur LCD-Anzeige
Dim Solltemp As Single ' Vorgabe der maximal zulässigen Temperatur
Dim Disp_solltemp As String * 10 ' zur LCD-Anzeige
Dim I As Integer ' Zähler / Schleife
Declare Sub Adc_in
Declare Sub Regeln
Declare Sub Anzeigen
Declare Sub Tasten
Config Lcdbus = 4
Config Lcd = 16 * 2
'Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Portb = Output
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Prescale = 1
' Tasten zur Einstellung der Solltemperatur
Taste_up Alias Pinc.4
Taste_dn Alias Pinc.5
Dim Tasteup As Integer
Dim Tastedn As Integer
Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input
Config Pinc.3 = Input
Config Pinc.4 = Input
Set Portc.4
Config Pinc.5 = Input
Set Portc.5
Config Adc = Single , Prescaler = Auto , Reference = Avcc
' Led
Ledgruen Alias Portd.0
Ledrot Alias Portd.1
Config Portd.0 = Output
Config Portd.1 = Output
Dim Dynamikgrenze_oben As Single
Dim Dynamikgrenze_unten As Single
Dim Toleranzgrenze_oben As Single ' in den Toleranzgrenzem wired nicht geregelt
Dim Toleranzgrenze_unten As Single
Dim Pausenzeit As Single ' Pause zwischen den Regelungen
Dim Pausenzeit_int As Integer
Dim Pausenzeit_max As Single ' max. zulässige Pausenzeit
Dim Pausenzeit_faktor As Single
Dim Schrittweite As Single ' um diesen Betrag wird PWM korrigiert
Dim Schrittweite_int As Integer
Dim Schrittweite_faktor As Single
Dim Pwmwert As Integer ' 10-Bit PWM (0...1023)
Dim Differenz As Single
' ------------------------------------------------------------------------------
' ----------------------- Initialisierung der Variablen ------------------------
' ------------------------------------------------------------------------------
'Solltemperatur (max, zulässige Temperatur)
Solltemp = 28
Toleranzgrenze_oben = Solltemp + 1
Toleranzgrenze_unten = Solltemp - 1
Dynamikgrenze_oben = Toleranzgrenze_oben + 10
Dynamikgrenze_unten = Toleranzgrenze_unten - 10
Pausenzeit = 25 ' zu Beginn mittlere Pausenzeit einstellen (2 Sek.)
Pausenzeit_faktor = 1 ' Multiplikator für die Bestimmung der Pausenzeit
Pausenzeit_max = 50 ' z.B. 50 * 1/10 Sek. = 5 Sekunden
Schrittweite = 50 ' Anfangswert
Schrittweite_int = 50 ' Anfangswert
Schrittweite_faktor = 10 '
Disable Interrupts
' ------------------------------------------------------------------------------
' Beginn Programm
' ------------------------------------------------------------------------------
Reset Ledgruen ' grüne LED einschalten
Call Adc_in
'Pwm1a = 0 ' Motor aus
Pwmwert = 500
Pwm1a = Pwmwert ' Motor max ein
Cursor Off
Cls
Locate 1 , 4
Lcd "Luefter 1.4"
Wait 5 ' Lüfter anlaufen lassen
Cls
Do
Call Adc_in
Call Tasten
Call Anzeigen
Call Regeln
Loop
' ADC lesen
Sub Adc_in
Start Adc
Letzter_isttemp = Isttemp ' letzten Messwert merken
Adc0 = Getadc(0) ' NTC
Adc1 = Getadc(1) ' LM35
Adc2 = Getadc(2) ' nix
Adc3 = Getadc(3) ' für Strom IRF510
Volt0 = Adc0 * Const5 ' NTC
Volt1 = Adc1 * Const5 ' LM35
Templm35 = Volt1 * 100 ' in Celsius umrechnen (10mV je Grad über Null)
Isttemp = Templm35 ' aktuelle Temperatur am LM35
Volt3 = Adc3 * Const5 ' Strom durch den IRF510 berechnen
'Strom = Volt3 / 2.7 ' I = U / R R=2,7 Ohm
Strom = Volt3 ' I = U / R R=1 Ohm
Strom = Strom * 1000 ' Ampere in mA
Stop Adc
End Sub
Sub Regeln
' Pausenzeit außerhalb Dynamikbereichs einstellen
If Isttemp > Dynamikgrenze_oben Then
Pausenzeit = 0 ' kürzest mögliche Pause
End If ' dann schnell regeln
' Temperatur unterhalb Solltemperatur
If Isttemp <= Solltemp Then ' Temp ist kälter als erlaubt
If Isttemp < Toleranzgrenze_unten Then ' unterhalb Toleranzgrenze ?
Pwmwert = Pwmwert - Schrittweite_int ' versuchen, ob Lüfter leiser werden kann
If Pwmwert < 0 Then
Pwmwert = 0
End If
End If
Pwm1a = Pwmwert
End If ' endif isttemp < solltemp
' Bereich oberhalb Solltemperatur
If Isttemp > Toleranzgrenze_oben Then ' Temp zu hoch, PWM-Wert steigern
' Schrittweite berechnen, um die der PWM-Wert korrigiert wird
Schrittweite = Isttemp - Solltemp
Schrittweite = Schrittweite * Schrittweite_faktor
Schrittweite_int = Round(schrittweite)
If Schrittweite_int < 1 Then
Schrittweite_int = 1
End If
If Isttemp > Letzter_isttemp Then
Pwmwert = Pwmwert + Schrittweite_int
End If
If Isttemp < Letzter_isttemp Then
Pwmwert = Pwmwert - Schrittweite_int
End If
If Isttemp = Letzter_isttemp Then
Pwmwert = Pwmwert + 10
End If
If Pwmwert > 1023 Then
Pwmwert = 1023
End If
If Pwmwert < 0 Then
Pwmwert = 0
End If
Pwm1a = Pwmwert ' PWM des Motors steuern
If Isttemp < Dynamikgrenze_oben Then ' im Regelbereich, in dem die Pausenzeit angepasst wird ?
Set Ledrot ' rote LED aus
' Pausenzeit berechnen für (Toleranzgrenze oben < x < Dynamikgrenze oben)
Differenz = Dynamikgrenze_oben - Isttemp
Pausenzeit = Pausenzeit_max / Differenz
Pausenzeit = Pausenzeit * Pausenzeit_faktor
If Pausenzeit > Pausenzeit_max Then
Pausenzeit = Pausenzeit_max
End If
' nun steht in Pausenzeit die Pausenzeit 1/10 Sekunden
End If
End If ' if Toleranzgrenze_oben < Isttemp
If Isttemp > Dynamikgrenze_oben Then ' Ist > als Dynamikgrenze oben, also SEHR hoch
Reset Ledrot ' warnen
Pausenzeit = 0
End If
Pausenzeit_int = Round(pausenzeit) ' Pausenzeit (SINGLE) in INTEGER wandeln
' Pausenzeit vergehen lassen
If Pausenzeit_int > 0 Then
For I = 0 To Pausenzeit_int
Waitms 100 ' Zeit verplempern in Einheiten von 1/10 Sekunde
Call Tasten
Next I
End If
End Sub
Sub Anzeigen
' Disp_volt0 = Fusing(volt0 , "#.###")
' Disp_volt1 = Fusing(volt1 , "#.###")
Disp_templm35 = Fusing(templm35 , "##.#")
Disp_strom = Fusing(strom , "###.#")
Disp_solltemp = Fusing(solltemp , "###.#")
' LCD zweizeilig je 16 Zeichen
Locate 1 , 1
Lcd Disp_templm35 ; " C "
Locate 1 , 7
Lcd " Soll:" ; Disp_solltemp ; " "
Locate 2 , 1
Lcd Disp_strom ; "mA ";
Locate 2 , 9
Lcd "Pwm:" ; Pwmwert ; " "
' LCD vierzeilig je 20 Zeilen
'Locate 2 , 2
'Lcd "NTC " ; Disp_volt0 ; " V "
'Locate 3 , 2
'Lcd "LM35 " ; Disp_templm35 ; " C "
'Locate 4 , 2
'Lcd "IRF510 " ; Disp_strom ; " mA ";
'Lcd "Pwm:" ; Pwmwert ; " "
'Locate 4 , 11
'Lcd " Sw:" ; Schrittweite_int ; " "
End Sub
Sub Tasten
Tasteup = Taste_up
Tastedn = Taste_dn
If Tasteup = 0 Then
Solltemp = Solltemp + 1
Waitms 300
End If
If Tastedn = 0 Then
Solltemp = Solltemp - 1
Waitms 300
End If
If Solltemp < 1 Then
Solltemp = 1
End If
End Sub

Binary file not shown.

View File

@ -0,0 +1,277 @@
:1000000012C0189518951895189518951895189563
:100010001895189518951895189518951895189578
:100020001895189518958FE58DBFC0E4E0E44E2E25
:1000300084E08EBFD4E0F4E05F2EEEEFF3E0A0E6C4
:10004000B0E088278D933197E9F7E7D366248FEFE7
:1000500087BBB99A83E88FBD81E08EBDA098A19837
:10006000A298A398A498AC9AA598AD9A86E086B970
:1000700080E487B980B7806180BF889A899AE6E971
:10008000F0E088E416D458E0C895802D0CD4319661
:100090005A95D1F704C00E0A0E2020202020E6EB4E
:1000A000F0E080E506D458E0C895802DFCD3319669
:1000B0005A95D1F704C0040A150404040404E6EDBB
:1000C000F0E088E5F6D358E0C895802DECD3319662
:1000D0005A95D1F704C00404040404150A048CE002
:1000E000E8D384E690E011D4A2ECB0E0EAEDF0E1D0
:1000F0005FD3ACECB0E0EEEDF0E15AD3A8ECB0E0A9
:10010000E2EEF0E155D3A0EDB0E0E2EEF0E150D345
:1001100082E390E0A4EDB0E08D939C93A6EDB0E077
:10012000E6EEF0E145D3E4E0F0E0BB27A0E180D7C4
:100130000F3F09F012C0EAEEF0E174D6E0E0F0E023
:10014000ADE0BB2794E07BE765D7E4E0F0E0A0E119
:10015000BB278AEA8C937BE75AD7ADE9B0E0E0E0B1
:10016000F0E094E068D784EF91E0CFD3F894909AD0
:10017000919A27D084EF91E0AAEDB0E08D939C9303
:10018000AAEDB0E08D919C9190934B0080934A0032
:100190008CE08FD328D38FE712E034D3EAE0F1E18B
:1001A0001CD3E5E0F0E030D31ED3909A0AD057D2AA
:1001B000EDD168D0909884E690E0A7D3F6CFF8947C
:1001C000FFCF379AEAE6F0E0AEE6B0E014D781E47C
:1001D000806487B988D4A0E6B0E08D939C9383E4D3
:1001E000806487B980D4A8E8B0E08D939C93EEEE4C
:1001F000F0E121D6E0E6F0E0D190E080FF24002796
:10020000DDD47ED5FF27EDE0A2E6B0E0F4D6E2EF44
:10021000F0E111D6E2E6F0E0ADD472D5FF27EDE0D3
:10022000A6E6B0E0E8D6E6E6F0E0AAE6B0E0E3D67F
:10023000EEEEF0E100D6E8E8F0E0D190E080FF24B7
:100240000027BCD45DD5FF27EDE0AAE8B0E0D3D607
:10025000E6EFF0E1F0D5EAE8F0E08CD4FBD4FF273C
:10026000EDE0AEE8B0E0C7D6EAEFF0E1E4D5EEE8C5
:10027000F0E080D445D5FF27EDE0AEE8B0E0BBD696
:1002800037980895EAE6F0E075D4E2EBF0E077D431
:10029000DBD510F009F001C005C0A2ECB0E0EEEF34
:1002A000F0E186D2EAE6F0E065D4EDE9F0E067D46B
:1002B000CBD510F009F034C08FE719E0A3D283E06A
:1002C000F2D2EAE6F0E056D4EEEBF0E058D4BCD53A
:1002D00008F01EC0AAEDB0E00D911C91A4EDB0E0B5
:1002E0004D915C91041B150BAAEDB0E00D931C938E
:1002F000AAEDB0E00D911C91003050E015070CF410
:1003000001C006C080E090E0AAEDB0E08D939C9320
:10031000AAEDB0E08D919C9190934B0080934A00A0
:10032000EAE6F0E027D4EAEBF0E029D48DD510F02E
:1003300009F001C0E6C08FE719E064D282E0B3D2D1
:10034000EDE9F0E01CD4EAE6F0E014D40AD5FF278A
:10035000EDE0A0EDB0E04FD6E6EDF0E010D4E0ED3A
:10036000F0E008D4CDD4FF27EDE0A0EDB0E043D617
:10037000E0EDF0E0A9D6FF27EDE0BED3A4EDB0E0BC
:10038000EE0C000FE794DD92EC92A4EDB0E00D913D
:100390001C91013050E015070CF401C006C081E04B
:1003A00090E0A4EDB0E08D939C93EAE6F0E0E2D318
:1003B000EEE6F0E0E4D348D510F009F001C00EC03D
:1003C000AAEDB0E00D911C91A4EDB0E04D915C91CF
:1003D000040F151FAAEDB0E00D931C93EAE6F0E0C0
:1003E000C9D3EEE6F0E0CBD32FD508F00EC0AAEDCE
:1003F000B0E00D911C91A4EDB0E04D915C91041B17
:10040000150BAAEDB0E00D931C93EAE6F0E0B2D331
:10041000EEE6F0E0B4D318D509F00CC0AAEDB0E0D8
:100420000D911C914AE050E0040F151FAAEDB0E0B9
:100430000D931C93AAEDB0E00D911C910F3F53E07A
:10044000150714F009F001C006C08FEF93E0AAED84
:10045000B0E08D939C93AAEDB0E00D911C9100301B
:1004600050E015070CF401C006C080E090E0AAED52
:10047000B0E08D939C93AAEDB0E08D919C91909308
:100480004B0080934A00EAE6F0E074D3E2EBF0E040
:1004900076D3DAD408F035C0919AEAE6F0E06FD36B
:1004A000E2EBF0E067D35DD4FF27EDE0ACEDB0E028
:1004B000A2D5ECEDF0E063D3E8ECF0E05BD3CAD377
:1004C000FF27EDE0A2ECB0E096D5ECECF0E057D3DE
:1004D000E2ECF0E04FD314D4FF27EDE0A2ECB0E063
:1004E0008AD5E2ECF0E046D3E8ECF0E048D3ACD4B7
:1004F00010F009F001C005C0E8ECF0E0A2ECB0E0BB
:100500007AD5EAE6F0E036D3E2EBF0E038D39CD4DB
:1005100010F009F001C006C09198A2ECB0E0EEEF37
:10052000F0E146D1E2ECF0E0CFD5FF27EDE0E4D2F8
:10053000A6ECB0E0EE0C000FE794DD92EC92A6EC96
:10054000B0E00D911C91003050E0150714F009F057
:1005500001C01BC080E090E0ACEAB0E08D939C93BA
:10056000A6ECB0E04D915C91ACEAB0E00D911C912D
:100570000417150714F009F008C084E690E0C5D10F
:100580006ED0ACEAB0E01BD1EBCF0895A8E2B4E0A6
:10059000AF93BF93E6E6F0E0EDD2C6D111E001E003
:1005A000BF91AF9174D4E8E2F4E0ADE7B0E01ED5BE
:1005B000A8E2B4E0AF93BF93EEE8F0E0DBD2B4D1B1
:1005C00011E001E0BF91AF9162D4E8E2F4E0A2E96A
:1005D000B0E00CD5A8E2B4E0AF93BF93EDE9F0E052
:1005E000C9D2A2D111E001E0BF91AF9150D4E8E2AD
:1005F000F4E0A1EAB0E0FAD48FE711E003D1EAE138
:10060000F1E1EBD0ADE7B0E0E2D081E04CD1EEE13A
:10061000F1E1E3D08FE71AE0F5D0E0E2F1E1DDD0DF
:10062000A1EAB0E0D4D0E4E2F1E1D7D08FEB11E061
:10063000E9D0A2E9B0E0CBD0E6E2F1E1CED08FEB99
:1006400019E0E0D0ECE2F1E1C8D0A8E2B4E0EAEDD4
:10065000F0E07BD4BAD0E4E2F1E1BFD00895BB274B
:10066000A3E38C9184FBAEEAB0E0882780F98D93F8
:1006700088278C93BB27A3E38C9185FBA0EBB0E08C
:10068000882780F98D9388278C93AEEAB0E00D918E
:100690001C91003050E0150709F01AC0ADE9B0E038
:1006A000EEEDF0E1C8D3EDE9F0E064D269D3FF27C5
:1006B000EDE0ADE9B0E09FD4E0E0F0E0ADE9B0E01E
:1006C00094E07BE7A7D491988CE291E01ED1919AB7
:1006D000A0EBB0E00D911C91003050E0150709F03F
:1006E00018C0EEEDF0E1A7D3EDE9F0E043D239D345
:1006F000FF27EDE0ADE9B0E07ED4E0E0F0E0ADE969
:10070000B0E094E07BE786D491988CE291E0FDD054
:10071000919AEDE9F0E02ED2EEEDF0E18CD394D396
:1007200008F005C0ADE9B0E0EEEDF0E141D0EDE953
:10073000F0E020D2E2E0F1E17ED386D310F009F0C0
:1007400001C005C0ADE9B0E0E2E0F1E131D0EEED8D
:10075000F0E171D3EDE9F0E00DD212D3FF27EDE027
:10076000AAEBB0E048D4EEEDF0E165D3EDE9F0E0BE
:1007700001D2F7D2FF27EDE0AEEBB0E03CD4E6E0EB
:10078000F1E159D3EAEBF0E0F5D1FAD2FF27EDE041
:10079000A2EBB0E030D4E6E0F1E14DD3EEEBF0E0D7
:1007A000E9D1DFD2FF27EDE0A6EBB0E024D4089535
:1007B00084E0C89531960D928A95D9F70895ED9108
:1007C000FC913196FC93EE930895A8E2B4E08D91EC
:1007D000882311F068D0FBCF089520D3802D11F02D
:1007E00062D0FBCF089581E064D014D080E861C06E
:1007F0008FE7213039F08FEB223021F08FE8233062
:1008000009F08FEC810F55C088EE93E07ED03197D0
:10081000D9F7089583E0992778C08AEF90E075D0E2
:100820008F9A8E9A8D9A8C9A8B9A8A9A9298EF9335
:10083000FF93E4ECF0E05DD0FF91EF9193989798EF
:100840009698959A949A939AEF93FF93E4ECF0E03C
:1008500050D0FF91EF91939855D0939AEF93FF93D7
:10086000E4ECF0E046D0FF91EF9193984BD0939A4F
:10087000EF93FF93E4ECF0E03CD0FF91EF9193987D
:1008800041D09498939AEF93FF93E4ECF0E031D049
:10089000FF91EF91939836D088E20BD08EE009D08B
:1008A00086E007D00895929A829505D004D02AD088
:1008B00008959298F9CF859510F4949A01C0949870
:1008C000859510F4959A01C09598859510F4969A9F
:1008D00001C09698859510F4979A01C09798939ABD
:1008E000EF93FF93E4ECF0E004D0FF91EF91939845
:1008F00008953197F1F70895689462F80895E8949F
:1009000062F8089581E090E000C0EF93FF93EE2736
:10091000E82BE92B31F0E0EDF7E03197F1F70197A3
:10092000D1F7FF91EF9108958DE207FD8D938F2D03
:10093000881F802F881F8F57082F6894F7F8802F03
:1009400087FF15C080958395082F80E38D938EE2F5
:100950008D93802F815228F080E38D9399279C936B
:10096000089544270A95802F09F192D01FC0805224
:1009700030F09EE49D9381E48D939D93EFCF4427C7
:10098000DF92EF92FF920F938FE1801B11F0082FFF
:100990007FD085D09EE29D930F91FF90EF90DF90E6
:1009A00044270395003209F4D7CF27D03F93E0E3E3
:1009B000FAE038E12F2D1E2D0D2DFF24EE24DD242D
:1009C0004427000F111F221F88F42F923F9226D236
:1009D000102C24D2202C22D2302C20D23197410D41
:1009E000D21CE31CF01C3F902F9001C0339631962F
:1009F0003A9539F73F9107D0B3CFDD0CEE1CFF1CC1
:100A00000A95D9F70895002719E058D08F93802BC5
:100A100011F0039501C08F911A95B9F7802F8823A3
:100A200009F49ACF8F91805D8D930A95D9F796CF6F
:100A30000065CD1D80B2E60E40597307A0ACB90326
:100A400050D6DC01286BEE0094357700CA9A3B0043
:100A500065CD1D00B2E60E0059730700ACB9030066
:100A6000D6DC01006BEE0000357700009A3B0000F9
:100A7000CD1D0000E60E000073070000B903000062
:100A8000DC010000EE000000770000003B000000E9
:100A9000F694E794D79447950A95D1F708950027DF
:100AA0000DD08F9303958F2D8E298D29842BC1F71F
:100AB0008F91805D8D930A95D9F750CF1F930F9337
:100AC000002710E2440FDD1CEE1CFF1C001F802FCE
:100AD0009AE0890B10F0082F43951A9599F7802F0B
:100AE0000F911F910895369A3699FECF369A36990E
:100AF000FECF84B195B108953DD0992711278F2D50
:100B0000880F80E8F82A802F881F08F41FEF41F033
:100B10008F57082F07FD04C0003240F08FEF01C04F
:100B20008827982FD82EE82EF82E09C08FE1801B39
:100B3000082FF694E794D79497950A95D1F7112347
:100B400051F09095D094E094F09481E0980F88272C
:100B5000D81EE81EF81E0F2DFE2CED2CD92E089560
:100B6000D094E094F09491E0D90E9927E91EF91EF3
:100B700010950895D190E190F190019108952191FF
:100B80003191419151910895102F90E8FF0C001F71
:100B90000927990FF7941078652F90E8440F551F97
:100BA0005927990F4795607800380895FF0C90E811
:100BB0009027110F9795F794092F0895102FBD2CAA
:100BC000DE2CEF2CF02E11234AF4B094D094E09454
:100BD000F0949FEFB91AD90AE90AF90A0EE1FF2049
:100BE00039F4FE2CED2CDB2CBB240850C2F766C078
:100BF00032F00A95BB0CDD1CEE1CFF1CF9CF01D0B6
:100C0000D5CFB7FE089590E8B91611F4D0FE089537
:100C10009FEFD91AE90AF90A09F403950895502FAC
:100C20002D2D3E2D4F2D612F08952DEC3CEC4CECDD
:100C30005DE366270FC09EDFF2DFDD24EE2490E83F
:100C4000F92E0FE307C09BDF05C02227332740E2C0
:100C500051E46627552351F1002381F195DF71F1AD
:100C60001627005850580894050B18F407FD03C0C8
:100C700025C007FD23C0469537952795F694E79440
:100C8000D79422D0FF202AF0DD0CEE1CFF1C01506F
:100C900073F09D2D969548F0DD203AF4EE202AF46D
:100CA00091E0D90E9927E91EF91E80CF07C09FE772
:100CB000092FF92A9FEFD92EE92E0895DD24EE247D
:100CC000FF240027112708959F929924AA24BB246A
:100CD00088E1D216E306F40628F0D21AE30AF40AF1
:100CE000089401C08894991CAA1CBB1CDD0CEE1C46
:100CF000FF1C8A9571F7D92CEA2CFB2C9F90089544
:100D000043DFE1F25038D1F21627005850580894CA
:100D1000051F12F418F4CBCF08F0D0CF0AD0FF2073
:100D20002AF0BB0CDD1CEE1CFF1C40CF0F5FFBF15B
:100D30003DCF9F929924AA24BB24992788E1990C3E
:100D4000AA1CBB1CDD1CEE1CFF1C30F4920EA31E63
:100D5000B41ED91EE91EF91E8A9589F79F90089541
:100D60000EDF12DF503829F090E869270CC00AF036
:100D700045D01CCF5FE322273327442701C0FFDE85
:100D800003DF5038B1F3003899F3902F951B8BF3A4
:100D900012F434D0FACF983118F0222733274427A1
:100DA000983028F0232F342F44279850F9CF9923D7
:100DB00029F04695379527959A95D9F7912F96273B
:100DC00042F014D0B0F6F794E794D7940F5F8BF607
:100DD0006ECF10D051F008F4C3DEFF2052F2DD0CCC
:100DE000EE1CFF1C0150CBF762CF68CFD20EE31E82
:100DF000F41E0895D21AE30AF40A0895DF92EF92DE
:100E0000FF920F931F93D22EE32EF42E052F162F51
:100E10006F915F914F913F912F910895C8953196B1
:100E200000200895FBDFD02CF9DFE02CF7DFF02C59
:100E3000F5DF002D0895F2DF202DF0DF302DEEDFFD
:100E4000402DECDF502D089507FB00680EF40F775E
:100E500057FB50680EF45F7707FD02C057FF05C0CF
:100E6000D216E306F406050708952D153E054F0535
:100E70005007089599278D9193958823E1F79395CD
:100E800011968C9311978E919A95D1F70895EA2F28
:100E9000FB2F00244C918D9103948E32E1F71124A5
:100EA0008D9113948823E1F71A94101640F411974A
:100EB000202F2119239580E38D932A95E9F711308E
:100EC00039F59927AE2FBF2FA00DB91FA00FB91F5D
:100ED0008C919C93853308F421C031E08E918E3241
:100EE000E9F38D3241F0830F8A3319F480E331E066
:100EF00001C033278C93AE1789F7332341F0AE2F0F
:100F0000BF2FB8DF81E34D3209F431968083089515
:100F10008827E00DF81FE00FF81F80830895000F69
:100F2000111F221F331F08950095109520953095AD
:100F30000F5F1F4F2F4F3F4F0895019110810EC03B
:100F400001911191219130810BC00191108117FF06
:100F500005C03FEF2FEF04C0008111272227332760
:100F600037FF03C0E1DF8DE28D93CF93DF93CF9204
:100F7000DF92EF92AA24BB24CC24DD24EE2440E2AD
:100F8000CAE0DD2755E093E38881890F87FD9F70D4
:100F900083FD907F891B89935A95A9F7C0DFAA1C0E
:100FA000BB1CCC1CDD1CEE1C4A9551F7E894EFE00D
:100FB000FF2782910ED0EB30E0F71EF068948A2D67
:100FC0000CD088278D93EF90DF90CF90DF91CF9159
:100FD0000895982F829501D0892F8F70805D26F01B
:100FE000803309F4089568948D93089581918D93C9
:100FF0008823E1F7089594E081918D939A95E1F724
:101000000895E199FECFEEBBFFBB3196089591E0C4
:1010100001C092E07B3751F47FB7F894F2DF8D91F5
:101020008DBBE29AE19A9A95C9F77FBF7727089519
:1010300091E001C092E0E5DFE09A8DB38D939A953F
:10104000D1F7089597DD80E003C094DD802F80788C
:10105000882321F0DF92EF92FF920F938F9394DD1C
:10106000802F839512F42ADE1BC080958A95885EB6
:101070000AF415C088501AF40CD0D92210C0DD240F
:1010800088501AF406D0E9220AC0EE2402D0F922D0
:1010900006C09FEF8770990F8A95EAF7089586DD5D
:1010A0008F918823D9F35F914F913F912F910F93A7
:1010B000CBDE0F9199F390F302D0506861CE5FE3DD
:1010C00040E833272227089555DD0F930F7752DE2E
:1010D000BDDF8F918078082B08950000C841000083
:1010E000803F00004842000020410000F041000025
:1010F000A03B0000C8429A99993F00007A44000042
:1011000000000000C642000080404C7565667465B2
:10111000722050574D2056330000493A00004300DA
:1011200020533A0020006D412020000050776D3A96
:021130000000BD
:00000001FF

View File

@ -0,0 +1,3 @@
rem Internal RC-OSC wird auf 8 MHz eingestellt
avrdude -p m8 -c stk200 -U flash:w:luefter3.hex -U lfuse:w:0xE4:m

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -0,0 +1,16 @@
In Luefter3.bas gibt es folgende Erweiterungen
- Erweiterung der Darstellung auf dem LCD
- Anzeige des Grad-Celsius-Symbols
- Anzeige des Temperatur-Trends mit Pfeil oben/unten
- Speichern der Solltemperatur im EEPROM nach Ändern derselben
- Beim Start: Lesen der Solltemperatur aus dem EEPROM
- Umstellung von 1 MHz auf 8 Mhz Prozessortakt
bedeutet: Fusebits entsprechend setzen bei der Programmierung
für avrdude liegt eine Batch-Datei anbei, die ndas erledigt

View File

@ -0,0 +1,335 @@
'******************************************************************************
'PWM Lueftersteuerung 17.07.2009
'Luefter_V3 - Erweiterungen: Matthias Foth
'
'Sollwert wird im EEPROM gespeichert
'
'Atmel Controller ATmega8
'AVCC Pin20 an +5V
'AREF Pin21 an +5V
'AGND Pin22 an GND
'
'Temperatur- Sensor LM35 an PC1
'Taster "Down" an PC5
'Taster "UP" an PC4
'LCD 16x2 an Port D
'LED grün an PD0
'LED rot an PD1
'IRF510 an PB1
'******************************************************************************
'$sim
$regfile = "m8def.dat" ' ATMega8
$crystal = 8000000 ' 8 MHz intern
'$crystal = 1000000 ' 1 MHz intern
Const Const5 = 0.0048828125 ' 5V / 1024 (10-Bit-ADC)
Dim Adc1 As Word ' Wert vom LM35
Dim Volt1 As Single ' Volt vom LM35
Dim Templm35 As Single ' Temperatur (celsius) von LM35
Dim Isttemp As Single ' aktuelle Temperatur in Celsius
Dim Letzter_isttemp As Single ' Messwert davor
Dim Disp_volt1 As String * 10 ' zur LCD-Anzeige
Dim Disp_templm35 As String * 10 ' zur LCD-Anzeige
Dim Adc3 As Word ' Wert vom ADC vom IRF510
Dim Volt3 As Single ' Volt vom IRF510
Dim Strom As Single ' Strom vom IRF510
Dim Disp_strom As String * 10 ' zur LCD-Anzeige
Dim Solltemp As Single ' Vorgabe der maximal zulässigen Temperatur
Dim Disp_solltemp As String * 10 ' zur LCD-Anzeige
Dim I As Integer ' Zähler / Schleife
Dim E_solltemp As Eram Single 'EEPROM Variable
Dim Eramempty As Eram Byte 'Flag wenn EEPROM noch leer ist
Declare Sub Adc_in
Declare Sub Regeln
Declare Sub Anzeigen
Declare Sub Tasten
Config Lcdbus = 4
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Portb = Output
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Prescale = 1
Taste_up Alias Pinc.4
Taste_dn Alias Pinc.5
Dim Tasteup As Integer
Dim Tastedn As Integer
Config Pinc.0 = Input
Config Pinc.1 = Input
Config Pinc.2 = Input
Config Pinc.3 = Input
Config Pinc.4 = Input
Set Portc.4
Config Pinc.5 = Input
Set Portc.5
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Set Sfior.adhsm 'ADC high speed mode ATmega8
Config Portd.0 = Output
Config Portd.1 = Output
Ledgruen Alias Portd.0
Ledrot Alias Portd.1
Deflcdchar 1 , 14 , 10 , 14 , 32 , 32 , 32 , 32 , 32 ' creating ° Symbol for Degree Centigrade
'Deflcdchar 1 , 24 , 24 , 3 , 4 , 4 , 4 , 4 , 3 'creating "°C" character (1)
'Deflcdchar 1 , 24 , 24 , 32 , 3 , 4 , 4 , 4 , 3 'creating "°C" character (1)
Deflcdchar 2 , 4 , 10 , 21 , 4 , 4 , 4 , 4 , 4 'creating "arrow top" char (2)
Deflcdchar 3 , 4 , 4 , 4 , 4 , 4 , 21 , 10 , 4 'creating "arrow down" char (3)
Cursor Off
Waitms 100
Dim Dynamikgrenze_oben As Single
Dim Dynamikgrenze_unten As Single
Dim Toleranzgrenze_oben As Single ' in den Toleranzgrenzem wired nicht geregelt
Dim Toleranzgrenze_unten As Single
Dim Pausenzeit As Single ' Pause zwischen den Regelungen
Dim Pausenzeit_int As Integer
Dim Pausenzeit_max As Single ' max. zulässige Pausenzeit
Dim Pausenzeit_faktor As Single
Dim Schrittweite As Single ' um diesen Betrag wird PWM korrigiert
Dim Schrittweite_int As Integer
Dim Schrittweite_faktor As Single
Dim Pwmwert As Integer ' 10-Bit PWM (0...1023)
Dim Differenz As Single
Const Eramemptymask = 255 'If EEprom is empty it contains 255
Const Eramfilledmask = 170 'If EEprom is filled it contains 170
' ------------------------------------------------------------------------------
' ----------------------- Initialisierung der Variablen ------------------------
' ------------------------------------------------------------------------------
Pausenzeit = 25 ' zu Beginn mittlere Pausenzeit einstellen (2 Sek.)
Pausenzeit_faktor = 1 ' Multiplikator für die Bestimmung der Pausenzeit
Pausenzeit_max = 50 ' z.B. 50 * 1/10 Sek. = 5 Sekunden
Schrittweite = 50 ' Anfangswert
Schrittweite_int = 50 ' Anfangswert
Schrittweite_faktor = 10 '
'-------------------------------------------------------------------------------
' EEprom operations
'-------------------------------------------------------------------------------
If Eramempty = Eramemptymask Then 'Default settings
E_solltemp = 30 'Solltemp im EEPROM speichern
Eramempty = Eramfilledmask
End If
Solltemp = E_solltemp 'Daten aus EEPROM lesen
Waitms 500 'warte 500ms
Disable Interrupts
' ------------------------------------------------------------------------------
' Beginn Programm
' ------------------------------------------------------------------------------
Set Ledgruen ' grüne LED aus
Set Ledrot 'rote LED aus
Call Adc_in 'Analogwerte erstmals abfragen
Pwmwert = 500
Pwm1a = Pwmwert ' Lüfter halbe Kraft voraus
Cursor Off
Cls
Locate 1 , 2
Lcd "Luefter PWM V3"
Wait 5
Cls
Do
Set Ledgruen 'LED grün aus
Call Adc_in
Call Tasten
Call Anzeigen
Call Regeln
Reset Ledgruen 'LED grün an
Waitms 100
Loop
End 'end program
'-------------------------------------------------------------------------------
Sub Adc_in ' ADC lesen
Start Adc
Letzter_isttemp = Isttemp ' letzten Messwert merken
Adc1 = Getadc(1) ' LM35
Adc3 = Getadc(3) ' für Strom IRF510
Volt1 = Adc1 * Const5 ' LM35
Templm35 = Volt1 * 100 ' in Celsius umrechnen (10mV je Grad über Null)
Isttemp = Templm35 ' aktuelle Temperatur am LM35
Volt3 = Adc3 * Const5 ' Strom durch den IRF510 berechnen
Strom = Volt3 / 1.2 ' I = U / R R=1,2 Ohm
Strom = Strom * 1000 ' Ampere in mA
Stop Adc
End Sub
Sub Regeln
' Pausenzeit außerhalb Dynamikbereichs einstellen
If Isttemp > Dynamikgrenze_oben Then
Pausenzeit = 0 ' kürzest mögliche Pause
End If ' dann schnell regeln
' Temperatur unterhalb Solltemperatur
If Isttemp <= Solltemp Then ' Temp ist kälter als erlaubt
Locate 1 , 9
Lcd Chr(3)
If Isttemp < Toleranzgrenze_unten Then ' unterhalb Toleranzgrenze ?
Pwmwert = Pwmwert - Schrittweite_int ' versuchen, ob Lüfter leiser werden kann
If Pwmwert < 0 Then
Pwmwert = 0
End If
End If
Pwm1a = Pwmwert
End If ' endif isttemp < solltemp
' Bereich oberhalb Solltemperatur
If Isttemp > Toleranzgrenze_oben Then ' Temp zu hoch, PWM-Wert steigern
Locate 1 , 9
Lcd Chr(2)
' Schrittweite berechnen, um die der PWM-Wert korrigiert wird
Schrittweite = Isttemp - Solltemp
Schrittweite = Schrittweite * Schrittweite_faktor
Schrittweite_int = Round(schrittweite)
If Schrittweite_int < 1 Then
Schrittweite_int = 1
End If
If Isttemp > Letzter_isttemp Then
Pwmwert = Pwmwert + Schrittweite_int
End If
If Isttemp < Letzter_isttemp Then
Pwmwert = Pwmwert - Schrittweite_int
End If
If Isttemp = Letzter_isttemp Then
Pwmwert = Pwmwert + 10
End If
If Pwmwert > 1023 Then
Pwmwert = 1023
End If
If Pwmwert < 0 Then
Pwmwert = 0
End If
Pwm1a = Pwmwert ' PWM des Motors steuern
If Isttemp < Dynamikgrenze_oben Then ' im Regelbereich, in dem die Pausenzeit angepasst wird
Set Ledrot ' rote LED aus
' Pausenzeit berechnen für (Toleranzgrenze oben < x < Dynamikgrenze oben)
Differenz = Dynamikgrenze_oben - Isttemp
Pausenzeit = Pausenzeit_max / Differenz
Pausenzeit = Pausenzeit * Pausenzeit_faktor
If Pausenzeit > Pausenzeit_max Then
Pausenzeit = Pausenzeit_max
End If
' nun steht in Pausenzeit die Pausenzeit 1/10 Sekunden
End If
End If ' if Toleranzgrenze_oben < Isttemp
If Isttemp > Dynamikgrenze_oben Then ' Ist > als Dynamikgrenze oben, also SEHR hoch
Reset Ledrot ' warnen
Pausenzeit = 0
End If
Pausenzeit_int = Round(pausenzeit) ' Pausenzeit (SINGLE) in INTEGER wandeln
If Pausenzeit_int > 0 Then ' Pausenzeit vergehen lassen
For I = 0 To Pausenzeit_int
Waitms 100 ' Zeit verplempern in Einheiten von 1/10 Sekunde
Call Tasten
Next I
End If
End Sub
Sub Anzeigen
Disp_templm35 = Fusing(templm35 , "##.#")
Disp_strom = Fusing(strom , "###.#")
Disp_solltemp = Fusing(solltemp , "###.#")
Locate 1 , 1 ' LCD 2x16
Lcd "I:" ; Disp_templm35 ;
Lcd Chr(1) ; "C";
Locate 1 , 10
Lcd " S:" ; Disp_solltemp ; " "
Locate 2 , 1
Lcd Disp_strom ; "mA "
Locate 2 , 9
Lcd "Pwm:" ; Pwmwert ; " "
End Sub
Sub Tasten
Tasteup = Taste_up
Tastedn = Taste_dn
If Tasteup = 0 Then
Incr Solltemp
E_solltemp = Solltemp
Reset Ledrot
Waitms 300
Set Ledrot
End If
If Tastedn = 0 Then
Decr Solltemp
E_solltemp = Solltemp
Reset Ledrot
Waitms 300
Set Ledrot
End If
If Solltemp < 1 Then
Solltemp = 1
End If
If Solltemp > 99 Then
Solltemp = 99
End If
Toleranzgrenze_oben = Solltemp + 1
Toleranzgrenze_unten = Solltemp - 1
Dynamikgrenze_oben = Toleranzgrenze_oben + 4
Dynamikgrenze_unten = Toleranzgrenze_unten - 4
End Sub

BIN
schaltbild.pdf Normal file

Binary file not shown.

5884
schaltbild.ps Normal file

File diff suppressed because it is too large Load Diff