DS18B20 i C# .NET

Mar 20, 2007 0 Replies

Bibliotekê maximu ju¿ przerobi³em.



Ale pytanie trochê inne. Pod³±czenie COM1, schemat tradycyjny z 4 diodami i nó¿ka 1'wsza zmostkowana z 3'ci±.



Jak ma wygl±daæ prawid³owy reset? w formatce mam dodany serialPort1 (9600, 8 databits, parity: none, stopbits



1)

Dalej mam tak: serialPort1.Open();



// reset??? serialPort1.Write(new byte[] { 0x10 }, 0, 1);



// Tylko 1 termometr wiêc pomijam wybieranie po adresie. serialPort1.Write(new byte[] { 0xCC }, 0, 1); serialPort1.Write(new byte[] { 0x44 }, 0, 1);



// Czas na przeliczenie temp. serialPort1.BreakState = true; Thread.Sleep(500); serialPort1.BreakState = false;



serialPort1.Write(new byte[] { 0x10 }, 0, 1); serialPort1.Write(new byte[] { 0xCC }, 0, 1); serialPort1.Write(new byte[] { 0xBE }, 0, 1); // Powinien zwróciæ 9 bajtów (9'ty CRC)



// Dane powinien zwróciæ przez event'a private void serialPort1_DataReceived (object sender, System.IO.Ports.SerialDataReceivedEventArgs e) string read = serialPort1.ReadExisting();



Przy wysy³aniu/odbieraniu trzeba co¶ dodatkowo ustawiaæ (dot. serialPort1)?



Pozdrawiam



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required