Use simpler constructor.
This commit is contained in:
parent
8b72a16203
commit
9a535c665b
@ -102,7 +102,6 @@ void setup() {
|
|||||||
ConfigData config;
|
ConfigData config;
|
||||||
EEPROM.get(ConfAddress, config);
|
EEPROM.get(ConfAddress, config);
|
||||||
|
|
||||||
|
|
||||||
unsigned long lastRun = millis() - UpdateInterval;
|
unsigned long lastRun = millis() - UpdateInterval;
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
rotary.begin();
|
rotary.begin();
|
||||||
@ -120,7 +119,9 @@ void setup() {
|
|||||||
mqtt_client.setClient(net);
|
mqtt_client.setClient(net);
|
||||||
mqtt_client.setCallback(MessageReceived);
|
mqtt_client.setCallback(MessageReceived);
|
||||||
|
|
||||||
KettleController.begin((int8_t)I_CS1, 0, 0, config.threshold, config.hysteresis);
|
KettleController.begin(I_CS1);
|
||||||
|
KettleController.SetHysteresis(config.hysteresis);
|
||||||
|
KettleController.SetThreshPWR(config.threshold);
|
||||||
|
|
||||||
// if you get a connection, report back via serial:
|
// if you get a connection, report back via serial:
|
||||||
if (Ethernet.linkStatus() == LinkON) {
|
if (Ethernet.linkStatus() == LinkON) {
|
||||||
|
@ -68,4 +68,6 @@ unsigned long lastRun = 0;
|
|||||||
#ifndef I_CS2
|
#ifndef I_CS2
|
||||||
#define I_CS2 48
|
#define I_CS2 48
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,37 +1,44 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <EEPROM.h>
|
|
||||||
#include "thermoControl.h"
|
#include "thermoControl.h"
|
||||||
|
|
||||||
|
|
||||||
void thermoControl::begin(int8_t pinRTD) {
|
void thermoControl::begin(int pinRTD) {
|
||||||
RTD = new Adafruit_MAX31865(pinRTD);
|
RTD = new Adafruit_MAX31865(pinRTD);
|
||||||
|
r_ref = 430.0;
|
||||||
|
r_nominal = 100.0;
|
||||||
outMax = 100;
|
outMax = 100;
|
||||||
outMin = 10;
|
outMin = 10;
|
||||||
OpMode = OFF;
|
OpMode = OFF;
|
||||||
SampleTime = 100;
|
SampleTime = 100;
|
||||||
lastTime = millis()-SampleTime;
|
lastTime = millis()-SampleTime;
|
||||||
|
output_pwm = 0;
|
||||||
|
control_temp = 0;
|
||||||
|
hysteresis = 1.0;
|
||||||
|
max_pwr_threshold = 5.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void thermoControl::begin(int8_t pinRTD, double temp, double output_pwm, double max_pwr_threshold, double hysteresis) {
|
void thermoControl::begin(int pinRTD, double temp, double duty, double mpt, double hyst) {
|
||||||
output_pwm = output_pwm;
|
|
||||||
|
|
||||||
RTD = new Adafruit_MAX31865(pinRTD);
|
RTD = new Adafruit_MAX31865(pinRTD);
|
||||||
control_temp = temp;
|
r_ref = 430.0;
|
||||||
|
r_nominal = 100.0;
|
||||||
outMax = 100;
|
outMax = 100;
|
||||||
outMin = 10;
|
outMin = 10;
|
||||||
|
|
||||||
OpMode = OFF;
|
OpMode = OFF;
|
||||||
SampleTime = 100;
|
SampleTime = 100;
|
||||||
lastTime = millis()-SampleTime;
|
lastTime = millis()-SampleTime;
|
||||||
|
|
||||||
|
output_pwm = duty;
|
||||||
|
control_temp = temp;
|
||||||
|
hysteresis = hyst;
|
||||||
|
max_pwr_threshold = mpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool thermoControl::Compute() {
|
bool thermoControl::Compute() {
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
unsigned long timeChange = (now - lastTime);
|
unsigned long timeChange = (now - lastTime);
|
||||||
|
|
||||||
double temp = RTD->readRTD();
|
double temp = RTD->temperature(r_nominal, r_ref);
|
||||||
|
|
||||||
if(timeChange>=SampleTime && OpMode == AUTOMATIC) {
|
if(timeChange>=SampleTime && OpMode == AUTOMATIC) {
|
||||||
double output;
|
double output;
|
||||||
|
@ -8,6 +8,8 @@ enum modes : uint8_t {OFF, AUTOMATIC, MANUAL, OVERFLOW};
|
|||||||
class thermoControl {
|
class thermoControl {
|
||||||
private:
|
private:
|
||||||
Adafruit_MAX31865* RTD;
|
Adafruit_MAX31865* RTD;
|
||||||
|
double r_nominal;
|
||||||
|
double r_ref;
|
||||||
double output_pwm;
|
double output_pwm;
|
||||||
double control_temp;
|
double control_temp;
|
||||||
double hysteresis;
|
double hysteresis;
|
||||||
@ -21,8 +23,8 @@ class thermoControl {
|
|||||||
unsigned long lastTime;
|
unsigned long lastTime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void begin(int8_t, double, double, double, double);
|
void begin(int, double, double, double, double);
|
||||||
void begin(int8_t);
|
void begin(int);
|
||||||
bool Compute();
|
bool Compute();
|
||||||
double Power();
|
double Power();
|
||||||
void Power(double);
|
void Power(double);
|
||||||
|
Loading…
Reference in New Issue
Block a user