MAX11410 high speed 24-bit Delta-Sigma ADC
Dependents: MAX11410BOB_24bit_ADC MAX11410BOB_Serial_Tester
Diff: MAX11410.cpp
- Revision:
- 5:a2e74357cfc0
- Parent:
- 4:c169ba85d673
- Child:
- 8:3a9dfa2e8234
--- a/MAX11410.cpp Tue Jan 07 23:47:41 2020 +0000 +++ b/MAX11410.cpp Fri Jan 10 01:54:39 2020 +0000 @@ -423,6 +423,10 @@ VRef_AVDD = 3.300; //---------------------------------------- + // RTD Resistance measurement; Thermocouple Cold Junction, in Ohms + rtd_resistance = 1000.0; + + //---------------------------------------- // Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C RTD_Temperature = 25.0; @@ -1624,7 +1628,7 @@ } //---------------------------------------- -// Menu item 'RM' +// Menu item 'R' -> rtd_resistance, RTD_Temperature // Trigger Measurement for Resistive Temperature Device (RTD). // // Example code for typical RTD measurement. @@ -1635,16 +1639,14 @@ // @param[in] rtd_ainp = channel RTD high side sense, default=AINP_SEL_1000_AIN8 // @param[in] rtd_ainn = channel RTD low side, default=AINN_SEL_1001_AIN9 // @post AINcode[rtd_ainp]: measurement result LSB code +// @post rtd_resistance: measurement result resistance in Ohms +// @post RTD_Temperature: Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C // // @return resistance calculated from raw LSB code and reference resistance double MAX11410::Measure_RTD(MAX11410_AINP_SEL_enum_t rtd_iout, MAX11410_AINP_SEL_enum_t rtd_ainp, MAX11410_AINN_SEL_enum_t rtd_ainn) { //---------------------------------------- - // warning -- WIP work in progress - #warning "Not Implemented Yet: MAX11410::Measure_RTD..." - - //---------------------------------------- // write8 0x08 FILTER = 0x34 to select RATE_0100, LINEF_11_SINC4 60SPS (given CONV_TYPE_01_Continuous) Configure_FILTER((uint8_t) /* MAX11410::MAX11410_LINEF_enum_t:: */ LINEF_11_SINC4, (uint8_t) /* MAX11410::MAX11410_RATE_enum_t:: */ RATE_0100); @@ -1686,44 +1688,36 @@ data0 = AINcode[((int)rtd_ainp & 0x0F)]; //---------------------------------------- - // warning -- WIP work in progress - #warning "Measure_RTD need calculate RTD return value from raw data, return R/RREF? R? T(R,R0)?" - - //---------------------------------------- - // ideal voltage calculated from raw LSB code and VRef_REF1 reference resistance in ohms - double Rx = VoltageOfCode(AINcode[((int)rtd_ainp & 0x0F)]); - // TODO: calculate temperature from the measured resistance Rx - return Rx; + // resistance calculated from raw LSB code and VRef_REF1 reference resistance in ohms + rtd_resistance = VoltageOfCode(AINcode[((int)rtd_ainp & 0x0F)]); + TemperatureOfRTD_PT1000(rtd_resistance); // calculate RTD_Temperature + return rtd_resistance; } //---------------------------------------- -// Menu item 'RT' // Return the physical temperature corresponding to measured resistance // of a PT1000 type Resistive Temperature Device (RTD). // // @param[in] rtd_resistance = RTD resistance in ohms, default=1000 +// @post RTD_Temperature: Temperature calculated from RTD Resistance; Thermocouple Cold Junction, in degrees C // // @return ideal temperature in degrees C, calculated from RTD resistance in ohms -// @test TemperatureOfRTD_PT1000(842.94) expect -40.0 within 0.1 PT-1000 RTD at -40C -// @test TemperatureOfRTD_PT1000(1000.0) expect 0.0 within 0.1 PT-1000 RTD at 0C -// @test TemperatureOfRTD_PT1000(1097.3) expect 25.0 within 0.1 PT-1000 RTD at 25C -// @test TemperatureOfRTD_PT1000(1328.1) expect 85.0 within 0.1 PT-1000 RTD at 85C -// @test TemperatureOfRTD_PT1000(1479.5) expect 125.0 within 0.1 PT-1000 RTD at 125C +// @test group RTD_PT1000 TemperatureOfRTD_PT1000(842.94) expect -40.0 within 0.1 PT-1000 RTD at -40C +// @test group RTD_PT1000 TemperatureOfRTD_PT1000(1000.0) expect 0.0 within 0.1 PT-1000 RTD at 0C +// @test group RTD_PT1000 TemperatureOfRTD_PT1000(1097.3) expect 25.0 within 0.1 PT-1000 RTD at 25C +// @test group RTD_PT1000 TemperatureOfRTD_PT1000(1328.1) expect 85.0 within 0.1 PT-1000 RTD at 85C +// @test group RTD_PT1000 TemperatureOfRTD_PT1000(1479.5) expect 125.0 within 0.1 PT-1000 RTD at 125C // double MAX11410::TemperatureOfRTD_PT1000(double rtd_resistance) { //---------------------------------------- - // warning -- WIP work in progress - #warning "Not Tested Yet: MAX11410::TemperatureOfRTD_PT1000..." - - //---------------------------------------- // Temperature from RTD Resistance maths // ITS-90 PT-1000 RTD double R0 = 1000.0; double a = 3.9083e-3; double b = -5.7750e-7; - // TODO: calculate T from R and R0 + // calculate T from R and R0 double sqrtTerm = sqrt(R0*R0 * a*a - 4*R0*b*(R0 - rtd_resistance)); double denominator = 2 * R0 * b; RTD_Temperature = ((-R0 * a) + (sqrtTerm)) / denominator; @@ -1858,14 +1852,10 @@ { //---------------------------------------- - // warning -- WIP work in progress - #warning "Not Tested Yet: MAX11410::TemperatureOfTC_TypeK..." - - //---------------------------------------- // Temperature from TC_TypeK voltage maths - // TODO: define standard TC_TypeK coefficients + // define standard TC_TypeK coefficients // ITS-90 Thermocouple Inverse Polynomial for a Type K thermocouple - // TODO: calculate deltaT from tc_voltage + // calculate deltaT from tc_voltage // // Voltage range -5891uV < tc_voltage < 0uV, // Temperature Range -200 deg C to 0 deg C