Browse Source

premiere mesure de temperature avec le LM35

tth 1 year ago
parent
commit
7332f87654
6 changed files with 90 additions and 8 deletions
  1. 2
    2
      serial/essai.sh
  2. 1
    1
      serial/t.c
  3. 47
    0
      simulator/rdtemp/rdtemp.ino
  4. 35
    0
      viz/curses/7segments.c
  5. 1
    1
      viz/curses/ecran.c
  6. 4
    4
      viz/curses/t.c

+ 2
- 2
serial/essai.sh View File

@@ -5,9 +5,9 @@ DATAFILE="foo.dat"
5 5
 TMPFILE="/tmp/dd2data"
6 6
 
7 7
 IMAGE="graphe.png"
8
-NB_READ=12000
8
+NB_READ=50
9 9
 
10
-./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
10
+./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
11 11
 
12 12
 gnuplot << __EOC__
13 13
 set term png 	size 1600,512

+ 1
- 1
serial/t.c View File

@@ -33,7 +33,7 @@ for (count=0; count<iters; count++) {
33 33
 		fprintf(stderr, "getline #%d -> %d\n", count, foo);
34 34
 		fprintf(stderr, "%s\n", ligne);
35 35
 		}
36
-	foo = parse4values(ligne, 'X', datas);
36
+	foo = parse4values(ligne, 'T', datas);
37 37
 	// 
38 38
 	if (foo >= 0) {
39 39
 		temps = time(NULL);

+ 47
- 0
simulator/rdtemp/rdtemp.ino View File

@@ -0,0 +1,47 @@
1
+/*
2
+ * lecture des capteurs de temperature LM35
3
+ */
4
+/* -------------------------------------------------- */
5
+
6
+#define NBVAL   4
7
+#define DELAI   5000
8
+
9
+int   values[NBVAL];
10
+
11
+/* -------------------------------------------------- */
12
+void setup() {
13
+  Serial.begin(9600);
14
+  pinMode(LED_BUILTIN, OUTPUT);
15
+  delay(2000);
16
+}
17
+/* -------------------------------------------------- */
18
+void updatevalues(void)
19
+{
20
+  int foo;
21
+  for (foo=0; foo<NBVAL; foo++) {
22
+    values[foo] = analogRead(A0);
23
+    delay(50);
24
+   }
25
+}
26
+/* -------------------------------------------------- */
27
+void sendvalues(void)
28
+{
29
+  int foo;
30
+
31
+  Serial.print("T");
32
+  for (foo=0; foo<NBVAL; foo++) {
33
+    Serial.print(" ");
34
+    Serial.print(values[foo]);
35
+    }
36
+  Serial.print("\n");
37
+}
38
+/* -------------------------------------------------- */
39
+
40
+void loop() {
41
+  updatevalues();
42
+  sendvalues();
43
+  delay(DELAI);
44
+}
45
+
46
+/* -------------------------------------------------- */
47
+

+ 35
- 0
viz/curses/7segments.c View File

@@ -15,6 +15,41 @@
15 15
 int	verbosity;
16 16
 
17 17
 /* ---------------------------------------------------------------- */
18
+int afficheur_7segs(WINDOW * win, int lig, int col, int bits, int k)
19
+{
20
+int	numbit, mask;
18 21
 
22
+for (numbit=0; numbit<8; numbit++) {
23
+	mask = 1 << numbit;
24
+
25
+	switch(mask) {
26
+
27
+		case 0x01:
28
+
29
+		case 0x02:
30
+
31
+		case 0x04:
32
+
33
+		case 0x08:
34
+
35
+		case 0x10:
36
+
37
+		case 0x20:
38
+
39
+		case 0x40:
40
+
41
+		case 0x80:
42
+			/* decimal point */
43
+			break;
44
+
45
+		default:
46
+			fprintf(stderr, "%s mask is wrong\n", __func__);
47
+			break;
48
+		}
49
+
50
+	}
51
+
52
+return -1;
53
+}
19 54
 /* ---------------------------------------------------------------- */
20 55
 

+ 1
- 1
viz/curses/ecran.c View File

@@ -33,7 +33,7 @@ char    buffer[200];
33 33
 tp = " DD2 MONITORING by tTh 2019 ";
34 34
 if (NULL != title)	tp = title;
35 35
 
36
-barre_inverse('+', 0);
36
+barre_inverse(' ', 0);
37 37
 standout();
38 38
 mvaddstr(0, 2, tp);
39 39
 #if TRACE

+ 4
- 4
viz/curses/t.c View File

@@ -22,16 +22,16 @@ water = open_waterfall("premier essai", 0);
22 22
 
23 23
 for (loop=0; loop<nbl; loop++) {
24 24
 
25
-	sprintf(line, "%04X  %04X", loop, rand()&0xffff);
25
+	sprintf(line, "%06X  %04X", loop, rand()&0xffff);
26 26
 	mvwaddstr(stdscr, LINES-1, 1, line);
27 27
 	wrefresh(stdscr);
28 28
 
29 29
 	for (foo=0; foo<4; foo++) {
30 30
 		if (rand()%100<42) {
31
-			rvals[foo] += 3.8*(foo + 1);
31
+			rvals[foo] += 3.9 * (foo + 1);
32 32
 			}
33 33
 		if (rvals[foo] > 1023.0) {
34
-			rvals[foo] = (float)(rand() % 15);
34
+			rvals[foo] = (float)(rand() % 25);
35 35
 		}
36 36
 	}
37 37
 
@@ -77,7 +77,7 @@ keypad(stdscr, TRUE);           /* acces aux touches 'curseur' */
77 77
 
78 78
 fond_ecran(" Demonstrator ");
79 79
 
80
-demo(90000, 0);
80
+demo(190000, 0);
81 81
 
82 82
 /*
83 83
  *      plop, on a fini, restaurer la console

Loading…
Cancel
Save