Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #224 from PubInv/robCleanup
Browse files Browse the repository at this point in the history
Rob cleanup
  • Loading branch information
RobertLRead committed Sep 9, 2023
2 parents 982b8cb + 5edfdf2 commit 74941c8
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
21 changes: 17 additions & 4 deletions firmware/lib/task/read_temps_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ void ReadTempsTask::calculateDdelta() {

void ReadTempsTask::updateTemperatures() {
_readTemperatureSensors();

// 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);
Expand All @@ -112,18 +115,24 @@ void ReadTempsTask::updateTemperatures() {
// value unchanged from the last read.
if (postHeaterTemp > -100.0) {
getConfig()->report->post_heater_C = postHeaterTemp;
good_temp_reads++;
} else {
OxCore::Debug<const char *>("Bad post_heater_C\n");
bad_temp_reads++;
}
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++;
}
if (postStackTemp > -100.0) {
getConfig()->report->post_stack_C = postStackTemp;
good_temp_reads++;
} else {
OxCore::Debug<const char *>("Bad post_stack_C\n");
bad_temp_reads++;
}

// WARNING! This needs to be done for all configs if we are
Expand All @@ -139,6 +148,14 @@ void ReadTempsTask::updateTemperatures() {
// which is what we are using as a control variable.
addTempToQueue(getConfig()->report->post_heater_C);
calculateDdelta();
if (DEBUG_READ_TEMPS > 0) {
OxCore::Debug<const char *>("Good Temp Reads:");
OxCore::Debug<unsigned long>(good_temp_reads);
OxCore::DebugLn<const char *>("");
OxCore::Debug<const char *>("Bad Temp Reads:");
OxCore::Debug<unsigned long>(bad_temp_reads);
OxCore::DebugLn<const char *>("");
}
}

void stage2_ReadTempsTask::updateTemperatures() {
Expand Down Expand Up @@ -169,10 +186,6 @@ void ReadTempsTask::_readTemperatureSensors() {
OxCore::DebugLn<float>(temperature);
}
}
if (DEBUG_READ_TEMPS > 1) {
OxCore::Debug<const char *>("Ddelta_C_per_min :");
Serial.println(Ddelta_C_per_min,5);
}
if (DEBUG_READ_TEMPS > 1) {
dumpQueue();
}
Expand Down
5 changes: 5 additions & 0 deletions firmware/lib/task/read_temps_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class ReadTempsTask : public OxCore::Task
public:
ReadTempsTask();
int DEBUG_READ_TEMPS = 0;

// These two fields are used to track the
// missing stack
unsigned long good_temp_reads = 0;
unsigned long bad_temp_reads = 0;
static const int PERIOD_MS = MachineConfig::TEMP_READ_PERIOD_MS;
// This is a ring buffer...

Expand Down
2 changes: 0 additions & 2 deletions firmware/lib/task/serial_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ namespace OxApp
if (DEBUG_LEVEL > 2) {
render_set_command_raw(&sc);
}
DebugLn<const char *>("rendered command");
delay(100);

// This is an over simplifcation of possible state transitions!
// This needs to be taken out to a separate routine, probably
Expand Down
3 changes: 0 additions & 3 deletions firmware/lib/task/state_machine_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ namespace OxApp
unsigned long ms = millis();
const unsigned long MINUTES_RAMPING_UP = (ms - begin_up_time_ms) / (60 * 1000);
float tt = recent_t + MINUTES_RAMPING_UP * getConfig()->RAMP_UP_TARGET_D_MIN;
Serial.println("preliminary tt, minutes");
Serial.println(MINUTES_RAMPING_UP);
Serial.println(getConfig()->OPERATING_TEMP);
tt = min(tt,getConfig()->OPERATING_TEMP);
return tt;
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/lib/task/state_machine_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace OxApp

class StateMachineManager : public OxCore::Task {
public:
int DEBUG_LEVEL = 2;
int DEBUG_LEVEL = 0;
TempRefreshTask* tempRefreshTask;
HeaterPIDTask* heaterPIDTask;

Expand Down
2 changes: 1 addition & 1 deletion firmware/lib/task/temp_refresh_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
public:
TempRefreshTask();
int DEBUG_TEMP_REFRESH = 1;
int DEBUG_TEMP_REFRESH = 0;
const int PERIOD_MS = 5*60*1000;
unsigned long time_of_last_refresh = 0;
// In this case, we need a public ability to run the task
Expand Down
28 changes: 18 additions & 10 deletions firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

// Program information
#define COMPANY_NAME "pubinv.org "
#define PROG_NAME "main.cpp"
#define VERSION "; Rev: 0.3.0" //
#define DEVICE_UNDER_TEST "Hardware: Due" //A model number
#define LICENSE "GNU Affero General Public License, version 3 "


#ifdef ARDUINO
#include <Arduino.h>
//#include <display.h>
#else // Native
//
#endif

Expand Down Expand Up @@ -177,7 +184,6 @@ void setup()
retrieveScriptUDPProperties.priority = OxCore::TaskPriority::High;
retrieveScriptUDPProperties.state_and_config = (void *) &machineConfig;

retrieveScriptUDPTask.DEBUG_UDP = 2;
bool retrieveScriptUDP = core.AddTask(&retrieveScriptUDPTask, &retrieveScriptUDPProperties);
if (!retrieveScriptUDP) {
OxCore::Debug<const char *>("Retrieve Script UDP\n");
Expand Down Expand Up @@ -221,8 +227,10 @@ void setup()
cogTask.heaterPIDTask = &heaterPIDTask;
cogTask.tempRefreshTask = &tempRefreshTask;

heaterPIDTask.DEBUG_PID = 1;
cogTask.DEBUG_LEVEL = 2;
heaterPIDTask.DEBUG_PID = 0;
cogTask.DEBUG_LEVEL = 0;
retrieveScriptUDPTask.DEBUG_UDP = 0;
readTempsTask.DEBUG_READ_TEMPS = 0;

OxCore::Debug<const char *>("Added tasks\n");

Expand All @@ -241,15 +249,15 @@ void loop() {
Serial.println("Critical error!");
delay(100);
// Loop endlessly to stop the program from running
while (true) {
Serial.println("INTERNAL ERROR!");
delay(100);
}
Serial.println("INTERNAL ERROR (CORE RETURNED)!");
delay(1000);
abort();
#endif
return;
} else {
Serial.println("INTERNAL ERROR!");
delay(100);
Serial.println("INTERNAL ERROR (CORE DID NOT START)!");
delay(300000);
abort();
}
}

Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ run_monitor:
&& pio device monitor --filter=direct --baud=115200


pio-run-due_ribbonfish:
oedcs:
cd firmware \
&& pio run -e due_ribbonfish -t upload \
&& pio device monitor --filter=direct --baud=115200

0 comments on commit 74941c8

Please sign in to comment.