Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion firmware/lib/hal/SanyoAceB97.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion firmware/lib/task/cog_hal.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
}
}
81 changes: 41 additions & 40 deletions firmware/lib/task/cog_task.cpp
Original file line numberDiff line numberDiff line change
@@ -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 <https://www.gnu.org/licenses/>.

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 <https://www.gnu.org/licenses/>.

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"
Expand All@@ -26,14 +26,14 @@ namespace OxApp


// TODO: Most of this should be moved into the machine definition
bool CogTask::_init()
{
OxCore::Debug<const char *>("CogTask init\n");
bool CogTask::_init()
{
OxCore::Debug<const char *>("CogTask init\n");

getConfig()->fanDutyCycle = 0.0;
getConfig()->fanDutyCycle = 0.0;

return true;
}
return true;
}

COG_HAL* CogTask::getHAL() {
return (COG_HAL *) (getConfig()->hal);
Expand All@@ -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;
Expand DownExpand Up@@ -181,7 +181,7 @@ namespace OxApp
// getConfig()->BEGIN_DN_TIME_MS = millis();
// } else

{
{
getConfig()->TARGET_TEMP = tt;
heaterPIDTask->HeaterSetPoint_C = getConfig()->TARGET_TEMP;
}
Expand DownExpand Up@@ -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);
Expand All@@ -252,6 +253,6 @@ namespace OxApp
heaterPIDTask->HeaterSetPoint_C = tt;

_updateStackVoltage(getConfig()->STACK_VOLTAGE);
return new_ms;
}
return new_ms;
}
}
8 changes: 2 additions & 6 deletions firmware/lib/task/machine.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,18 +37,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
D4 - MAX31850_DATA_PIN
*/

#ifdef ARDUINO
#include <Arduino.h>


#ifdef RIBBONFISH
#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
Expand All@@ -59,7 +55,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#define POST_HEATER_0_IDX 1

#endif
#endif


#include <machine_core_defs.h>

Expand Down
10 changes: 7 additions & 3 deletions firmware/lib/task/read_temps_task.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand All@@ -120,13 +118,17 @@ void ReadTempsTask::updateTemperatures() {
OxCore::Debug<const char *>("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++;
} else {
OxCore::Debug<const char *>("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++;
Expand DownExpand Up@@ -185,6 +187,8 @@ void ReadTempsTask::_readTemperatureSensors() {
OxCore::Debug<const char *>(": ");
OxCore::DebugLn<float>(temperature);
}
// TODO: We should investigate a delay hear to make sure the
// OneWire system is ready
}
if (DEBUG_READ_TEMPS > 1) {
dumpQueue();
Expand Down
8 changes: 4 additions & 4 deletions firmware/lib/task/stage2_config.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,20 +25,20 @@ void MachineConfig::outputStage2Report(
Stage2Heater s2h,MachineStatusReport *msr,
float target_temp,float measured_temp,float duty_cycle) {
OxCore::Debug<const char *>("Stage2Heater: ");
delay(100);

OxCore::DebugLn<const char *>(MachineConfig::HeaterNames[s2h]);
delay(100);

OxCore::Debug<const char *>("Machine State: ");
OxCore::DebugLn<const char *>(MachineConfig::MachineStateNames[msr->ms]);
delay(100);

OxCore::Debug<const char *>("Target C: ");
OxCore::DebugLn<float>(target_temp);
OxCore::Debug<const char *>("Temp C : ");
// This needs to change base on our state...
OxCore::DebugLn<float>(measured_temp);
OxCore::Debug<const char *>("Heater DC : ");
Serial.println(duty_cycle,4);
delay(100);

}

void MachineConfig::createStage2JSONReport(Stage2Heater s2h,MachineStatusReport* msr, char *buffer) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/main.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -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<const char *>("Added tasks\n");

Expand Down