Skyward boardcore
|
Driver to communicate with a TLB digital-analog weight transmitter attached to a loadcell. More...
#include <MBLoadCell.h>
Public Member Functions | |
MBLoadCell (USARTInterface &serial, LoadCellModes mode) | |
constructor that initializes the serial communication with the load cell | |
bool | init () override |
Initializes the serial communication with the load cell. | |
ReturnsStates | asciiRequest (LoadCellValuesEnum r, int value=0) |
Generates and sends a request in ASCII mode, waits for the response and updates the lastSample structure. | |
void | resetMaxMinWeights () |
Permits to reset the peak weight value. | |
void | printData () |
Prints the last sample received. | |
MBLoadCellData | getMaxWeight () |
Returns a copy of the max weight detected. | |
MBLoadCellData | getMinWeight () |
Returns a copy of the min weight detected. | |
bool | selfTest () override |
Check if the sensor is working. | |
![]() | |
Sensor () | |
Sensor (Sensor &&other) | |
virtual | ~Sensor () |
void | sample () override |
Sample the sensor. | |
virtual MBLoadCellData | getLastSample () |
![]() | |
virtual | ~AbstractSensor () |
SensorErrors | getLastError () |
Get last error for debugging purposes. Avoid silent fails. | |
Protected Member Functions | |
MBLoadCellData | sampleImpl () override |
Requests the weight sampled from the load cell or waits for a sample depending on the mode selected (it's a blocking function). | |
MBLoadCellData | sampleContModT (void) |
Sampling in the "continuous Mod T" mode. | |
MBLoadCellData | sampleContModTd (void) |
Sampling in the "continuous Mod Td" mode. | |
MBLoadCellData | sampleAsciiModTd (void) |
Sampling in the "ASCII Mod Td" mode. | |
void | generateRequest (DataAsciiRequest &req, const LoadCellValuesEnum toRequest, int value=0) |
Forges a request for the ascii mode. | |
void | transmitASCII (const std::string &buf) |
Wrapper to the serial sendString method. This also sets the control pins to enable the transmission mode. | |
std::string | receiveASCII () |
Wrapper to the serial recvString method. This also sets the control pins to enable the receiver mode. | |
template<typename T > | |
void | receive (T *buf) |
Wrapper to the serial receive method. This also sets the control pins to enable the receiver mode. | |
Additional Inherited Members | |
![]() | |
using | DataType |
![]() | |
DataType | lastSample |
miosix::FastMutex | mutex |
![]() | |
SensorErrors | lastError = SensorErrors::NO_ERRORS |
Driver to communicate with a TLB digital-analog weight transmitter attached to a loadcell.
The driver allows to use the TLB transmitter in different modes:
Definition at line 50 of file MBLoadCell.h.
Boardcore::MBLoadCell::MBLoadCell | ( | USARTInterface & | serial, |
LoadCellModes | mode ) |
constructor that initializes the serial communication with the load cell
mode | the mode in which the load cell is in |
serial | the serial port to be used |
Definition at line 36 of file MBLoadCell.cpp.
ReturnsStates Boardcore::MBLoadCell::asciiRequest | ( | LoadCellValuesEnum | r, |
int | value = 0 ) |
Generates and sends a request in ASCII mode, waits for the response and updates the lastSample structure.
Definition at line 55 of file MBLoadCell.cpp.
|
protected |
Forges a request for the ascii mode.
req | Reference to the request that will be generated. |
toRequest | The request to forge. |
value | The value used in the forging of the "set point" requests. |
Definition at line 253 of file MBLoadCell.cpp.
MBLoadCellData Boardcore::MBLoadCell::getMaxWeight | ( | ) |
Returns a copy of the max weight detected.
Definition at line 152 of file MBLoadCell.cpp.
MBLoadCellData Boardcore::MBLoadCell::getMinWeight | ( | ) |
Returns a copy of the min weight detected.
Definition at line 154 of file MBLoadCell.cpp.
|
overridevirtual |
Initializes the serial communication with the load cell.
Implements Boardcore::AbstractSensor.
Definition at line 43 of file MBLoadCell.cpp.
void Boardcore::MBLoadCell::printData | ( | ) |
Prints the last sample received.
Definition at line 123 of file MBLoadCell.cpp.
|
protected |
Wrapper to the serial receive method. This also sets the control pins to enable the receiver mode.
buf | The pointer to the buffer in which the data received will be stored. |
Definition at line 298 of file MBLoadCell.cpp.
|
protected |
Wrapper to the serial recvString method. This also sets the control pins to enable the receiver mode.
Definition at line 284 of file MBLoadCell.cpp.
void Boardcore::MBLoadCell::resetMaxMinWeights | ( | ) |
Permits to reset the peak weight value.
Definition at line 116 of file MBLoadCell.cpp.
|
protected |
Sampling in the "ASCII Mod Td" mode.
Definition at line 220 of file MBLoadCell.cpp.
|
protected |
Sampling in the "continuous Mod T" mode.
Definition at line 204 of file MBLoadCell.cpp.
|
protected |
Sampling in the "continuous Mod Td" mode.
Definition at line 212 of file MBLoadCell.cpp.
|
overrideprotectedvirtual |
Requests the weight sampled from the load cell or waits for a sample depending on the mode selected (it's a blocking function).
Implements Boardcore::Sensor< MBLoadCellData >.
Definition at line 158 of file MBLoadCell.cpp.
|
overridevirtual |
Check if the sensor is working.
Implements Boardcore::AbstractSensor.
Definition at line 156 of file MBLoadCell.cpp.
|
protected |
Wrapper to the serial sendString method. This also sets the control pins to enable the transmission mode.
buf | The message to send. |
Definition at line 275 of file MBLoadCell.cpp.