Skip to content

Commit

Permalink
load cell and sab interface documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
abbymartin committed Sep 12, 2024
1 parent 206cc3a commit 53321c8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
30 changes: 28 additions & 2 deletions lib/interfaces/include/LoadCellInterface.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#ifndef __LOADCELLINTERFACE_H__
#define __LOADCELLINTERFACE_H__

/* Library */
#include "Utility.h"
#include "SysClock.h"
#include "AnalogSensorsInterface.h"

/* Structs */
/* Interface */
#include "AnalogSensorsInterface.h"

/**
* Struct holding conversions for each wheel's load cell data.
* AnalogConversion_s struct holds raw and converted values and whether the result was clamped.
* Load cell data is converted from raw -> lbs
*/
struct LoadCellInterfaceTick_s
{
const AnalogConversion_s &FLConversion;
Expand All @@ -15,13 +21,22 @@ struct LoadCellInterfaceTick_s
const AnalogConversion_s &RRConversion;
};

/**
* Struct containing converted and filtered load cell data
*/
struct LoadCellInterfaceOutput_s
{
veh_vec<float> loadCellForcesFiltered;
veh_vec<AnalogConversion_s> loadCellConversions;
bool FIRSaturated;
};


/**
* The LoadCellInterface filters load cell signals to be used in the TorqueControllers system.
* Applies FIR filter and determines if signal is saturated
* [why specifically do we use a FIR filter?]

This comment has been minimized.

Copy link
@jhwang04

jhwang04 Sep 12, 2024

Contributor

From my short googling, a FIR filter is like a weighted sliding window. FIR filters are good for their stability and ease of implementation (a quick impulse will not continue to affect the signal beyond a finite point). That being said, we might wanna ask Ben why we chose FIR instead of IIR for the load cells.

*/
class LoadCellInterface
{
private:
Expand Down Expand Up @@ -56,8 +71,19 @@ class LoadCellInterface
veh_vec<float> loadCellForcesFiltered_;
bool FIRSaturated_ = false;
public:
/**
* Default constructor
*/
LoadCellInterface() {}

/**
* Updates load cell force vectors after receiving new data

This comment has been minimized.

Copy link
@jhwang04

jhwang04 Sep 12, 2024

Contributor

I'd say something like "Updates loadCellForcesFiltered_ vectors after receiving new data" to be clear you're referring to the field. Minor nitpick (somewhat subjective)

*/
void tick(const LoadCellInterfaceTick_s &intake);

/**
* Getter for load cell output data
*/
LoadCellInterfaceOutput_s getLoadCellForces();
};

Expand Down
23 changes: 23 additions & 0 deletions lib/interfaces/include/SABInterface.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#ifndef __SABINTERFACE_H__
#define __SABINTERFACE_H__

/* Library */
#include "hytech.h"
#include "FlexCAN_T4.h"

/* Interface */
#include "AnalogSensorsInterface.h"

/**
* The SAB Interface receieves CAN messages containing load cell and potentionmeter readings.
* Through this interface values are parsed, updated, and converted to real units.
*/
class SABInterface
{
private:
public:
/* Rear load cell output */
AnalogChannel rlLoadCell;
AnalogChannel rrLoadCell;

/* Rear potentiometer output */
AnalogChannel pot3;
AnalogChannel pot4;

/**
* Constructor that defines conversion for both load cells and potentionmeter data
* Defined offset and scale values from MCU_rev15_defs are used to convert from raw data to correct units (pounds)
*/
SABInterface(
float rlLoadCellScale,
float rlLoadCellOffset,
Expand All @@ -38,13 +52,22 @@ class SABInterface
pot4.offset = pot4Offset;
};

/**
* Overloaded constructor with default values for potentiometer data.
* Sets pot scale to 1.0 and offset to 0.0 so value stays same as last sample.
*/
SABInterface(
float rlLoadCellScale,
float rlLoadCellOffset,
float rrLoadCellScale,
float rrLoadCellOffset
) : SABInterface (rlLoadCellScale, rlLoadCellOffset, rrLoadCellScale, rrLoadCellOffset, 1.0, 0.0, 1.0, 0.0) {};


/**
* Parses CAN message into individual values for rear load cell and potentiometer readings.
* Updates each sensor's lastSample and converts data to pounds

This comment has been minimized.

Copy link
@jhwang04

jhwang04 Sep 12, 2024

Contributor

Since this function affects the object's member variables, you might want to specify which ones are affected

*/
void retrieve_pots_and_load_cells_CAN(CAN_message_t &recvd_msg);
};

Expand Down

0 comments on commit 53321c8

Please sign in to comment.