-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
load cell and sab interface documentation
- Loading branch information
1 parent
206cc3a
commit 53321c8
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
@@ -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.
Sorry, something went wrong. |
||
*/ | ||
class LoadCellInterface | ||
{ | ||
private: | ||
|
@@ -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.
Sorry, something went wrong.
jhwang04
Contributor
|
||
*/ | ||
void tick(const LoadCellInterfaceTick_s &intake); | ||
|
||
/** | ||
* Getter for load cell output data | ||
*/ | ||
LoadCellInterfaceOutput_s getLoadCellForces(); | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -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.
Sorry, something went wrong.
jhwang04
Contributor
|
||
*/ | ||
void retrieve_pots_and_load_cells_CAN(CAN_message_t &recvd_msg); | ||
}; | ||
|
||
|
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.