Temperaturüberwachung der Motoren und Stepper
Mega 2560 + TFT Shield + 1-Wire Bus mit DS18B20
in Arbeit. Code noch total unbereinigt.
Geplant:
- Touch Kontrolle
- Daten Logging (Min / Max / Temp Kurve)
- Alarm bei Überschreitung eines Wertes
- Uhrzeit / Datum
- Spannungsüberwachung
- Stromverbrauch
- Daten über ein Ethernet Shield übertragen. Soon(TM)
Edit: 18.02.2014 – Skript Update – Min / Max Werte
Edit: 21.02.2015 – neue Code, neue Grafik
Edit: 29.01.2016 – Github Link – https://github.com/buyenne/cnc_ardu_temp_mon
Zwecks besserer Übersicht habe ich ein paar weitere Änderungen vorgenommen. Spannungsüberwachung kommt auch noch. Jedoch muß ich mir da etwas anderes einfallen lassen. Der Touchscreen läßt sich partout nicht kalibrieren. Somit ist dieser nicht zu benutzen.
Hier muß noch der Font Incosola.c hinzugefügt werden (ins Sketch Verzeichnis kopieren – Arduino restart.)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
#include <UTFT.h> #include <OneWire.h> #include <DallasTemperature.h> //#include <Inconsola.c> // Data wire is plugged into port 2 on the Arduino #define ONE_WIRE_BUS 8 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); // Declare which fonts we will be using extern uint8_t SmallFont[]; extern uint8_t Inconsola[]; UTFT myGLCD(ITDB32S,38,39,40,41); // Testeintrag. Weitere Möglichkeit die Sensoren anzusprechen. Müssen vorher mit einem andere Skript ausgelesen werden. DeviceAddress Sensor1 = {0x28, 0x2C, 0x3D, 0x74, 0x06, 0x00, 0x00, 0xCA}; // min / max Werte Setzten float tempA_min = 100; float tempA_max = 0; float tempB_min = 100; float tempB_max = 0; float tempC_min = 100; float tempC_max = 0; float tempD_min = 100; float tempD_max = 0; float tempE_min = 100; float tempE_max = 0; float tempF_min = 100; float tempF_max = 0; void setup(void) { // Setup the LCD myGLCD.InitLCD(); myGLCD.setFont(SmallFont); //myGLCD.setFont(BigFont); myGLCD.clrScr(); // start serial port Serial.begin(9600); // Start up the library sensors.begin(); } void loop(void) { // request to all devices on the bus Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); Serial.print("Temperature for the device 1 (index 0) is: "); Serial.println(sensors.getTempCByIndex(0)); Serial.println(sensors.getTempCByIndex(1)); Serial.println(sensors.getTempCByIndex(2)); Serial.println(sensors.getTempCByIndex(3)); Serial.println(sensors.getTempCByIndex(4)); Serial.println(sensors.getTempCByIndex(5)); // alternative zum Temp holen Serial.println(sensors.getTempC(Sensor1)); float tempA = sensors.getTempCByIndex(0); float tempB = sensors.getTempCByIndex(1); float tempC = sensors.getTempCByIndex(2); float tempD = sensors.getTempCByIndex(3); float tempE = sensors.getTempCByIndex(4); float tempF = sensors.getTempCByIndex(5); // alternative float tempC1 = sensors.getTempC(Sensor1); { if (tempA_min > tempA ) {tempA_min = tempA; } else { Serial.println("keine Änderung"); } } { if (tempA_max < tempA ) {tempA_max = tempA; } else { Serial.println("keine Änderung"); } } { if (tempB_min > tempB ) {tempB_min = tempB; } else { Serial.println("keine Änderung"); } } { if (tempB_max < tempB ) {tempB_max = tempB; } else { Serial.println("keine Änderung"); } } { if (tempC_min > tempC ) {tempC_min = tempC; } else { Serial.println("keine Änderung"); } } { if (tempC_max < tempC ) {tempC_max = tempC; } else { Serial.println("keine Änderung"); } } // min / max Sensor D { if (tempD_min > tempD ) {tempD_min = tempD; } else { Serial.println("keine Änderung"); } } { if (tempD_max < tempD ) {tempD_max = tempD; } else { Serial.println("keine Änderung"); } } // min / max Sensor E { if (tempE_min > tempE ) {tempE_min = tempE; } else { Serial.println("keine Änderung"); } } { if (tempE_max < tempE ) {tempE_max = tempE; } else { Serial.println("keine Änderung"); } } // min / max Sensor F { if (tempF_min > tempF ) {tempF_min = tempF; } else { Serial.println("keine Änderung"); } } { if (tempF_max < tempF ) {tempF_max = tempF; } else { Serial.println("keine Änderung"); } } //Kopf und Fußzeile myGLCD.setColor(255, 0, 0); myGLCD.fillRect(0, 0, 319, 13); myGLCD.setColor(255, 255, 255); myGLCD.fillRect(0, 226, 319, 239); myGLCD.setColor(255, 255, 255); myGLCD.setBackColor(255, 0, 0); myGLCD.print("* Temp Monitor AL-Line TEST *", CENTER, 1); myGLCD.setBackColor(255, 2552, 255); myGLCD.setColor(0,0,0); myGLCD.print("<http://blog.buyenne.com>", CENTER, 227); //Temperaturen myGLCD.setBackColor(0, 0, 0); myGLCD.drawRect(0, 14, 319, 225); myGLCD.setColor(255,255,255); myGLCD.print("Temp Motor - Temp Stepper", CENTER, 20); myGLCD.print("X-Achse", LEFT, 30); myGLCD.print("Y-Achse", LEFT, 70); myGLCD.print("Z-Achse", LEFT, 110); myGLCD.print("4-Achse", LEFT, 150); // Test Groß klein Temp myGLCD.setColor(0,0,255); myGLCD.printNumF(tempA_min ,2,15,43); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempA_max ,2,15,55); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempA ,1, 55, 43); myGLCD.setFont(SmallFont); myGLCD.setColor(0,0,255); myGLCD.printNumF(tempB_min ,2,15,83); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempB_max ,2,15,95); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempB ,1, 55, 83); myGLCD.setFont(SmallFont); myGLCD.setColor(0,0,255); myGLCD.printNumF(tempC_min ,2,15,123); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempC_max ,2,15,135); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempC ,1, 55, 123); myGLCD.setFont(SmallFont); myGLCD.setColor(0,0,255); myGLCD.printNumF(tempD_min ,2,175,43); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempD_max ,2,175,55); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempD ,1, 215, 43); myGLCD.setFont(SmallFont); myGLCD.setColor(0,0,255); myGLCD.printNumF(tempE_min ,2,175,83); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempE_max ,2,175,95); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempE ,1, 215, 83); myGLCD.setFont(SmallFont); myGLCD.setColor(0,0,255); myGLCD.printNumF(tempF_min ,2,175,123); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempF_max ,2,175,135); myGLCD.setColor(255,255,255); myGLCD.setFont(Inconsola); myGLCD.printNumF(tempF ,1, 215, 123); myGLCD.setFont(SmallFont); // Trafos myGLCD.setColor(255,255,255); myGLCD.print("Spannung Trafos 5V 12V 24V 48V", CENTER, 190); delay(2000); } |
Der alte Code mit Screenshot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
#include <UTFT.h> #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 2 on the Arduino #define ONE_WIRE_BUS 8 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); // Declare which fonts we will be using extern uint8_t SmallFont[]; UTFT myGLCD(ITDB32S,38,39,40,41); DeviceAddress Sensor1 = {0x28, 0x2C, 0x3D, 0x74, 0x06, 0x00, 0x00, 0xCA}; float tempA_min = 100; float tempA_max = 0; void setup(void) { // randomSeed(analogRead(0)); // Setup the LCD myGLCD.InitLCD(); myGLCD.setFont(SmallFont); myGLCD.clrScr(); // start serial port Serial.begin(9600); // Serial.println("Dallas Temperature IC Control Library Demo"); // Start up the library sensors.begin(); } //void min() void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus // myGLCD.clrScr(); Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); Serial.print("Temperature for the device 1 (index 0) is: "); Serial.println(sensors.getTempCByIndex(0)); Serial.println(sensors.getTempCByIndex(1)); Serial.println(sensors.getTempCByIndex(2)); Serial.println(sensors.getTempCByIndex(3)); Serial.println(sensors.getTempC(Sensor1)); float tempA = sensors.getTempCByIndex(0); float tempB = sensors.getTempCByIndex(1); float tempC = sensors.getTempCByIndex(2); float tempD = sensors.getTempCByIndex(3); float tempC1 = sensors.getTempC(Sensor1); { if (tempA_min > tempA ) {tempA_min = tempA; } else { Serial.println("keine Änderung"); } } { if (tempA_max < tempA ) {tempA_max = tempA; } else { Serial.println("keine Änderung"); } } myGLCD.setColor(255, 0, 0); myGLCD.fillRect(0, 0, 319, 13); myGLCD.setColor(255, 255, 255); myGLCD.fillRect(0, 226, 319, 239); myGLCD.setColor(255, 255, 255); myGLCD.setBackColor(255, 0, 0); myGLCD.print("* Temp Monitor AL-Line TEST *", CENTER, 1); myGLCD.setBackColor(255, 2552, 255); myGLCD.setColor(0,0,0); myGLCD.print("<http://blog.buyenne.com>", CENTER, 227); myGLCD.setBackColor(0, 0, 0); myGLCD.drawRect(0, 14, 319, 225); //myGLCD.fillRect(0, 14, 319, 225); //myGLCD.setBackColor(255, 255, 255); myGLCD.setColor(255,255,255); myGLCD.print("Temp Motor X-Achse", LEFT, 20); myGLCD.printNumF(tempA ,2, 50, 35); myGLCD.print(" Celsius", 90, 35); myGLCD.print("Temp Motor Y-Achse", LEFT, 50); myGLCD.printNumF(tempB ,2, 50, 65); myGLCD.print(" Celsius", 90, 65); myGLCD.print("Temp Motor Z-Achse", LEFT, 80); //myGLCD.printNumI(sensors.getTempCByIndex(0), 60, 90); myGLCD.printNumF(tempC ,2,50,95); myGLCD.print(" Celsius", 90, 95); myGLCD.print("Temp Stepper X-Achse", RIGHT, 20); myGLCD.printNumF(tempD ,2,180,35); myGLCD.print(" Celsius", 220, 35); myGLCD.print("Temp Stepper Y-Achse", RIGHT, 50); myGLCD.print("Temp Stepper Z-Achse", RIGHT, 80); //min / Max myGLCD.setColor(0,0,255); myGLCD.printNumF(tempA_min ,2,20,120); myGLCD.setColor(255,0,0); myGLCD.printNumF(tempA_max ,2,80,120); myGLCD.setColor(255,255,255); myGLCD.print("Temp Trafo 5V", LEFT, 140); myGLCD.print("Temp Trafo 12V", RIGHT, 140); myGLCD.print("Temp Trafo 24V", LEFT, 170); myGLCD.print("Temp Trafo 48V", RIGHT, 170); delay(2000); } |