Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AD7791
CN0216 Class Reference
EVAL-CN0216 weigh scale measurement shield. More...
#include <CN0216.h>
Public Types | |
| enum | CalibrationStep_t { ZERO_SCALE_CALIBRATION, FULL_SCALE_CALIBRATION, COMPUTE_UNITS_PER_BIT } |
Public Member Functions | |
| CN0216 (PinName CSAD7791=D8, PinName MOSI=SPI_MOSI, PinName MISO=SPI_MISO, PinName SCK=SPI_SCK) | |
| CN0216 constructor. | |
| void | init (float cal_weight=_DEFAULT_CAL_WEIGHT, uint8_t mode_val=_DEFAULT_MODE_VAL, uint8_t filter_val=_DEFAULT_FILTER_VAL) |
| Initializes the mode and filter values of the AD7791 and sets the weight to be used in calibration. | |
| void | calibrate (CalibrationStep_t cal) |
| Calibrates the CN0216 weigh scale. | |
| float | compute_weight (uint32_t data) |
| Computes the weight based on the formula weight = (data - zeroscale) * weight_units_per_bit. | |
| uint32_t | read_u32 () |
| Reads the AD7791. | |
| float | read_weight () |
| Reads the ADC and computes the weight based on the formula described above. | |
Detailed Description
EVAL-CN0216 weigh scale measurement shield.
Definition at line 58 of file CN0216.h.
Member Enumeration Documentation
| enum CalibrationStep_t |
Constructor & Destructor Documentation
| CN0216 | ( | PinName | CSAD7791 = D8, |
| PinName | MOSI = SPI_MOSI, |
||
| PinName | MISO = SPI_MISO, |
||
| PinName | SCK = SPI_SCK |
||
| ) |
CN0216 constructor.
- Parameters:
-
CSAD7791 - Chipselect of the AD7791 MOSI - MOSI line of the SPI bus MISO - MISO line of the SPI bus SCK - SCK line of the SPI bus
Definition at line 60 of file CN0216.cpp.
Member Function Documentation
| void calibrate | ( | CalibrationStep_t | cal ) |
Calibrates the CN0216 weigh scale.
- Parameters:
-
cal - calibration step. Step CN0216::ZERO_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the minimum as value for the zero scale Step CN0216::FULL_SCALE_CALIBRATION will take CN0216::_NUMBER_OF_SAMPLES samples and use the average as value for the full scale Step COMPUTE_UNITS_PER_BIT will compute the grams per bit used in weight computation.
Definition at line 94 of file CN0216.cpp.
| float compute_weight | ( | uint32_t | data ) |
Computes the weight based on the formula weight = (data - zeroscale) * weight_units_per_bit.
- Parameters:
-
data read from the ADC
- Returns:
- weight based on data
Definition at line 134 of file CN0216.cpp.
| void init | ( | float | cal_weight = _DEFAULT_CAL_WEIGHT, |
| uint8_t | mode_val = _DEFAULT_MODE_VAL, |
||
| uint8_t | filter_val = _DEFAULT_FILTER_VAL |
||
| ) |
Initializes the mode and filter values of the AD7791 and sets the weight to be used in calibration.
- Parameters:
-
cal_weight - weight used in calibration mode_val - value of the mode register filter_val - value of the filter register
Definition at line 74 of file CN0216.cpp.
| uint32_t read_u32 | ( | ) |
| float read_weight | ( | ) |
Reads the ADC and computes the weight based on the formula described above.
- Returns:
- weight
Definition at line 156 of file CN0216.cpp.
Generated on Wed Jul 13 2022 06:22:05 by
1.7.2
CN0216 - Weight Scale