Skip to content
Open
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
1 change: 1 addition & 0 deletions firmware/lib/fdcan/fdcan_toad.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class CAN : public arduino::HardwareCAN
{
bool success = true;

// TODO - print error for each CAN bus that fails
success = success && can_tvc.begin(CanBitRate::BR_500k);
success = success && can_fc.begin(CanBitRate::BR_500k);

Expand Down
26 changes: 14 additions & 12 deletions firmware/lib/temperature_sensors/TemperatureSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ Adafruit_MAX31856 tc_chip_3(TC_CHIP_3_SPI_BUS, PIN_TC_CHIP_3_CS, MAX31856_TCTYPE
Adafruit_MAX31856 tc_chip_4(TC_CHIP_4_SPI_BUS, PIN_TC_CHIP_4_CS, MAX31856_TCTYPE_K);
Adafruit_MAX31856 tc_chip_5(TC_CHIP_5_SPI_BUS, PIN_TC_CHIP_5_CS, MAX31856_TCTYPE_K);
Adafruit_MAX31856 tc_chip_6(TC_CHIP_6_SPI_BUS, PIN_TC_CHIP_6_CS, MAX31856_TCTYPE_K);
Adafruit_MAX31856 tc_chips[NUM_TC_CHIPS] = {tc_chip_1, tc_chip_2, tc_chip_3, tc_chip_4, tc_chip_5, tc_chip_6};
const char *tc_names[NUM_TC_CHIPS] = {STRINGIFY(TC1), STRINGIFY(TC2), STRINGIFY(TC3),
STRINGIFY(TC4), STRINGIFY(TC5), STRINGIFY(TC6)};
static_assert(NUM_TC_CHIPS == 6);

// Configures each TC chip.
// Always returns true.
bool begin() {
bool all_chips_connected = true;
all_chips_connected &= tc_chip_1.begin();
all_chips_connected &= tc_chip_2.begin();
all_chips_connected &= tc_chip_3.begin();
all_chips_connected &= tc_chip_4.begin();
all_chips_connected &= tc_chip_5.begin();
all_chips_connected &= tc_chip_6.begin();
for (size_t i = 0; i < NUM_TC_CHIPS; i++) {
bool connected = tc_chips[i].begin();
if (!connected) {
CommsSerial.printf("TC Board %d failed to connect.", i);
}
all_chips_connected &= connected;
}

CommandRouter::add(print_tc_readings, "print_tc", "Print TC readings in Fahrenheit.");

Expand All @@ -42,6 +46,7 @@ temperature_readings_t read_tcs() {
tc_readings.TC_4 = tc_chip_4.readThermocoupleTemperature() + C_TO_KELVIN;
tc_readings.TC_5 = tc_chip_5.readThermocoupleTemperature() + C_TO_KELVIN;
tc_readings.TC_6 = tc_chip_6.readThermocoupleTemperature() + C_TO_KELVIN;
static_assert(NUM_TC_CHIPS == 6);

return tc_readings;
}
Expand All @@ -54,12 +59,9 @@ float c_to_f(float c) {
// print TC readings in Fahrenheit.
void print_tc_readings() {
CommsSerial.print("TC Readings:");
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_1), c_to_f(tc_chip_1.readThermocoupleTemperature()));
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_2), c_to_f(tc_chip_2.readThermocoupleTemperature()));
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_3), c_to_f(tc_chip_3.readThermocoupleTemperature()));
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_4), c_to_f(tc_chip_4.readThermocoupleTemperature()));
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_5), c_to_f(tc_chip_5.readThermocoupleTemperature()));
CommsSerial.printf("%20s: %6.2f C\n", STRINGIFY(TC_6), c_to_f(tc_chip_6.readThermocoupleTemperature()));
for (size_t i = 0; i < NUM_TC_CHIPS; i++) {
CommsSerial.printf("%20s: %6.2f F\n", tc_names[i], c_to_f(tc_chips[i].readThermocoupleTemperature()));
}
}

} // namespace TemperatureSensors
4 changes: 2 additions & 2 deletions firmware/src/ec_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "ErrorCounters.h"
#include "PressureSensors.h"
#include "RCS.h"
#include "RS485.h"
#include "SolenoidValves.h"
#include "TVC_Actuators.h"
#include "TemperatureSensors.h"
#include "ThrottleValves.h"
#include "ValveController.h"
#include "fdcan_toad.h"
#include "RS485.h"

// shared interfaces
// CommsSerial_t<USBSerial> USB_CommsSerial;
Expand Down Expand Up @@ -58,7 +58,7 @@ void setup() {
if (!all_modules_ok) {
while (true) {
CommsSerial.println("At least one module failed to begin(), see errors above.");
HW_FallbackSerial.println("At least one module failed to begin(), see errors above. [Fallback Serial]");
HW_FallbackSerial.println("At least one module failed to begin(). [Fallback Serial]");
delay(5000);
}
}
Expand Down
Loading