 |
www.elektronik.si Forum o elektrotehniki in računalništvu
|
Poglej prejšnjo temo :: Poglej naslednjo temo |
Avtor |
Sporočilo |
laco Član

Pridružen-a: Pon 06 Jun 2011 19:32 Prispevkov: 13 Aktiv.: 0.08 Kraj: Hrvatska
|
Objavljeno: Tor Nov 29, 2011 8:12 pm Naslov sporočila: Atmega16 PT1000 Bascom Avr |
|
|
Trebam pomoć. Radim projekt termometar -40C - 250C sa PT1000 i imam problem, ADC Vout mi je dosta nestabilan, iako koristim za Vref IC REF02. Dobivam temeperature npr. 21.5 , 22.5, 18.9, 22.5, 21.5 C itd.
Prilažem Bascom Avr kod i shematski prikaz PT1000 pojačala LTC271CP. Neznam da li je problem u 10-bit ADC-u ili nešto treba promijeniti u shemi ili možda treba dodati 16-bit ADC. Razmišljam o MCP3425/6, ali na Bascom Forumima nisam našao primjer.
Code:
$regfile = "m16def.dat" ' SLAVE-01 (B01) Temperatures Controler
$crystal = 8000000
$hwstack = 64
$swstack = 32
$framesize = 100
$lib "glcdKS108.lbx"
$baud = 2400
$include "Font6x8.font"
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 2 , Rd = 3 , Reset = 5 , Enable = 4 , Mode = 6
' Config ADC
Config Adc = Single , Prescaler = Auto
' Constants for PT100 and Referece Voltage
Const Vin = 5.0 ' Vref = Vin = 5.0V
Const Vref_1024 = 0.0048828125 ' Vref/1024 = 5/1024
' Temperatures variables
Dim W As Word , W1 As Word , W_temp As Single
Dim Temp_lm35 As Integer , Temp_pt1000 As Single
Dim Int_pt1000 As Integer
Dim S1 As String * 6
Dim Dif_v As Single , V1 As Single , Vout As Single , Rt As Single
Dim Pt1000_temp As Single , Rt_resistance As Integer
Cls
Setfont Font6x8
Wait 1
Start Adc
Do
Dim Ii As Integer , Volt_adc_7 As Single
Waitms 150
W = Getadc(2)
W1 = Getadc(3)
W_temp = W1 - W
W_temp = W_temp * Vref_1024
W_temp = W_temp * 100 ' Read LM35-1 OutHome
Temp_lm35 = Int(w_temp)
S1 = " "
S1 = Str(w_temp)
S1 = Fusing(w_temp , "#.###")
Lcdat 1 , 1 , "T_lm35: " ; S1
W = Getadc(7)
W_temp = W
'***************************************
Volt_adc_7 = W * Vref_1024
S1 = ""
S1 = Str(volt_adc_7)
S1 = Fusing(volt_adc_7 , "#.####")
Lcdat 2 , 1 , "Vout: " ; S1 ; " W: " ; W
'***************************************
If W > 0 Then
Const Pt_a = 0.0039083 ' PT-1000 constants A
Const Neg_a = -1.0 * Pt_a ' PT-1000 constants -A
Const Pt_b = -0.0000005775 ' PT-1000 constants B
Const 4b = 4 * Pt_b
Const 2b = 2 * Pt_b
Const A2 = Pt_a ^ 2
V1 = 0
Rt = 0
Vout = W_temp * Vref_1024 ' PT1000 Vout = Vref / 1024 * Getadc(0)
V1 = Vout / 12
V1 = V1 * 1.014 ' V1=Vout/(R4/R3+1) = Vout/12
Dif_v = Vin / V1 ' PT100 Rt=R1/(Vin/V1-1)
Dif_v = Dif_v - 1
Rt = 22000 / Dif_v
Rt = Rt + 2
S1 = " "
S1 = Str(v1)
S1 = Fusing(v1 , "#.####")
Lcdat 3 , 1 , "V1 : " ; S1
' Temp_pt1000=(-A+SQR(A^2-4B(1-Rt/R0))))/2B
'*****************************************
Temp_pt1000 = Rt / 1000.0 ' RT/1000
Temp_pt1000 = 1 - Temp_pt1000 ' 1 - RT/1000
Temp_pt1000 = Temp_pt1000 * 4b ' 4*(1-RT/1000)
Temp_pt1000 = A2 - Temp_pt1000 ' A2-(1-RT/1000)
Temp_pt1000 = Sqr(temp_pt1000) ' SQRT(A2-(1-RT/1000))
Temp_pt1000 = Neg_a + Temp_pt1000 ' -A+SQRT(A2-(1-RT/1000))
Temp_pt1000 = Temp_pt1000 / 2b ' -A+SQRT(A2-(1-RT/1000))/2B
'*****************************************
S1 = " "
S1 = Str(rt)
S1 = Fusing(rt , "#.###")
Lcdat 4 , 1 , "RT_pt1000: " ; S1
'*************************************
Else
Temp_pt1000 = 0 ' Temperatures Solar Collector-1
End If
S1 = ""
S1 = Str(temp_pt1000)
S1 = Fusing(temp_pt1000 , "#.###")
Lcdat 5 , 1 , "T_pt1000 : " ; S1
Wait 5
Loop
End 'end program
Opis: |
|
 Download |
Ime datoteke: |
PT1000 -40 - 250 TCL271CP.pdf |
Velikost datoteke: |
237.56 KB |
Downloadano: |
129 krat |
_________________ Lijep pozdrav,
Ivica Lacmanovic |
|
Nazaj na vrh |
|
 |
|
|
Ne, ne moreš dodajati novih tem v tem forumu Ne, ne moreš odgovarjati na teme v tem forumu Ne, ne moreš urejati svojih prispevkov v tem forumu Ne, ne moreš brisati svojih prispevkov v tem forumu Ne ne moreš glasovati v anketi v tem forumu Ne, ne moreš pripeti datotek v tem forumu Ne, ne moreš povleči datotek v tem forumu
|
Uptime: 496 dni
Powered by phpBB © 2001, 2005 phpBB Group
|