Hallo zusammen,
haben zu diesem Thema noch kein passenden Thread im Forum gefunden. Oder
leider nicht richtig gefunden.
Ich möchte mit Hilfe des Temperatursensors TC74 und dem Atmega 1284P die
Temperatur aufnehmen.
Dabei möchte ich mir die tiefste gemessene und die höchst gemessene
Temperatur anzeigen lassen.
Hat jemand eine Möglichkeit dieses zu realisieren?
Vielen Dank schonmal im Vorraus!
im folgenden der momentane Quellcode zu diesem Projekt:
1 | #include <avr/io.h>
|
2 | #define F_CPU 8000000
|
3 | #include <util/delay.h>
|
4 | #include "lcd-routines.h"
|
5 | #include "i2cmaster.h"
|
6 |
|
7 | uint8_t byte_TC74;
|
8 | char cBuffer_TC74[8];
|
9 | float fMesswert_TC74;
|
10 |
|
11 | uint8_t byte_1_DS1621;
|
12 | uint8_t byte_2_DS1621;
|
13 | char cBuffer_DS1621[10];
|
14 | float fMesswert_DS1621;
|
15 |
|
16 |
|
17 | int main(void)
|
18 | {
|
19 |
|
20 | while (1)
|
21 | {
|
22 |
|
23 |
|
24 | /***Einlesen des Temparaturbausteins TC74 ***/
|
25 |
|
26 | lcd_clear();
|
27 | lcd_init();
|
28 | i2c_init();
|
29 | i2c_start(0x9A);
|
30 | i2c_write(0x00);
|
31 | i2c_rep_start(0x9B);
|
32 | byte_TC74=i2c_readNak();
|
33 | i2c_stop();
|
34 |
|
35 | itoa(byte_TC74,cBuffer_TC74,2);
|
36 | fMesswert_TC74=byte_TC74;
|
37 | dtostrf(fMesswert_TC74,4,0,cBuffer_TC74);
|
38 | lcd_setcursor(0,1);
|
39 | lcd_string(cBuffer_TC74);
|
40 | lcd_string(" ßC TC74");
|
41 |
|
42 | /****Einlesen des Temparaturbausteins DS1621 ***/
|
43 |
|
44 | i2c_init();
|
45 | i2c_start(0b10010000);
|
46 | i2c_write(0xEE);
|
47 | i2c_rep_start(0x90);
|
48 | i2c_write(0xAA);
|
49 | i2c_rep_start(0x91);
|
50 | byte_1_DS1621=i2c_readAck();
|
51 | byte_2_DS1621=i2c_readNak();
|
52 | i2c_stop();
|
53 | itoa(byte_1_DS1621,cBuffer_DS1621,2);
|
54 | itoa(byte_2_DS1621,cBuffer_DS1621,2);
|
55 | fMesswert_DS1621 = byte_1_DS1621;
|
56 | if(byte_2_DS1621==0x90) fMesswert_DS1621+=0.5;
|
57 | dtostrf(fMesswert_DS1621,4,1,cBuffer_DS1621);
|
58 | lcd_setcursor(0,2);
|
59 | lcd_string(" ");
|
60 | lcd_string(cBuffer_DS1621);
|
61 | lcd_string(" ßC DS1621");
|
62 |
|
63 | _delay_ms(700);
|
64 |
|
65 |
|
66 | }
|
67 | }
|