MP Type | ADC |
OS Type | Multi-Thread Mbed , etc |
Calculation accuracy | integer calculation |
Characteristic Conversion | Non-linear conversion(Two-dimensional table method) |
Filter | Weighted Moving Average ( WMA ) |
Diagnostics | Non |
Software Specifications

Caution)
Please note that the return value of the Mbed read_u16 function may be MSB-padded or LSB-packed. The adc_read_u16_wrapper function assumes LSB packing.
File ( Mbed C++)
main.cpp | application source code file |
pcmp.cpp | ADC Component source code file |
pcmp.h | ADC Component header file |
oss-ec.h | OSS-EC header file |
Source Code
- Constants for components Constants to match the component
- Constants for MPU Constants to match the microcontroller of the product
- Constants for circuits Constants to match the circuit of the product
// BCL No.00000028
// Interger constant
#define iInt_const 256U // Interger constant
// Filter definitions
#define iWMA_num 4U // Weighted moving average number
// MPU definitions
#define iADC_bit 16U // MPU ADC bit
// CAUTION : When Mbed is selected, 16 bit is fixed
#define iPIN_adc A0 // MPU Port Pin (ADC)
// P-CMP ( Sysyem Parts , Circuit , IC ) definitions
// Model type System Parts definitions
#define iData_num 5U // Number of characteristic table elements
const sint32 Data_x[iData_num] = // X axis for table search : Voltage [mV]
{
0 , 500 , 1000 , 1500 , 2000 // X data
};
const sint32 Data_y[iData_num] = // Y axis for table search : Physical [unit]
{
10 , 15 , 30 , 50 , 100 // Y data
};
// Circuit definitions
#define iADC_vdd 3300U // MPU Vdd [mV]
#define iK_tc ( 1*iInt_const ) // Circuit Transformation ratio
sint32 Phy_Read( void )
{
return( pcmp() );
}
static sint32 pcmp( void )
{
uint16 ai = mp(); // A/D value read
uint16 vi = cp( ai ); // A/D value to Voltage value conversion
sint32 phy = sp( vi ); // Voltage value to Physical value
return( phy );
}
static sint32 sp( uint16 vi )
{
// Voltage value to Physical value conversion
sint32 wk = lib_s32_Tbl2D( vi , &Tbl );
// Physical value Weighted Moving Average calculation
wk = lib_s32_WMA( wk , &Phy_WMA );
return( wk );
}
static uint16 cp( uint16 ai )
{
// A/D value to Voltage value conversion
uint16 wk = (uint16)mac_UpLmt( (uint32)ai * iK_tc / iInt_const , iUint16_Max );
return( wk );
}
static uint16 mp( void )
{
uint16 wk;
// Read A/D convension value
uint8 sts = adc_read_u16_wrapper( an , &wk );
return( wk );
}