-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path181009_Induktion.ino
More file actions
73 lines (59 loc) · 3.03 KB
/
181009_Induktion.ino
File metadata and controls
73 lines (59 loc) · 3.03 KB
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
/*
* Sketch zur Kommunikation zwischen einem CBPi und einem GGM Induktionskochfeld.
* v.0.2 vom 09.10.2018
* M.Sc.
*
* Benutzung auf eigene gefahr.
*
*/
/*############## INCLUDES ###################*/
#include <Wire.h> // i2C
#include <LiquidCrystal_I2C.h> // i2C Display
#include "config.h" // Config-Datei
/*############## KONSTANTEN ##################*/
LiquidCrystal_I2C lcd(0x27,20,4); // Instanz Display
/*############## Variablen ##################*/
/*----- Induktionskochfeld -----*/
byte CMD_CUR = 0; // Aktueller Befehl
boolean isRelayon = false; // Systemstatus: ist das Relais in der Platte an?
boolean isInduon = false; // Systemstatus: ist Power > 0?
boolean isError = false;
boolean isInduError[] = { false, // E0: Kein Topf
false, // E1: Stromkreisfehler
false, // E2: ??
false, // E3: Überhitzung
false, // E4: Temperatursensor Feheler
false, // E5: ??
false, // E6: ??
false, // E7: Niederspannung
false, // E8: Überspannung
false }; // EC: Kommunikationsfehler
boolean isunknownError = false; // Unbekannter Fehler
boolean isSerialError = false; // Fehler in Serieller Kommunikation
boolean skipSerialError = false; // Serial Error Überschreiben.
boolean isCommError = false; // Fehler in Kommunikation mit Induktionskochfeld
int newError;
byte inputBuffer[33]; // Buffer für Rückantwort der Platte
byte inputCurrent = 0; // Hilfvariable für Rückantwort (Zählvariable)
bool inputStarted = false; // Starbit
unsigned long lastInterrupt; // Zeitmessung
unsigned long timeLastReaction; // Timeout Induktionskochfeld
unsigned long timeTurnedoff; // Für Messung Verzögerung Abschaltung Relais
int power = 0; // Prozent Power Aktuell
int newPower = 0; // Prozent Power Neu
int storePower = 0; // letzten Power Wert Speichern (Für ErrorHandling)
long powerSampletime = 20000; // Dauer eines Schaltzyklus
long powerHigh = powerSampletime; // Dauer des "HIGH"-Anteils im Schaltzyklus
long powerLow = 0; // Dauer des "LOW"-Anteils im Schaltzyklus
bool isPower = false; // High oder Low Senden
unsigned long powerLast; // Zeitmessung für High oder Low
/*----- LCD -----*/
String errorMessage = ""; // Nachricht für Display
unsigned long timeLastLCD; // LCD Timeout
/*----- CBPi -----*/
unsigned long timeLastCommand; // Letzer empfangener Command von CBPi
/*############## PIN-Zuordnung ##################*/
/*----- Induktionskochfeld -----*/
const byte PIN_WHITE = 3; // RELAIS
const byte PIN_YELLOW = 5; // AUSGABE AN PLATTE
const byte PIN_INTERRUPT = 2; // EINGABE VON PLATTE