Manuel Caballero / ADS1231

Dependents:   weightscale Projet-BTS-balance Programme_Final_V6

Embed: (wiki syntax)

« Back to documentation index

ADS1231 Class Reference

ADS1231 Class Reference

Example: More...

#include <ADS1231.h>

Public Types

enum  ADS1231_data_output_status_t { ADS1231_DATA_BUSY = 0, ADS1231_DATA_READY = 1 }
 

READY/BUSY DATA.

More...
enum  ADS1231_scale_t { ADS1231_SCALE_kg = 0, ADS1231_SCALE_g = 1, ADS1231_SCALE_mg = 2, ADS1231_SCALE_ug = 3 }
 

SCALE.

More...

Public Member Functions

 ADS1231 (PinName SCLK, PinName DOUT)
 Create an ADS1231 object connected to the specified pins.
 ~ADS1231 ()
 Delete ADS1231 object.
ADS1231_status_t ADS1231_Reset (void)
 It performs an internal reset.
ADS1231_status_t ADS1231_PowerDown (void)
 It puts the device into power-down mode.
ADS1231_status_t ADS1231_ReadRawData (Vector_count_t *myNewRawData, uint32_t myAverage)
 It reads raw data from the device.
ADS1231_status_t ADS1231_ReadData_WithCalibratedMass (Vector_count_t *myNewRawData, uint32_t myAverage)
 It reads raw data with an user-specified calibrated mass.
ADS1231_status_t ADS1231_ReadData_WithoutMass (Vector_count_t *myNewRawData, uint32_t myAverage)
 It reads raw data without any mass.
ADS1231_status_t ADS1231_SetAutoTare (float myCalibratedMass, ADS1231_scale_t myScaleCalibratedMass, Vector_count_t *myNewRawData, float myTime)
 It reads raw data without any mass after the system is calibrated.
Vector_count_t ADS1231_SetManualTare (float myTareWeight)
 It sets a tare weight manually.
Vector_mass_t ADS1231_CalculateMass (Vector_count_t *myNewRawData, float myCalibratedMass, ADS1231_scale_t myScaleCalibratedMass)
 It calculates scaled data.
Vector_voltage_t ADS1231_CalculateVoltage (Vector_count_t *myNewRawData, float myVoltageReference)
 It calculates voltage data.

Detailed Description

Example:

include "mbed.h" include "ADS1231.h"

ADS1231 myWeightSensor ( p5, p6 ); Serial pc ( USBTX, USBRX );

Ticker newReading; DigitalOut myled1 ( LED1 ); DigitalOut myled2 ( LED2 ); DigitalOut myled3 ( LED3 ); DigitalOut myled4 ( LED4 );

ADS1231::ADS1231_status_t aux; ADS1231::Vector_count_t myData; ADS1231::Vector_mass_t myCalculatedMass; ADS1231::Vector_voltage_t myCalculatedVoltage;

void readDATA ( void ) { myled4 = 1;

aux = myWeightSensor.ADS1231_ReadRawData ( &myData, 4 ); myCalculatedMass = myWeightSensor.ADS1231_CalculateMass ( &myData, 1.0, ADS1231::ADS1231_SCALE_kg ); myCalculatedVoltage = myWeightSensor.ADS1231_CalculateVoltage ( &myData, 5.0 );

pc.printf( "Raw Data: %ld Mass: %0.5f kg Voltage: %0.5f mV\r\n", (uint32_t)myData.myRawValue, myCalculatedMass.myMass, 1000*myCalculatedVoltage.myVoltage );

myled4 = 0; }

int main() { pc.baud ( 115200 );

Reset and wake the device up aux = myWeightSensor.ADS1231_PowerDown (); aux = myWeightSensor.ADS1231_Reset (); wait(1);

CALIBRATION time start! 1. REMOVE THE MASS ON THE LOAD CELL ( ALL LEDs OFF ). Read data without any mass on the load cell aux = myWeightSensor.ADS1231_ReadData_WithoutMass ( &myData, 4 );

myled1 = 1; wait(3);

2. PUT A KNOWN MASS ON THE LOAD CELL ( JUST LED1 ON ). Read data with an user-specified calibration mass aux = myWeightSensor.ADS1231_ReadData_WithCalibratedMass ( &myData, 4 ); CALIBRATION time end!

[ OPTIONAL ] REMOVE THE MASS ON THE LOAD CELL ( JUST LED2 ON ). Read the device without any mass to calculate the tare weight for 5 seconds myled1 = 0; myled2 = 1; wait(3); myled2 = 0;

Calculating the tare weight ( JUST LED3 ON ) myled3 = 1; aux = myWeightSensor.ADS1231_SetAutoTare ( ADS1231::ADS1231_SCALE_kg, &myData, 5 ); myled3 = 0;

newReading.attach( &readDATA, 0.5 ); // the address of the function to be attached ( readDATA ) and the interval ( 0.5s ) ( JUST LED4 BLINKING )

Let the callbacks take care of everything while(1) { sleep(); } }

Library for the ADS1231 24-Bit Analog-to-Digital Converter for Bridge Sensors.

Definition at line 108 of file ADS1231.h.


Member Enumeration Documentation

READY/BUSY DATA.

Enumerator:
ADS1231_DATA_BUSY 

ADS1231 data is NOT ready to be read.

ADS1231_DATA_READY 

ADS1231 data is ready to be read.

Definition at line 114 of file ADS1231.h.

SCALE.

Enumerator:
ADS1231_SCALE_kg 

ADS1231 Scale in kg.

ADS1231_SCALE_g 

ADS1231 Scale in g.

ADS1231_SCALE_mg 

ADS1231 Scale in mg.

ADS1231_SCALE_ug 

ADS1231 Scale in ug.

Definition at line 124 of file ADS1231.h.


Constructor & Destructor Documentation

ADS1231 ( PinName  SCLK,
PinName  DOUT 
)

Create an ADS1231 object connected to the specified pins.

ADS1231.h.

Parameters:
sclkADS1231 Power down control (high active) and serial clock input
doutADS1231 Serial data output

24-Bit Analog-to-Digital Converter for Bridge Sensors. Function file.

Returns:
NA
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN
Precondition:
This code belongs to Nimbus Centre ( http://www.nimbus.cit.ie ).

Definition at line 20 of file ADS1231.cpp.

~ADS1231 (  )

Delete ADS1231 object.

Definition at line 28 of file ADS1231.cpp.


Member Function Documentation

ADS1231::Vector_mass_t ADS1231_CalculateMass ( Vector_count_t *  myNewRawData,
float  myCalibratedMass,
ADS1231_scale_t  myScaleCalibratedMass 
)

It calculates scaled data.

ADS1231_CalculateMass ( Vector_count_t* myNewRawData, uint32_t myCalibratedMass, ADS1231_scale_t myScaleCalibratedMass )

It calculates the mass.

Parameters:
[in]myNewRawData,:It has myRawValue_WithCalibratedMass ( ADC code taken with calibrated mass ), myRawValue_WithoutCalibratedMass ( ADC code taken without any mass ) and myRawValue ( the current data taken by the system ).
[in]myCalibratedMass,:A known value for the calibrated mass when myRawValue_WithCalibratedMass was calculated.
[in]myScaleCalibratedMass,:The range of the calibrated mass ( kg, g, mg or ug ).
[out]NaN.
Returns:
The calculated mass.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 293 of file ADS1231.cpp.

ADS1231::Vector_voltage_t ADS1231_CalculateVoltage ( Vector_count_t *  myNewRawData,
float  myVoltageReference 
)

It calculates voltage data.

ADS1231_CalculateVoltage ( Vector_count_t* ,float )

It calculates the mass.

Parameters:
[in]myNewRawData,:myRawValue ( the current data taken by the system ).
[in]myVoltageReference,:The voltage at the converter reference input.
[out]NaN.
Returns:
The calculated voltage.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 469 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_PowerDown ( void   )

It puts the device into power-down mode.

ADS1231_PowerDown ( void )

It puts the device in power-down mode.

Parameters:
[in]NaN.
[out]NaN.
Returns:
Status of ADS1231_PowerDown.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
When SCLK pin changes from low to high and stays at high for longer than 26μs, ADS1231 enters power down mode.
Warning:
NaN.

Definition at line 93 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_ReadData_WithCalibratedMass ( Vector_count_t *  myNewRawData,
uint32_t  myAverage 
)

It reads raw data with an user-specified calibrated mass.

ADS1231_ReadData_WithCalibratedMass ( Vector_count_t* myNewRawData, uint32_t myAverage )

It reads data with a calibrated mass on the load cell.

Parameters:
[in]myAverage,:How many data to read.
[out]myNewRawData,:myRawValue_WithCalibratedMass ( ADC code taken with calibrated mass ).
Returns:
Status of ADS1231_ReadData_WithCalibratedMass.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 208 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_ReadData_WithoutMass ( Vector_count_t *  myNewRawData,
uint32_t  myAverage 
)

It reads raw data without any mass.

ADS1231_ReadData_WithoutMass ( Vector_count_t* myNewRawData, uint32_t myAverage )

It reads data without any mass on the load cell.

Parameters:
[in]myAverage,:How many data to read.
[out]myNewRawData,:myRawValue_WithoutCalibratedMass ( ADC code taken without any mass ).
Returns:
Status of ADS1231_ReadData_WithoutMass.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 248 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_ReadRawData ( Vector_count_t *  myNewRawData,
uint32_t  myAverage 
)

It reads raw data from the device.

ADS1231_ReadRawData ( Vector_count_t*, uint32_t )

It reads the raw data from the device.

Parameters:
[in]myAverage,:How many measurement we have to get and deliver the average.
[out]myNewRawData,:The new value from the device.
Returns:
Status of ADS1231_ReadRawData.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 127 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_Reset ( void   )

It performs an internal reset.

ADS1231_Reset ( void )

It performs an internal reset.

Parameters:
[in]NaN.
[out]NaN.
Returns:
Status of ADS1231_Reset.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
When SCLK pin changes from low to high and stays at high for longer than 26μs, ADS1231 enters power down mode.

When SCLK returns to low, chip will reset and enter normal operation mode.

Warning:
NaN.

Definition at line 57 of file ADS1231.cpp.

ADS1231::ADS1231_status_t ADS1231_SetAutoTare ( float  myCalibratedMass,
ADS1231_scale_t  myScaleCalibratedMass,
Vector_count_t *  myNewRawData,
float  myTime 
)

It reads raw data without any mass after the system is calibrated.

ADS1231_SetAutoTare ( float ,ADS1231_scale_t ,Vector_count_t* ,float )

It reads data without any mass on the load cell after the system is calibrated to calculate the tare weight.

Parameters:
[in]myCalibratedMass,:A known value for the calibrated mass when myRawValue_WithCalibratedMass was calculated.
[in]myScaleCalibratedMass,:The range of the calibrated mass ( kg, g, mg or ug ).
[in]myTime,:How long the auto-set lasts.
[out]myNewRawData,:myRawValue_TareWeight ( ADC code taken without any mass ).
Returns:
Status of ADS1231_SetAutoTare.
Author:
Manuel Caballero
Date:
18/September/2017
Version:
18/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 378 of file ADS1231.cpp.

ADS1231::Vector_count_t ADS1231_SetManualTare ( float  myTareWeight )

It sets a tare weight manually.

ADS1231_SetManualTare ( float myTareWeight )

It sets a tare weight manually.

Parameters:
[in]myTareWeight,:Tare weight.
[out]NaN.
Returns:
myRawValue_TareWeight.
Author:
Manuel Caballero
Date:
12/September/2017
Version:
12/September/2017 The ORIGIN
Precondition:
NaN.
Warning:
NaN.

Definition at line 435 of file ADS1231.cpp.