Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ab64679
State Machine Base
DiegoLHendrix Dec 10, 2024
190f973
Switching to TPDO and RPDO
DiegoLHendrix Jan 18, 2025
62e4d55
Testin vicor fault input
DiegoLHendrix Jan 25, 2025
ac2b0a5
Vicor fault signal be working
DiegoLHendrix Jan 25, 2025
3aff232
I make oopsie
DiegoLHendrix Jan 27, 2025
6d2e140
Temperature sensing started
DiegoLHendrix Feb 6, 2025
81eff1e
Power switch temperature sensing is functional
DiegoLHendrix Feb 8, 2025
dffdba2
Temperature and Current sensing methods tested
DiegoLHendrix Feb 13, 2025
847fe5c
Fault State added
DiegoLHendrix Feb 15, 2025
c7fe087
GitHub being dumb
DiegoLHendrix Feb 18, 2025
561dd5f
Applied Formatting Changes During GitHub Build
Feb 18, 2025
8e188a6
Changed exit condition for fault state
DiegoLHendrix Feb 18, 2025
06af24e
Loosing it rn
DiegoLHendrix Feb 18, 2025
8fdc71a
Applied Formatting Changes During GitHub Build
Feb 18, 2025
acc57b8
Namespace changes
DiegoLHendrix Mar 1, 2025
dd04a80
Current and temperature sensing fixing
DiegoLHendrix Apr 5, 2025
a700955
Current and temperature sensing fixing
DiegoLHendrix Apr 5, 2025
84a4b38
Applied Formatting Changes During GitHub Build
Apr 5, 2025
8d77abc
Temperature sensing works
DiegoLHendrix Apr 8, 2025
e34ef4a
Applied Formatting Changes During GitHub Build
Apr 8, 2025
56ec042
Running method created
DiegoLHendrix Apr 23, 2025
5388ad5
Applied Formatting Changes During GitHub Build
Apr 23, 2025
99a1c49
Updated state machine and CANopen object dictionary
DiegoLHendrix Apr 24, 2025
91dedeb
Merge branch 'feature/diegolhendrix/state-machine' of github.com:RIT-…
DiegoLHendrix Apr 24, 2025
26fac15
Fixed merge conflicts
DiegoLHendrix Apr 24, 2025
70f900d
Process state with fault checking
DiegoLHendrix Apr 26, 2025
ae3ac7d
Applied Formatting Changes During GitHub Build
Apr 26, 2025
fe79b15
Initialized boards as off
DiegoLHendrix Apr 26, 2025
28fb43d
Merge branch 'feature/diegolhendrix/state-machine' of github.com:RIT-…
DiegoLHendrix Apr 26, 2025
07235ce
Fixed CANopen object dictionary, README.md, and current sensing
DiegoLHendrix May 3, 2025
2a97690
Check vicor fault status, added proper time intervals for CANopen dic…
DiegoLHendrix May 3, 2025
7347bb0
Fixed getCurrent method on TPS2H target
DiegoLHendrix May 3, 2025
94024b6
Applied Formatting Changes During GitHub Build
May 3, 2025
11dfb3f
Added setLimits in main.cpp and fixed incorrect log print message for…
DiegoLHendrix May 4, 2025
9489635
Fixed CANopen intervals
DiegoLHendrix May 5, 2025
80a252d
Applied Formatting Changes During GitHub Build
May 7, 2025
8b0a421
Properly receiving CANopen messages
DiegoLHendrix May 7, 2025
21d9dc8
Started making PR changes
DiegoLHendrix May 26, 2025
eeff12e
PR review changes part 1
DiegoLHendrix May 28, 2025
a2dceb2
Pr changes part 2: electric boogaloo
DiegoLHendrix Jul 23, 2025
c83c7f9
Applied Formatting Changes During GitHub Build
Jul 23, 2025
9862dcd
Fixed Latch pin logic, edited switchFaultStatus variable name, rename…
DiegoLHendrix Aug 18, 2025
0be2e7c
Applied Formatting Changes During GitHub Build
Aug 18, 2025
6a9c33f
made constructor explicit, made volt in (3.3) sensitivity and average…
danntrapp Oct 2, 2025
d69996e
renamed temperature limit because Rue told me to, fixed a comment
danntrapp Oct 2, 2025
bbb5160
Storing vals in variables for better readibility
danntrapp Oct 9, 2025
59f00ba
Updated CANopen object dictionary and EVT-Core branch
DiegoLHendrix Mar 30, 2026
26cec2b
Updated CANobject dictionary, added logic for turning switch off when…
DiegoLHendrix Apr 7, 2026
59b1669
Individual power switch channels now turn off when there is a fault i…
DiegoLHendrix Apr 11, 2026
24810c5
Updated variable names, comments, and struct declarations
DiegoLHendrix Apr 17, 2026
00eec29
Updated includes and namespaces for LVSS current sensor
DiegoLHendrix Apr 18, 2026
e6f8b17
Applied Formatting Changes During GitHub Build
Apr 18, 2026
3ab5cc9
Updated CANopen Object Dictionary to receive VCU board enable signal
DiegoLHendrix Apr 18, 2026
8f6ca21
Formatting and other pr changes
DiegoLHendrix Apr 23, 2026
3f8cac9
Applied Formatting Changes During GitHub Build
Apr 23, 2026
1b22a1e
Removed TPDO_NODE_ID variable and made logger messages more descriptive
DiegoLHendrix Apr 27, 2026
f95aa80
Applied Formatting Changes During GitHub Build
Apr 27, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
jobs:
build:
# Select the server's operating system
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
Comment thread
DiegoLHendrix marked this conversation as resolved.
Outdated

steps:
# Checkout the repository, including all submodules
Expand Down
Binary file removed datasheets/Current_Sensing_High_Power.pdf
Comment thread
DiegoLHendrix marked this conversation as resolved.
Binary file not shown.
170 changes: 163 additions & 7 deletions include/LVSS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <EVT/dev/LCD.hpp>
#include <EVT/io/CANopen.hpp>
#include <EVT/io/GPIO.hpp>
#include <EVT/io/SPI.hpp>
#include <EVT/utils/log.hpp>
#include <LVSS.hpp>
#include <cstdio>
Expand All @@ -14,6 +12,7 @@

namespace IO = EVT::core::IO;
namespace DEV = EVT::core::DEV;
namespace time = EVT::core::time;

namespace LVSS {

Expand All @@ -25,12 +24,58 @@ static constexpr uint8_t POWER_SWITCHES_SIZE = 3;
class LVSS : public CANDevice {
public:
static constexpr uint8_t NODE_ID = 42;
static constexpr uint8_t TPDO_NODE_ID = 1;

IO::GPIO& vicorFT;
static constexpr IO::Pin vicorFaultPin = IO::Pin::PB_4;
static constexpr IO::GPIO::State VICOR_FAULT_ACTIVE_STATE = IO::GPIO::State::HIGH;

/** Union bit field to hold a bit representing which boards are on/off */
typedef union {
uint16_t val;
struct {
// Power Switch 0
uint8_t batt : 1;
uint8_t hib : 1;

// Power Switch 1
uint8_t tms : 1;
uint8_t hudl : 1;

// Power Switch 2
uint8_t gub : 1;
uint8_t acc : 1;
};
Comment thread
DiegoLHendrix marked this conversation as resolved.
Outdated
} u_t;
Comment thread
DiegoLHendrix marked this conversation as resolved.
Outdated

/** FSM State declaration */
enum class State {
/** When LVSS is powered on */
INITIALIZATION = 0u,
/** Reads VCU signal and starting data liike switch current */
SOFT_START = 1u,
/** Turns on the specified boards */
POWER_UP = 2u,
/** Checks values for errors */
IDLE = 3u,
/** Handles errors */
FAULT = 4u,
};

enum class PowerSwitchStatus {
Safe = 1u,
OverCurrent = 2u,
Temperature = 3u,
Fault = 4u
};
Comment thread
DiegoLHendrix marked this conversation as resolved.

PowerSwitchStatus err[3] = {PowerSwitchStatus::Safe, PowerSwitchStatus::Safe, PowerSwitchStatus::Safe};// Holds the error status for each power switch

/**
* Constructor for the LVSS class, takes a pointer to an array of power switches
* @param powerSwitches an array of pointers to power switches
Comment thread
DiegoLHendrix marked this conversation as resolved.
Outdated
*/
explicit LVSS(TPS2HB50BQ1* powerSwitches[POWER_SWITCHES_SIZE]);
explicit LVSS(TPS2HB50BQ1* powerSwitches[POWER_SWITCHES_SIZE], IO::GPIO& vicorFT);

CO_OBJ_T* getObjectDictionary() override;

Expand All @@ -44,11 +89,122 @@ class LVSS : public CANDevice {
void process();

private:
// false = OFF, true = ON?

TPS2HB50BQ1* powerSwitches[POWER_SWITCHES_SIZE]{};// a struct for each power switch (of which there are 3)
// ACS781XLR currentSensor;

u_t boardEN;

/** Tracks signal from VCU */
uint16_t VCUBoardSig = 0x00;

/** Tracks high value current */
uint16_t highValCurrent = 0x00;
Comment thread
DiegoLHendrix marked this conversation as resolved.
Outdated

/** Tracks power switch current */
uint16_t switchCurrent = 0x00;

/** Tracks power switch temperature */
uint16_t switchTemperature = 0x00;

/** Tracks power switch fault */
uint16_t switchFaultstatus = 0x00;

/**
* The current state of the LVSS
*/
State state;

uint8_t CurrentLim = 9000; // Current Limit
uint8_t TemperatureLim = 135;// Temperature Limit

/**
* Boolean flag which represents that a state has just changed
*
* Useful for determining when operations that only take place once per
* state change should take place.
*/
bool isNewState = false;

/**
* Handle VICOR Initialization state
* Waits for 110ms while the VICOR initializes.
*
* State: State::INITIALIZATION
*/
void initState();

/**
* Handle VICOR soft start state
* Reads in CANopen messages from the VCU of which boards to turn on/ff.
*
* State: State::SOFT_START
*/
void softStartState();

/**
* Handle VICOR when the LVSS sends out power to the boards
* Determines which boards get turned on/off first based on priority.
*
* State: State::POWER_UP
*/
void powerUpState();

/**
* Checks LVSS values
*
* State: State::IDLE
*/
void idleState();

/**
* Checks LVSS values
*
* State: State::FAULT
*/
void faultState();

/**
* Have to know the size of the object dictionary for initialization
* process.
*/
static constexpr uint8_t OBJECT_DICTIONARY_SIZE = 40;

/**
* The object dictionary itself. Will be populated by this object during
* construction.
*
* The plus one is for the special "end of dictionary" marker.
*/
CO_OBJ_T objectDictionary[OBJECT_DICTIONARY_SIZE + 1] = {
MANDATORY_IDENTIFICATION_ENTRIES_1000_1014,
HEARTBEAT_PRODUCER_1017(2000),
IDENTITY_OBJECT_1018,
SDO_CONFIGURATION_1200,

RECEIVE_PDO_SETTINGS_OBJECT_140X(0x00, 0x00, TPDO_NODE_ID, RECEIVE_PDO_TRIGGER_ASYNC),
RECEIVE_PDO_MAPPING_START_KEY_16XX(0x00, 0x1),
RECEIVE_PDO_MAPPING_ENTRY_16XX(0x00, 0x01, PDO_MAPPING_UNSIGNED16),

TRANSMIT_PDO_SETTINGS_OBJECT_18XX(0x00, TRANSMIT_PDO_TRIGGER_TIMER, TRANSMIT_PDO_INHIBIT_TIME_DISABLE, 2000),
TRANSMIT_PDO_MAPPING_START_KEY_1AXX(0x00, 0x02),
TRANSMIT_PDO_MAPPING_ENTRY_1AXX(0x00, 0x01, PDO_MAPPING_UNSIGNED16),
TRANSMIT_PDO_MAPPING_ENTRY_1AXX(0x00, 0x02, PDO_MAPPING_UNSIGNED16),

// User defined data, this will be where we put elements that can be
// accessed via SDO and depending on configuration PDO
DATA_LINK_START_KEY_21XX(0x00, 0x05),
/** Receive data */
DATA_LINK_21XX(0x00, 0x01, CO_TUNSIGNED16, &VCUBoardSig),

/** Transfer data */
DATA_LINK_21XX(0x00, 0x02, CO_TUNSIGNED16, &highValCurrent),
DATA_LINK_21XX(0x00, 0x03, CO_TUNSIGNED16, &switchCurrent),
DATA_LINK_21XX(0x00, 0x04, CO_TUNSIGNED16, &switchTemperature),
DATA_LINK_21XX(0x00, 0x05, CO_TUNSIGNED16, &switchFaultstatus),

// End of dictionary marker
CO_OBJ_DICT_ENDMARK,
};
};

}// namespace LVSS
#endif
#endif
11 changes: 10 additions & 1 deletion include/dev/TPS2HB50BQ1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TPS2HB50BQ1 {
/**
* Get the temperature of the power switch
*
* @return The temperature of the power switch
* @return The temperature of the power switch in millicelsius
*/
uint32_t getTemp();

Expand All @@ -91,6 +91,15 @@ class TPS2HB50BQ1 {
IO::GPIO& diagSelect2;
IO::ADC& senseOut;

uint32_t temp = 0; // Power Switch Temperature
uint32_t counts = 0; // ADC Counts
uint32_t volts = 0; // ADC Voltage
uint32_t current = 0;// Power Switch Current in milliamps

uint32_t kcl = 90000; // Current Limit Ratio
uint32_t rlim = 10000; // Resistor that sets the current limit
uint32_t icl = kcl / rlim;// Current Limit Value

void setDiagStateEnabled(bool state);

/**
Expand Down
Loading