Use simpler constructor.

This commit is contained in:
Chris Giacofei 2022-01-21 11:35:09 -05:00
parent 8b72a16203
commit 9a535c665b
4 changed files with 25 additions and 13 deletions

View File

@ -102,7 +102,6 @@ void setup() {
ConfigData config;
EEPROM.get(ConfAddress, config);
unsigned long lastRun = millis() - UpdateInterval;
Serial.begin(9600);
rotary.begin();
@ -120,7 +119,9 @@ void setup() {
mqtt_client.setClient(net);
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 (Ethernet.linkStatus() == LinkON) {

View File

@ -68,4 +68,6 @@ unsigned long lastRun = 0;
#ifndef I_CS2
#define I_CS2 48
#endif
#endif

View File

@ -1,37 +1,44 @@
#include <Arduino.h>
#include <EEPROM.h>
#include "thermoControl.h"
void thermoControl::begin(int8_t pinRTD) {
void thermoControl::begin(int pinRTD) {
RTD = new Adafruit_MAX31865(pinRTD);
r_ref = 430.0;
r_nominal = 100.0;
outMax = 100;
outMin = 10;
OpMode = OFF;
SampleTime = 100;
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) {
output_pwm = output_pwm;
void thermoControl::begin(int pinRTD, double temp, double duty, double mpt, double hyst) {
RTD = new Adafruit_MAX31865(pinRTD);
control_temp = temp;
r_ref = 430.0;
r_nominal = 100.0;
outMax = 100;
outMin = 10;
OpMode = OFF;
SampleTime = 100;
lastTime = millis()-SampleTime;
output_pwm = duty;
control_temp = temp;
hysteresis = hyst;
max_pwr_threshold = mpt;
}
bool thermoControl::Compute() {
unsigned long now = millis();
unsigned long timeChange = (now - lastTime);
double temp = RTD->readRTD();
double temp = RTD->temperature(r_nominal, r_ref);
if(timeChange>=SampleTime && OpMode == AUTOMATIC) {
double output;

View File

@ -8,6 +8,8 @@ enum modes : uint8_t {OFF, AUTOMATIC, MANUAL, OVERFLOW};
class thermoControl {
private:
Adafruit_MAX31865* RTD;
double r_nominal;
double r_ref;
double output_pwm;
double control_temp;
double hysteresis;
@ -21,8 +23,8 @@ class thermoControl {
unsigned long lastTime;
public:
void begin(int8_t, double, double, double, double);
void begin(int8_t);
void begin(int, double, double, double, double);
void begin(int);
bool Compute();
double Power();
void Power(double);