Example : ADC

ADC components of OSS-EC

The ADC component of the OSS-EC is used as an example here. BSL00000057 is described as an example program.

  • Block diagram of ADC components architecture and OSS-EC architecture ( fig 1. )
  • ADC component state flow ( fig 2. )
  • API ( fig 3. )

Blue label characters are data related to User-defined.
Green label characters are data related to model number.

BSL00000057 Features

– Component typeADC component
– Number of Components Single
– Supported OS (HAL)Arduino
– CalculationFloating-point
– Conversion typeLinear
– Moving average filterMoving average filter select ( Non,SMA,EMA,WMA )
– DiagnosisRange (Min to Max)

Example download

An example using NXP’s MPXA4250A can be downloaded below.

physical value
aiA/D conversion value
vi Sensor output voltage value
VddSensor supply voltage(ADC_vdd) value
ADC_bitA/D conversion bit length
PPProgram of OSS-EC
MPMicrocontroller unit program
ADC unit program
ai = f(ch)
CP      
Circuit/IC components program
Conversion formula from circuit output voltage to sensor output signal value
vi = f(ai)
SP      System components program
Conversion formula from sensor output signal value to physical value
y = f(vi)

The conversion formula for vi shall be as follows.

vi = f(ai) = ai * ADC_vdd / ( 2ADC_bit )

ADC_Vdd Sensor supply voltage [V]
ADC_bitADC conversion of MPU Bit number

The conversion formula for y is as follows. ( Liner conversion )
Let it be a linear transformation equation.

y = f(vi) = ( vi – x_offset ) / gain + y_offset range min to max

x_offsetSensor output voltage offset value [V]
gainVoltage value to physical value conversion gain
y_offsetPhysical offset value
minPhysical value min
maxPhysical value max

Software Option

Moving average select

#defineiMAiSMASimple moving average filter
phy = ( yn + yn-1 + yn-2 … ) / n
n : iABCDEF_SMA_num
#defineiMAiEMAExponential moving average filter
phy = ( y × k ) + ( phyn-1 × ( 1 – k ) )
k :  iABCDEF_EMA_K
#defineiMAiWMAWeighted moving average filter
phy = ( ( yn × 1 ) + ( yn-1 × 2 ) + ( yn-2 × 3 ) … ) / ( 1 + 2 + 3 … )
n : iABCDEF_WMA_num
#defineiMAiNonMANon-moving average  filter
typedef struct
{
uint32sts;// Diagnosis result of range min to max
float32phy;// Sensor physical value
}pp2ap_adc_t;

sts Normal = iNormal, Over Max = iMax_NG, Under Min = iMin_NG

OSS-EC Site