Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::MBLoadCell Class Reference

Driver to communicate with a TLB digital-analog weight transmitter attached to a loadcell. More...

#include <MBLoadCell.h>

Inheritance diagram for Boardcore::MBLoadCell:
Collaboration diagram for Boardcore::MBLoadCell:

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.
 
- Public Member Functions inherited from Boardcore::Sensor< MBLoadCellData >
 Sensor ()
 
 Sensor (Sensor &&other)
 
virtual ~Sensor ()
 
void sample () override
 Sample the sensor.
 
virtual MBLoadCellData getLastSample ()
 
- Public Member Functions inherited from Boardcore::AbstractSensor
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

- Public Types inherited from Boardcore::Sensor< MBLoadCellData >
using DataType
 
- Protected Attributes inherited from Boardcore::Sensor< MBLoadCellData >
DataType lastSample
 
miosix::FastMutex mutex
 
- Protected Attributes inherited from Boardcore::AbstractSensor
SensorErrors lastError = SensorErrors::NO_ERRORS
 

Detailed Description

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:

  • Continuous-modT: unidirectional protocol that consists in receiving the gross weight
  • Continuous-modTd: unidirectional protocol that consists in receiving the gross weight
  • ASCII-modTd: bidirectional mode that consists in sending a request and receiving a response with the data requested or an error message

Definition at line 50 of file MBLoadCell.h.

Constructor & Destructor Documentation

◆ MBLoadCell()

Boardcore::MBLoadCell::MBLoadCell ( USARTInterface & serial,
LoadCellModes mode )

constructor that initializes the serial communication with the load cell

Parameters
modethe mode in which the load cell is in
serialthe serial port to be used

Definition at line 36 of file MBLoadCell.cpp.

Member Function Documentation

◆ asciiRequest()

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.

◆ generateRequest()

void Boardcore::MBLoadCell::generateRequest ( DataAsciiRequest & req,
const LoadCellValuesEnum toRequest,
int value = 0 )
protected

Forges a request for the ascii mode.

Parameters
reqReference to the request that will be generated.
toRequestThe request to forge.
valueThe value used in the forging of the "set point" requests.

Definition at line 253 of file MBLoadCell.cpp.

◆ getMaxWeight()

MBLoadCellData Boardcore::MBLoadCell::getMaxWeight ( )

Returns a copy of the max weight detected.

Definition at line 152 of file MBLoadCell.cpp.

◆ getMinWeight()

MBLoadCellData Boardcore::MBLoadCell::getMinWeight ( )

Returns a copy of the min weight detected.

Definition at line 154 of file MBLoadCell.cpp.

◆ init()

bool Boardcore::MBLoadCell::init ( )
overridevirtual

Initializes the serial communication with the load cell.

Returns
True if initialization completed with no problems, false otherwise.

Implements Boardcore::AbstractSensor.

Definition at line 43 of file MBLoadCell.cpp.

◆ printData()

void Boardcore::MBLoadCell::printData ( )

Prints the last sample received.

Definition at line 123 of file MBLoadCell.cpp.

◆ receive()

template<typename T >
void Boardcore::MBLoadCell::receive ( T * buf)
protected

Wrapper to the serial receive method. This also sets the control pins to enable the receiver mode.

Parameters
bufThe pointer to the buffer in which the data received will be stored.

Definition at line 298 of file MBLoadCell.cpp.

◆ receiveASCII()

std::string Boardcore::MBLoadCell::receiveASCII ( )
protected

Wrapper to the serial recvString method. This also sets the control pins to enable the receiver mode.

Returns
The message received.

Definition at line 284 of file MBLoadCell.cpp.

◆ resetMaxMinWeights()

void Boardcore::MBLoadCell::resetMaxMinWeights ( )

Permits to reset the peak weight value.

Definition at line 116 of file MBLoadCell.cpp.

◆ sampleAsciiModTd()

MBLoadCellData Boardcore::MBLoadCell::sampleAsciiModTd ( void )
protected

Sampling in the "ASCII Mod Td" mode.

Definition at line 220 of file MBLoadCell.cpp.

◆ sampleContModT()

MBLoadCellData Boardcore::MBLoadCell::sampleContModT ( void )
protected

Sampling in the "continuous Mod T" mode.

Definition at line 204 of file MBLoadCell.cpp.

◆ sampleContModTd()

MBLoadCellData Boardcore::MBLoadCell::sampleContModTd ( void )
protected

Sampling in the "continuous Mod Td" mode.

Definition at line 212 of file MBLoadCell.cpp.

◆ sampleImpl()

MBLoadCellData Boardcore::MBLoadCell::sampleImpl ( )
overrideprotectedvirtual

Requests the weight sampled from the load cell or waits for a sample depending on the mode selected (it's a blocking function).

Returns
The weight measured from the load cell.

Implements Boardcore::Sensor< MBLoadCellData >.

Definition at line 158 of file MBLoadCell.cpp.

◆ selfTest()

bool Boardcore::MBLoadCell::selfTest ( )
overridevirtual

Check if the sensor is working.

Returns
boolean indicating whether the sensor is correctly working or not

Implements Boardcore::AbstractSensor.

Definition at line 156 of file MBLoadCell.cpp.

◆ transmitASCII()

void Boardcore::MBLoadCell::transmitASCII ( const std::string & buf)
protected

Wrapper to the serial sendString method. This also sets the control pins to enable the transmission mode.

Parameters
bufThe message to send.

Definition at line 275 of file MBLoadCell.cpp.


The documentation for this class was generated from the following files: