Hi,
ich habe nun endlich meine Minicontrol zumlaufen gebracht. Nun will ich über den I2C und dem daran angeschloßenen Temp. sensor DS1621 die Temp. auslesen.
Ich habe den DS1621 so an den I2C angeschloßen :
DS1621 I2C
SDA - SDA
SCL - SCl
Gnd - GND
Tout -
Vdd - 5V
A0 - GND
A1 - GND
A2 - GND
Ist das so richtig?
Hier ist der Code den ich von hier geladen habe, was muss ich ändern das er mir einfach via Com port die Temp zeigt? Würde mich echt freuen wenn ihr mir helfen könntet![]()
Code:'------------------------------------die anweisungen für prozessor,use.------------------------------------------------- $regfile = "m168def.dat" $crystal = 16000000 'Quarzfrequenz $baud = 9600 $hwstack = 32 $framesize = 32 $swstack = 32 Config Scl = Portc.5 Config Sda = Portc.4 Config Pind.6 = Output Portd.6 = 0 Dim ___lcdno As Bit Config Lcdpin = Pin , E = Portc.3 , E2 = Portd.7 , Rs = Portc.2 , Db4 = Portd.2 , Db5 = Portd.3 , Db6 = Portd.4 , Db7 = Portd.5 Config Lcd = 20 * 4 Dim Convert_strg As String * 10 Declare Sub Showvalue_komma1(byval Format As String)as Byte Dim Device As Byte Dim Deviceread As Byte Dim Lowtemp As Byte Dim Hightemp As Byte Dim Value As Word '!!!!!!! I2cinit Device = 144 'Wenn alle Adressleitungen des 1621 auf GND sind. Deviceread = 145 '----------------------------------------------Hauptprogramm------------------------------------------------------------ Do I2cstart I2cwbyte Device I2cwbyte &HEE 'Temperaturmessung anstoßen I2cstop I2cstart I2cwbyte Device I2cwbyte &HAA 'Temperaturmessung Lesekommando I2cstop I2cstart I2cwbyte Deviceread I2crbyte Lowtemp , Ack 'LSB holen I2crbyte Hightemp , Nack 'MSB holen I2cstop Value = Lowtemp * 10 If Hightemp = 128 Then Value = Value + 5 End If Print Cursor Off Cls Cursor 1 , 1 Lcd Showvalue_komma1() Waitms 500 'kurze Pause Loop End '------------------------------------------------------------ Sub Showvalue_komma1() Convert_strg = Str(value) Convert_strg = Format(convert_strg , " 0.00") Lcd Convert_strg End Sub







Zitieren

Lesezeichen