Browse code

Create Arduino-Pt1000.ino

Stefan Höhn authored on21/03/2014 12:44:29
Showing1 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1,64 @@
1
+//----------------------------------------------------------------------------
2
+// RTD Module Example Sketch
3
+// Last revision 30 November 2009
4
+// Licence: GNU GPL
5
+// By Trystan Lea
6
+//
7
+// reduziert auf eine Messstelle von Stefan Höhn
8
+//----------------------------------------------------------------------------
9
+
10
+//----------------------------------------------------------------------------
11
+// Load RTD library and create new instance
12
+//----------------------------------------------------------------------------
13
+#include "RTDModule.h"
14
+RTDModule rtd;
15
+
16
+//----------------------------------------------------------------------------
17
+// Temperature variables
18
+//----------------------------------------------------------------------------
19
+double CYLB,CYLT,COL;
20
+
21
+//----------------------------------------------------------------------------
22
+// Setup
23
+//----------------------------------------------------------------------------
24
+void setup()
25
+{
26
+  rtd.setPins(4,5,2);                                //RTD PT1000 pins 4,5 are digital pins for multiplexer, 2 is analog input
27
+  
28
+  //rtd.calibration( input number, scaler, offset )
29
+  rtd.calibration(0, 0.120270927, -15.066198679);   //INPUT 0 pin 12
30
+  rtd.calibration(1, 0.120821076, -13.824162893);   //INPUT 1 pin 14
31
+  rtd.calibration(2, 0.120400012, -14.91327759);    //INPUT 2 pin 15
32
+      
33
+  analogReference(INTERNAL);                        //Set reference to 1.1V ready for RTD measurements
34
+
35
+  Serial.begin(9600);
36
+}
37
+
38
+//----------------------------------------------------------------------------
39
+// Main loop Es wird  nur 1 Temp angezeigt
40
+//----------------------------------------------------------------------------
41
+void loop()
42
+{
43
+  //Get temperatures and pass through digital low pass filter
44
+  COL = digitalLowPass(COL, rtd.getTemperature(0) ,0.90);
45
+ CYLB = digitalLowPass(CYLB, rtd.getTemperature(1) ,0.90);
46
+ CYLT = digitalLowPass(CYLT, rtd.getTemperature(2) ,0.90);
47
+  
48
+  //Print temperatures out to serial
49
+  //Serial.print(COL);
50
+  Serial.println(COL);
51
+  //Serial.print(' ');
52
+  //Serial.print(CYLB);
53
+  //Serial.print(' ');
54
+  //Serial.println(CYLT);
55
+  
56
+}
57
+//----------------------------------------------------------------------------
58
+
59
+//Digital low pass filter
60
+double digitalLowPass(double last_smoothed, double new_value, double filterVal)
61
+{
62
+  double smoothed = (new_value * (1 - filterVal)) + (last_smoothed * filterVal);
63
+  return smoothed;
64
+}