سلام ما برنامه زیر رو نوشتیم ولی تو پروتیوس جواب نمیده (همیشه عدد صفر نمایش داده میشه!) :NO:
این برنامه دماسنج هست که ما به جای LM35 در شبیه سازی از یک POT-HG استفاده کردیم و اون رو به پایه A.0وصل کردیم :cry2:
این برنامه دماسنج هست که ما به جای LM35 در شبیه سازی از یک POT-HG استفاده کردیم و اون رو به پایه A.0وصل کردیم :cry2:
$regfile = "m32def.dat" 'We use internal osc 4000000 for atmega32
$crystal = 4000000
Config Lcdpin = Pin , Db4 = Portc.1 , Db5 = Portc.2 , Db6 = Portc.3 , Db7 = _
Portc.4 , E = Portd.2 , Rs = Portd.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto
Start Adc
Config Timer0 = Timer , Prescale = 1024
Enable Interrupts
Enable Timer0
On Timer0 Sample
Start Timer0
Dim Va As Word
Dim Dt As Word
Dim Temp As Word
Dim A As Word
Dim Sample As Word
Dim Sum As Word
Do
Loop
End
Sample:
Incr Sample
Dt = Getadc(0)
A = 5 * Dt
Va = A / 1024
Temp = Va * 100 'temp is equal to real temperature
Sum = Sum + Temp
If Sample = 15 Then
Cls
Sample = 0
Stop Timer0
Temp = Sum / 15
Lcd Temp
Start Timer0
Sum = 0
End If
Return
$crystal = 4000000
Config Lcdpin = Pin , Db4 = Portc.1 , Db5 = Portc.2 , Db6 = Portc.3 , Db7 = _
Portc.4 , E = Portd.2 , Rs = Portd.3
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto
Start Adc
Config Timer0 = Timer , Prescale = 1024
Enable Interrupts
Enable Timer0
On Timer0 Sample
Start Timer0
Dim Va As Word
Dim Dt As Word
Dim Temp As Word
Dim A As Word
Dim Sample As Word
Dim Sum As Word
Do
Loop
End
Sample:
Incr Sample
Dt = Getadc(0)
A = 5 * Dt
Va = A / 1024
Temp = Va * 100 'temp is equal to real temperature
Sum = Sum + Temp
If Sample = 15 Then
Cls
Sample = 0
Stop Timer0
Temp = Sum / 15
Lcd Temp
Start Timer0
Sum = 0
End If
Return
دیدگاه