diff --git a/firmware/lib/hal/SanyoAceB97.cpp b/firmware/lib/hal/SanyoAceB97.cpp index ed25ebe4..9be2e10a 100644 --- a/firmware/lib/hal/SanyoAceB97.cpp +++ b/firmware/lib/hal/SanyoAceB97.cpp @@ -31,9 +31,16 @@ //Calculates the RPM based on the timestamps of the last 2 interrupts. Can be called at any time. //namespace tach_data { + +// This can be used to add time to the interrupt for testing; +// so far I have not seen that that creates a problem +//unsigned long temporary_test_variable; + void tachISR(uint8_t i) { tach_data_cnt[i]++; - // refresh_tach_data(i); + // for(int i = 0; i < 1000; i++) { + // temporary_test_variable = (temporary_test_variable * 2 ) % 37; + // } } void tachISR0() { tachISR(0); diff --git a/firmware/lib/task/cog_hal.cpp b/firmware/lib/task/cog_hal.cpp index fcac3a5a..99239bbb 100644 --- a/firmware/lib/task/cog_hal.cpp +++ b/firmware/lib/task/cog_hal.cpp @@ -62,6 +62,6 @@ bool COG_HAL::init() { // but this is genertic. void COG_HAL::_updateFanPWM(float unitInterval) { for (int i = 0; i < NUM_FANS; i++) { - _fans[i].update(unitInterval); + _fans[i].update(unitInterval); } } diff --git a/firmware/lib/task/cog_task.cpp b/firmware/lib/task/cog_task.cpp index 4ff54e2f..6da9640c 100644 --- a/firmware/lib/task/cog_task.cpp +++ b/firmware/lib/task/cog_task.cpp @@ -1,16 +1,16 @@ /* -This program includes free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. - -See the GNU Affero General Public License for more details. -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + This program includes free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + See the GNU Affero General Public License for more details. + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include "cog_task.h" @@ -26,14 +26,14 @@ namespace OxApp // TODO: Most of this should be moved into the machine definition - bool CogTask::_init() - { - OxCore::Debug("CogTask init\n"); + bool CogTask::_init() + { + OxCore::Debug("CogTask init\n"); - getConfig()->fanDutyCycle = 0.0; + getConfig()->fanDutyCycle = 0.0; - return true; - } + return true; + } COG_HAL* CogTask::getHAL() { return (COG_HAL *) (getConfig()->hal); @@ -42,13 +42,13 @@ namespace OxApp float CogTask::getTemperatureReading() { return getConfig()->report->post_heater_C; } - bool CogTask::_run() - { - // Report fan speed - getConfig()->report->fan_rpm = - getHAL()->_fans[0]._calcRPM(0); - this->StateMachineManager::run_generic(); - } + bool CogTask::_run() + { + // Report fan speed + getConfig()->report->fan_rpm = + getHAL()->_fans[0]._calcRPM(0); + this->StateMachineManager::run_generic(); + } MachineState CogTask::_updatePowerComponentsOff() { MachineState new_ms = Off; @@ -181,7 +181,7 @@ namespace OxApp // getConfig()->BEGIN_DN_TIME_MS = millis(); // } else - { + { getConfig()->TARGET_TEMP = tt; heaterPIDTask->HeaterSetPoint_C = getConfig()->TARGET_TEMP; } @@ -215,20 +215,21 @@ namespace OxApp return new_ms; } // TODO: This would go better on the HAL - void CogTask::_updateStackVoltage(float voltage) { - for (int i = 0; i < getHAL()->NUM_STACKS; i++) { - getHAL()->_stacks[i]->updateVoltage(voltage,getConfig()); - } - } - - void CogTask::_updateStackAmperage(float amperage) { - for (int i = 0; i < getHAL()->NUM_STACKS; i++) { - getHAL()->_stacks[i]->updateAmperage(amperage,getConfig()); - } + void CogTask::_updateStackVoltage(float voltage) { + for (int i = 0; i < getHAL()->NUM_STACKS; i++) { + getHAL()->_stacks[i]->updateVoltage(voltage,getConfig()); } + } + + void CogTask::_updateStackAmperage(float amperage) { + for (int i = 0; i < getHAL()->NUM_STACKS; i++) { + getHAL()->_stacks[i]->updateAmperage(amperage,getConfig()); + } + } - MachineState CogTask::_updatePowerComponentsOperation(IdleOrOperateSubState i_or_o) { - MachineState new_ms = NormalOperation; + + MachineState CogTask::_updatePowerComponentsOperation(IdleOrOperateSubState i_or_o) { + MachineState new_ms = NormalOperation; float t = getTemperatureReading();; float fs = computeFanSpeed(t); @@ -252,6 +253,6 @@ namespace OxApp heaterPIDTask->HeaterSetPoint_C = tt; _updateStackVoltage(getConfig()->STACK_VOLTAGE); - return new_ms; - } + return new_ms; + } } diff --git a/firmware/lib/task/machine.h b/firmware/lib/task/machine.h index b9ef3247..f64217a2 100644 --- a/firmware/lib/task/machine.h +++ b/firmware/lib/task/machine.h @@ -37,7 +37,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. D4 - MAX31850_DATA_PIN */ -#ifdef ARDUINO #include @@ -45,10 +44,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #define RF_FAN 2 #define RF_HEATER 3 #define RF_STACK DAC0 -// This should change to PIN 5 when -// we get the planned control board. -#define MAX31850_DATA_PIN 4 -//#define MAX31850_DATA_PIN 5 +#define MAX31850_DATA_PIN 5 // #define RF_FAN_TACH 5 #define RF_MOSTPLUS_FLOW_PIN A0 #define RF_MOSTPLUS_FLOW_LOW_CUTOFF_VOLTAGE 1.75 @@ -59,7 +55,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #define POST_HEATER_0_IDX 1 #endif -#endif + #include diff --git a/firmware/lib/task/read_temps_task.cpp b/firmware/lib/task/read_temps_task.cpp index be9dec54..9a012055 100644 --- a/firmware/lib/task/read_temps_task.cpp +++ b/firmware/lib/task/read_temps_task.cpp @@ -107,9 +107,7 @@ void ReadTempsTask::updateTemperatures() { // These are added just to test if reading quickly causes an error, // which might induce us to add power to the Dallas One-Wire board, for example. - float postHeaterTemp = _temperatureSensors[0].GetTemperature(0); - float postStackTemp = _temperatureSensors[0].GetTemperature(1); - float postGetterTemp = _temperatureSensors[0].GetTemperature(2); + float postHeaterTemp = _temperatureSensors[0].GetTemperature(0);; // Sometimes we get a data read error, that comes across // as -127.00. In that case, we will leave the // value unchanged from the last read. @@ -120,6 +118,8 @@ void ReadTempsTask::updateTemperatures() { OxCore::Debug("Bad post_heater_C\n"); bad_temp_reads++; } + + float postGetterTemp = _temperatureSensors[0].GetTemperature(2); if (postGetterTemp > -100.0) { getConfig()->report->post_getter_C = postGetterTemp; good_temp_reads++; @@ -127,6 +127,8 @@ void ReadTempsTask::updateTemperatures() { OxCore::Debug("Bad post_getter_C\n"); bad_temp_reads++; } + + float postStackTemp = _temperatureSensors[0].GetTemperature(1); if (postStackTemp > -100.0) { getConfig()->report->post_stack_C = postStackTemp; good_temp_reads++; @@ -185,6 +187,8 @@ void ReadTempsTask::_readTemperatureSensors() { OxCore::Debug(": "); OxCore::DebugLn(temperature); } + // TODO: We should investigate a delay hear to make sure the + // OneWire system is ready } if (DEBUG_READ_TEMPS > 1) { dumpQueue(); diff --git a/firmware/lib/task/stage2_config.cpp b/firmware/lib/task/stage2_config.cpp index 685f550f..97610153 100644 --- a/firmware/lib/task/stage2_config.cpp +++ b/firmware/lib/task/stage2_config.cpp @@ -25,12 +25,12 @@ void MachineConfig::outputStage2Report( Stage2Heater s2h,MachineStatusReport *msr, float target_temp,float measured_temp,float duty_cycle) { OxCore::Debug("Stage2Heater: "); - delay(100); + OxCore::DebugLn(MachineConfig::HeaterNames[s2h]); - delay(100); + OxCore::Debug("Machine State: "); OxCore::DebugLn(MachineConfig::MachineStateNames[msr->ms]); - delay(100); + OxCore::Debug("Target C: "); OxCore::DebugLn(target_temp); OxCore::Debug("Temp C : "); @@ -38,7 +38,7 @@ void MachineConfig::outputStage2Report( OxCore::DebugLn(measured_temp); OxCore::Debug("Heater DC : "); Serial.println(duty_cycle,4); - delay(100); + } void MachineConfig::createStage2JSONReport(Stage2Heater s2h,MachineStatusReport* msr, char *buffer) { diff --git a/firmware/src/main.cpp b/firmware/src/main.cpp index 5336b1f6..680b9db9 100644 --- a/firmware/src/main.cpp +++ b/firmware/src/main.cpp @@ -230,7 +230,7 @@ void setup() heaterPIDTask.DEBUG_PID = 0; cogTask.DEBUG_LEVEL = 0; retrieveScriptUDPTask.DEBUG_UDP = 0; - readTempsTask.DEBUG_READ_TEMPS = 0; + readTempsTask.DEBUG_READ_TEMPS = 2; OxCore::Debug("Added tasks\n");