Seeking more information on NRF52833 ADC, reference, and buffers

Hi,

We are developing a product which is reading RTDs and thermistors from the NRF52833's internal ADC. We're working on compensating for the intrinsic errors of the ADC and gain buffers and have some questions not covered in the product specifications.

Do the ADC gain buffers have offsets associated with them? The datasheet says the ADC has an intrinsic offset of ±2LSB @ 10bit res but doesn't mention whether there are voltage offsets associated with the buffers.

Is there any procedure to internally determine the ADC buffer gains? For example, connecting the buffer inputs directly to the reference voltage?

Can you provide any more detail on what the ADC's internal calibration routine does or what it accounts for?

Are there any details on how the ADC input buffer gain is implemented?

Are there any specs on channel isolation in sequential measurement mode?

Is there a spec for temperature drift of the VDDH/5 divider?

Thank you!

Parents
  • Sorry, another question:

    In Product Spec v1.7, section 6.21.2.3 (SAADC Scan mode) it says "The time it takes to sample all channels is less than the sum of the conversion time of all enabled channels. The conversion time for a channel is defined as the sum of the acquisition time tACQ and the conversion time tCONV."

    Why is the total conversion time less than the sum of the channels? What is skipped? What is the expected conversion time?

    Thanks

  • Do the ADC gain buffers have offsets associated with them? The datasheet says the ADC has an intrinsic offset of ±2LSB @ 10bit res but doesn't mention whether there are voltage offsets associated with the buffers.

    1) The input buffer of the ADC has auto-zero for offset. The offset of the ADC core should be scaled with the gain. 

    Is there any procedure to internally determine the ADC buffer gains? For example, connecting the buffer inputs directly to the reference voltage?

    2) Only for VDD as reference. There is an undocumented TASKS_CALIBRATEGAIN that connects the input to VDD/4 and uses gain 1/4

    Can you provide any more detail on what the ADC's internal calibration routine does or what it accounts for?

    3) The offset shorts the ADC input, and then a digital feedback loop tunes a current DAC in the SAR comparator to compensate for the offset. The offset may introduce a noise component if the TASKS_CALIBRATEOFFSET is triggered often

    Are there any details on how the ADC input buffer gain is implemented?

    4) Sorry, no details, but it's a switched capacitor gain stage with high common mode rejection. 

    Are there any specs on channel isolation in sequential measurement mode?

    5) There is only one core ADC, the muxing is done through T-gates (transmission gate, pull down, transmission gate), so there should be very little cross coupling between channels. 

    Is there a spec for temperature drift of the VDDH/5 divider?

    6) No, but it's a resistive divider, as such, as long as the ADC input settles, should not change with temperature (although the resistors do change with temperature, the relative size does not). The ADC temperature coefficient will dominate.

    jdub said:
    Also - any details on the accuracy of the internal VDD/4 divider which can be used as an ADC reference? We are also finding that when using the VDD/4 reference, our signals are much noisier. Any specs on that noise or advice for reducing it?

    7)  The noise that you're seeing is probably coming from VDD. There is a low pass filter inside the ADC, but that is in the MHz range. 

    jdub said:
    Is the VDDH/5 input only enabled when REG0 is on? I'm working on a device where VDDH and VDD are tied together. The 1% spec on the VDDH/5 divider is better than the 3% spec on the ADC's input gain buffers, so I have been trying to use the VDDH5 input. But it behaves like it's floating (the reading seems arbitrary and the value decreases with sample rate, implying a loading effect)

    8) That does not matter. VDDH/5 divider goes to the input gain buffers. I'm not sure it's enabled without the 5V regulator is enabled.

    jdub said:
    Does the ADC sequence converter fail if you use the CH[X}.CONFIG register's RESP and RESN settings to set inputs at VDD/2 while setting CH[X}.PSEL and NSEL to Not Connected? I can take a valid measurement in this configuration if I sample as a one-off, but if I make this measurement part of a sequence the ADC never finishes.

    9) You need to enable the PSEL/NSEL, but not connect them to anything. Try writing 0xFE to both.

    jdub said:

    In Product Spec v1.7, section 6.21.2.3 (SAADC Scan mode) it says "The time it takes to sample all channels is less than the sum of the conversion time of all enabled channels. The conversion time for a channel is defined as the sum of the acquisition time tACQ and the conversion time tCONV."

    Why is the total conversion time less than the sum of the channels? What is skipped? What is the expected conversion time?

    10) Not sure why it's written like this as it's very confusing. We expect the conversion time to be N x (TACQ + t_conv).

  • Could you clarify the specific resistance range (at min to max temperature) of the RTD you are measuring?

  • jdub said:
    Direct ADC question:
    The INL is listed as 4.7 bits, which is quite significant. Do you have any sense of whether the error at a given part of the transfer function is stable, or does it shift with time/temperature/supply voltage? Ie. Can we characterize the non-linearity for a given part and rely on that profile to calibrate future readings?

    In 12bit mode the INL is 4.7 LSBs, not bits. In 10-bit mode its around 1 LSB. The errors will likely be systematic. It is possible to compensate for some of the effects, however, it does require per device calibration. For example https://ieeexplore.ieee.org/document/7993659

    jdub said:
    Do you have any application notes related to reading a RTD or other high precision, low sensitivity resistance sensor?

    No, sorry

    jdub said:
    In our application we are very space constrained and must do so with a simple voltage divider setup, with a fixed resistor on top and temperature sensor on bottom. By taking differential measurements with the same gain settings across the different legs of the voltage divider, we can cancel out any tolerance errors on the references or gains of the ADC and buffers. But our final temperature reading still has more error than we expect, so we are trying to find ways to improve it.

    If you're using resistive input it's important that you select a TACQ that is long enough compared to the source impedance, see the product specification. 

  • > In 12bit mode the INL is 4.7 LSBs, not bits.

    You're right, that was just a typo on my part, I wasn't making my calculations with 2^4.7 = 26 LSB of noise Laughing

    > If you're using resistive input it's important that you select a TACQ that is long enough compared to the source impedance, see the product specification. 

    Yes our input impedance is <1kOhm which is very low, so we can use a short acquisition time. But we have found that extending it out to the maximum makes no difference on this measurement.

    Thank you!

  • The nRF52833 supports both 4-wire and 3-wire RTD modes on the SAADC, and the performance is better than the discussions above indicate. The trick is to use ratiometric measurements, and assuming no space for large S/H caps this can be done with a single reference resistor - typically mid-range say 2k0 - and a single 100nF capacitor (2 capacitors are better). Performance is within a few Ohms. No SAADC calibration is required due to the ratiometric measurement. 14-bit mode gives the best results, though 12-bit is almost as good. Sampling time of 10uSecs works fine, though if the remote lead length to the RTD is capacitive a longer setup time for the excitation may be required. Current is VDD dependent, but again ratiometric mode removes any issues with that.

    These results are using a noisy USB as power source; even better results if operating on a battery. This test is with current flowing from RTD to Reference and then reverse current through RTD and reference and the results would be averaged. Using both current directions removes long-term DC offset which avoids other issues. Current is off except during measurement.

    Edit: I decided to use two 100nF capacitors; if you have room on the board this improves the readings. I updated my schematic and code to clarify.

    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2980mV,  919 uA,  170 Ohm,  137 Ohm, 2823mV, 1982mV, 1982mV,  126mV,  477 counts, 1054 counts,  911 Ohms  0.22%
    // RTD 2977mV,  919 uA,  179 Ohm,  140 Ohm, 2812mV, 1976mV, 1983mV,  129mV,  476 counts, 1054 counts,  909 Ohms  0.00%
    // RTD 2984mV,  921 uA,  175 Ohm,  136 Ohm, 2822mV, 2006mV, 1980mV,  126mV,  477 counts, 1056 counts,  909 Ohms  0.00%
    // RTD 2966mV,  919 uA,  156 Ohm,  137 Ohm, 2822mV, 1988mV, 1981mV,  126mV,  475 counts, 1053 counts,  908 Ohms -0.11%
    // RTD 2982mV,  920 uA,  168 Ohm,  145 Ohm, 2827mV, 1982mV, 1991mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2980mV,  920 uA,  169 Ohm,  145 Ohm, 2824mV, 1981mV, 1982mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2975mV,  920 uA,  161 Ohm,  145 Ohm, 2826mV, 1982mV, 1986mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2980mV,  920 uA,  169 Ohm,  139 Ohm, 2824mV, 2000mV, 1973mV,  128mV,  476 counts, 1055 counts,  908 Ohms -0.11%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2976mV,  919 uA,  130 Ohm,  173 Ohm,  120mV,  969mV,  973mV, 2817mV,  475 counts, 1053 counts,  908 Ohms -0.11%
    // RTD 2976mV,  919 uA,  139 Ohm,  175 Ohm,  128mV,  962mV,  967mV, 2815mV,  474 counts, 1053 counts,  906 Ohms -0.33%
    // RTD 2982mV,  917 uA,  138 Ohm,  175 Ohm,  127mV,  965mV,  971mV, 2821mV,  475 counts, 1051 counts,  910 Ohms  0.11%
    // RTD 2975mV,  917 uA,  131 Ohm,  174 Ohm,  121mV,  966mV,  968mV, 2815mV,  475 counts, 1051 counts,  910 Ohms  0.11%
    // RTD 2976mV,  917 uA,  133 Ohm,  167 Ohm,  122mV,  970mV,  967mV, 2822mV,  474 counts, 1051 counts,  908 Ohms -0.11%
    // RTD 2982mV,  918 uA,  143 Ohm,  183 Ohm,  132mV,  976mV,  958mV, 2814mV,  475 counts, 1052 counts,  909 Ohms  0.00%
    // RTD 2971mV,  918 uA,  141 Ohm,  167 Ohm,  130mV,  965mV,  963mV, 2817mV,  475 counts, 1052 counts,  909 Ohms  0.00%
    // RTD 2981mV,  919 uA,  140 Ohm,  168 Ohm,  129mV,  962mV,  966mV, 2826mV,  476 counts, 1053 counts,  910 Ohms  0.11%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2973mV,  920 uA,  168 Ohm,  133 Ohm, 2818mV, 1987mV, 1983mV,  123mV, 1901 counts, 4217 counts,  907 Ohms -0.22%
    // RTD 2974mV,  919 uA,  173 Ohm,  141 Ohm, 2815mV, 1978mV, 1971mV,  130mV, 1901 counts, 4215 counts,  908 Ohms -0.11%
    // RTD 2968mV,  918 uA,  155 Ohm,  137 Ohm, 2825mV, 1985mV, 1981mV,  126mV, 1900 counts, 4210 counts,  908 Ohms -0.11%
    // RTD 2969mV,  917 uA,  162 Ohm,  145 Ohm, 2820mV, 1978mV, 1976mV,  133mV, 1897 counts, 4207 counts,  908 Ohms -0.11%
    // RTD 2973mV,  919 uA,  157 Ohm,  139 Ohm, 2828mV, 1980mV, 1977mV,  128mV, 1899 counts, 4213 counts,  907 Ohms -0.22%
    // RTD 2973mV,  919 uA,  177 Ohm,  134 Ohm, 2810mV, 1982mV, 1977mV,  124mV, 1903 counts, 4215 counts,  909 Ohms  0.00%
    // RTD 2973mV,  919 uA,  166 Ohm,  138 Ohm, 2820mV, 1975mV, 1971mV,  127mV, 1900 counts, 4213 counts,  908 Ohms -0.11%
    // RTD 2973mV,  919 uA,  159 Ohm,  131 Ohm, 2826mV, 1979mV, 1985mV,  121mV, 1900 counts, 4213 counts,  908 Ohms -0.11%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2981mV,  920 uA,  120 Ohm,  178 Ohm,  111mV,  962mV,  947mV, 2817mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    // RTD 2978mV,  920 uA,  129 Ohm,  179 Ohm,  119mV,  979mV,  963mV, 2813mV, 1913 counts, 4219 counts,  913 Ohms  0.44%
    // RTD 2973mV,  920 uA,  131 Ohm,  173 Ohm,  121mV,  959mV,  960mV, 2813mV, 1908 counts, 4218 counts,  911 Ohms  0.22%
    // RTD 2966mV,  920 uA,  144 Ohm,  170 Ohm,  133mV,  965mV,  947mV, 2809mV, 1913 counts, 4219 counts,  913 Ohms  0.44%
    // RTD 2973mV,  920 uA,  130 Ohm,  171 Ohm,  120mV,  958mV,  965mV, 2815mV, 1913 counts, 4218 counts,  913 Ohms  0.44%
    // RTD 2978mV,  920 uA,  132 Ohm,  179 Ohm,  122mV,  962mV,  964mV, 2813mV, 1909 counts, 4218 counts,  911 Ohms  0.22%
    // RTD 2977mV,  920 uA,  127 Ohm,  178 Ohm,  117mV,  955mV,  960mV, 2813mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    // RTD 2978mV,  920 uA,  140 Ohm,  186 Ohm,  129mV,  964mV,  962mV, 2806mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2969mV,  556 uA,  161 Ohm,  115 Ohm, 2879mV, 1202mV, 1206mV,   64mV,  953 counts,  638 counts, 3008 Ohms  0.47%
    // RTD 2979mV,  558 uA,  202 Ohm,  132 Ohm, 2866mV, 1194mV, 1194mV,   74mV,  953 counts,  640 counts, 2998 Ohms  0.13%
    // RTD 2975mV,  557 uA,  172 Ohm,  132 Ohm, 2879mV, 1198mV, 1209mV,   74mV,  953 counts,  639 counts, 3003 Ohms  0.30%
    // RTD 2974mV,  557 uA,  159 Ohm,  150 Ohm, 2885mV, 1200mV, 1200mV,   84mV,  954 counts,  639 counts, 3006 Ohms  0.40%
    // RTD 2971mV,  556 uA,  161 Ohm,  158 Ohm, 2881mV, 1202mV, 1199mV,   88mV,  952 counts,  638 counts, 3005 Ohms  0.37%
    // RTD 2968mV,  556 uA,  156 Ohm,  138 Ohm, 2881mV, 1197mV, 1202mV,   77mV,  953 counts,  638 counts, 3008 Ohms  0.47%
    // RTD 2977mV,  558 uA,  177 Ohm,  118 Ohm, 2878mV, 1196mV, 1196mV,   66mV,  954 counts,  640 counts, 3002 Ohms  0.27%
    // RTD 2978mV,  556 uA,  176 Ohm,  133 Ohm, 2880mV, 1198mV, 1195mV,   74mV,  952 counts,  638 counts, 3005 Ohms  0.37%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2974mV,  559 uA,  132 Ohm,  173 Ohm,   74mV, 1757mV, 1751mV, 2877mV,  954 counts,  641 counts, 2997 Ohms  0.10%
    // RTD 2962mV,  559 uA,  132 Ohm,  148 Ohm,   74mV, 1745mV, 1755mV, 2879mV,  956 counts,  641 counts, 3003 Ohms  0.30%
    // RTD 2973mV,  560 uA,  135 Ohm,  182 Ohm,   76mV, 1745mV, 1754mV, 2871mV,  957 counts,  642 counts, 3002 Ohms  0.27%
    // RTD 2978mV,  560 uA,   83 Ohm,  191 Ohm,   47mV, 1747mV, 1755mV, 2871mV,  957 counts,  642 counts, 3002 Ohms  0.27%
    // RTD 2974mV,  561 uA,  131 Ohm,  167 Ohm,   74mV, 1747mV, 1759mV, 2880mV,  956 counts,  643 counts, 2994 Ohms  0.00%
    // RTD 2973mV,  561 uA,  178 Ohm,  176 Ohm,  100mV, 1757mV, 1752mV, 2874mV,  956 counts,  643 counts, 2994 Ohms  0.00%
    // RTD 2967mV,  559 uA,  118 Ohm,  171 Ohm,   66mV, 1764mV, 1749mV, 2871mV,  956 counts,  641 counts, 3003 Ohms  0.30%
    // RTD 2979mV,  560 uA,  133 Ohm,  175 Ohm,   75mV, 1749mV, 1741mV, 2881mV,  956 counts,  642 counts, 2999 Ohms  0.17%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2981mV,  558 uA,  175 Ohm,  132 Ohm, 2883mV, 1197mV, 1196mV,   74mV, 3816 counts, 2560 counts, 3002 Ohms  0.27%
    // RTD 2981mV,  557 uA,  179 Ohm,  131 Ohm, 2881mV, 1198mV, 1200mV,   73mV, 3812 counts, 2556 counts, 3003 Ohms  0.30%
    // RTD 2966mV,  557 uA,  143 Ohm,  134 Ohm, 2886mV, 1205mV, 1207mV,   75mV, 3815 counts, 2557 counts, 3004 Ohms  0.33%
    // RTD 2974mV,  558 uA,  145 Ohm,  134 Ohm, 2893mV, 1209mV, 1205mV,   75mV, 3813 counts, 2561 counts, 2998 Ohms  0.13%
    // RTD 2974mV,  558 uA,  159 Ohm,  123 Ohm, 2885mV, 1213mV, 1204mV,   69mV, 3815 counts, 2559 counts, 3002 Ohms  0.27%
    // RTD 2977mV,  558 uA,  161 Ohm,  132 Ohm, 2887mV, 1172mV, 1206mV,   74mV, 3821 counts, 2561 counts, 3004 Ohms  0.33%
    // RTD 2966mV,  557 uA,  113 Ohm,  123 Ohm, 2903mV, 1198mV, 1198mV,   69mV, 3813 counts, 2557 counts, 3003 Ohms  0.30%
    // RTD 2974mV,  558 uA,  161 Ohm,  125 Ohm, 2884mV, 1204mV, 1206mV,   70mV, 3815 counts, 2560 counts, 3001 Ohms  0.23%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2973mV,  560 uA,  133 Ohm,  155 Ohm,   75mV, 1751mV, 1750mV, 2886mV, 3824 counts, 2569 counts, 2997 Ohms  0.10%
    // RTD 2975mV,  561 uA,  124 Ohm,  201 Ohm,   70mV, 1755mV, 1750mV, 2862mV, 3825 counts, 2572 counts, 2995 Ohms  0.03%
    // RTD 2973mV,  561 uA,   99 Ohm,  171 Ohm,   56mV, 1753mV, 1739mV, 2877mV, 3830 counts, 2571 counts, 3000 Ohms  0.20%
    // RTD 2979mV,  561 uA,  128 Ohm,  183 Ohm,   72mV, 1749mV, 1758mV, 2876mV, 3828 counts, 2572 counts, 2997 Ohms  0.10%
    // RTD 2977mV,  561 uA,  135 Ohm,  176 Ohm,   76mV, 1754mV, 1758mV, 2878mV, 3826 counts, 2571 counts, 2997 Ohms  0.10%
    // RTD 2979mV,  561 uA,  124 Ohm,  185 Ohm,   70mV, 1751mV, 1765mV, 2875mV, 3831 counts, 2575 counts, 2996 Ohms  0.07%
    // RTD 2975mV,  559 uA,  139 Ohm,  164 Ohm,   78mV, 1753mV, 1752mV, 2883mV, 3821 counts, 2565 counts, 3000 Ohms  0.20%
    // RTD 2973mV,  562 uA,  122 Ohm,  160 Ohm,   69mV, 1746mV, 1752mV, 2883mV, 3830 counts, 2576 counts, 2994 Ohms  0.00%
    

    This is a working design to produce these results:

    // RTD Measurement - Reversible current option
    //                                         +----------------------------------------------------+
    //                                         | nRF52832/nRF52833/nRF52840                         |
    //                                         |                                                    |
    //                                         |    VDD      VDD            VDD                     |
    //                                         |   --#--    --#--          --#--                    |
    //                                         |     |        |              |                      |
    //                                         |    _|__      | +Excitation  |   Option             |
    //                                         |    / \       +-|   Drive A  +-|   13k              |
    //                                         |   /-+-\        |<- High       |<- Pullup           |
    //                                         |     |        +-|   115R     +-|   (not used)       |
    //                                   P0.04 |     |        |              |                      |
    //                       +-----------------O-----#--------#--------------#------------ In       |
    //                       |                 |     |        | -Excitation  |   Option             |
    //                       |                 |   __|__      +-|   Drive A  +-|   13k              |
    //                       |                 |    / \         |<- Low        |<- Pulldown         |
    //                       |                 |   /-+-\      +-|   115R     +-|   (not used)       |
    //                       |                 |     |        |              |                      |
    //                       |                 |   =====    =====          =====                    |
    //                       |                 |    ===      ===            ===                     |
    //                       |                 |     =        =              =                      |
    //                       |                 |                                                    |
    //                       |                 |    VDD                                             |
    //                       |                 |   --#--                                            |
    //                       |                 |     |   Option                                     |
    //                       |                 |     +-|   160k                                     |
    //     Red Excitation A  |                 |       |<- High                                     |
    //   +--------/~/--------+                 |     +-|   Bias (not used)                          |
    //   | White Sense A                 P0.28 |     |                                              |
    //   #--------/~/------------------#-------O-----#------------#------#--> PIN_VOLTAGE_1         |
    //   |                             |       |     |   Option   |      |    AIN4 Ref=Int          |
    //   |                             |       |     +-|   160k  +++     |                          |
    //   |                             |       |       |<- Low   | |   -----                        |
    //  +++                      100nF |       |     +-|   Bias  | |   -----                        |
    //  | |                          -----     |     |    (nu)   +++     | 2.5pF                    |
    //  | |                          -----     |     |            |1M0   |                          |
    //  +++RTD                         |       |   =====        =====  =====                        |
    //   | Remote                      |       |    ===          ===    ===                         |
    //   |                             |       |     =            =      =                          |
    //   | White Sense B               | P0.29 |                                                    |
    //   #--------/~/------------------#-------O-----#------------#------#--> PIN_VOLTAGE_2         |
    //   |                               P0.31 |                              AIN5 Ref=Int          |
    //   +--------/~/--------#---------#-------O-----#------------#------#--> PIN_VOLTAGE_3         |
    //     Red Excitation B  |         | P0.30 |                              AIN7 Ref=Int          |
    //                       |         |   +---O-----#------------#------#--> PIN_VOLTAGE_4         |
    //                       |         |   |   |                              AIN6 Ref=Int          |
    //                       |   100nF |   |   |                                                    |
    //                       |       ----- |   |                                                    |
    //                       |       ----- |   |    VDD      VDD            VDD                     |
    //                       |         |   |   |   --#--    --#--          --#--                    |
    //                Rref  +++        |   |   |     |        |              |                      |
    //                2k0   | |        |   |   |    _|__      | +Excitation  |   Option             |
    //                1%    | |        |   |   |    / \       +-|   Drive B  +-|   13k              |
    //               (0.1%) +++        |   |   |   /-+-\        |<- High       |<- Pullup           |
    //                       |         |   |   |     |        +-|   115R     +-|   (not used)       |
    //                       |         |   |   |     |        |              |                      |
    //                       +---------#---#---O-----#--------#--------------#------------ In       |
    //                                   P0.03 |     |        | -Excitation  |   Option             |
    //                                         |   __|__      +-|   Drive B  +-|   13k              |
    //                                         |    / \         |<- Low        |<- Pulldown         |
    //                                         |   /-+-\      +-|   115R     +-|   (not used)       |
    //                                         |     |        |              |                      |
    //                                         |   =====    =====          =====                    |
    //                                         |    ===      ===            ===                     |
    //                                         |     =        =              =                      |
    //                                         +----------------------------------------------------+
    // Vrtd = differential voltage V1 and V2 in SAADC counts
    // Vref = differential voltage V3 and V4 in SAADC counts
    // Rrtd = (Vrtd * Rref)/Vref Ohms

    This code sample is designed to work with the schematic above on the nRF52833DK; I haven't bothered to optimise this code as it is already pretty quick and it is a simple proof-of-concept:

    #define SAADC_RESOLUTION_VAL   SAADC_RESOLUTION_VAL_12bit  // 12- or 14-bit in this code
    #define PIN_EXCITATION_A  4 // Red lead A to remote RTD
    #define PIN_EXCITATION_B  3 // Connected via Reference resistor to Red lead B to remote RTD
    //      PIN_VOLTAGE_0   VDD // VDD as source of excitation
    #define PIN_VOLTAGE_1    28 // AIN4 White lead from remote RTD (PIN_EXCITATION_A end)   2027
    #define PIN_VOLTAGE_2    29 // AIN5 White lead from remote RTD (PIN_EXCITATION_B end)     33
    #define PIN_VOLTAGE_3    31 // AIN7 Red lead B to remote RTD and Reference resistor     2967
    #define PIN_VOLTAGE_4    30 // AIN6 Reference resistor and PIN_EXCITATION_B             2017
    
    // Input range = (0.6 V)/(1/6) = 3.6 V. Differential mode has 1 bit less than single-ended due to sign bit
    #if (SAADC_RESOLUTION_VAL == SAADC_RESOLUTION_VAL_12bit)
     #define ADC12_COUNTS_PER_VOLT_SE   1138  // 12-bit Mode Singe-ended:  4096/3.6V
     #define ADC12_COUNTS_PER_VOLT_DIFF  569  // 12-bit Mode Differential: 2048/3.6V
     const uint8_t SAADC_ResolutionStr[] = "12-bit";
    #elif (SAADC_RESOLUTION_VAL == SAADC_RESOLUTION_VAL_14bit)
     #define SAADC_RESOLUTION_VAL SAADC_RESOLUTION_VAL_14bit
     #define ADC12_COUNTS_PER_VOLT_SE   4551  // 14-bit Mode Singe-ended: 16384/3.6V
     #define ADC12_COUNTS_PER_VOLT_DIFF 2276  // 14-bit Mode Differential: 8192/3.6V
     const uint8_t SAADC_ResolutionStr[] = "14-bit";
    #elif
     #error SAADC_RESOLUTION_VAL   not 12- or 14-bit in this code
    #endif
    
    // Do an initial calibration as the offset shows up in comparing +ve and -ve current measurements
    static bool mAmCalibrated = false;
    static float mMeasurementError = 0.0f;
    
    uint16_t GetRTD_Voltage(uint32_t AnalogueChannelP, uint32_t AnalogueChannelN)
    {
       uint16_t result = 9999;
       uint32_t timeout = 10000;
       volatile int16_t buffer[8];
       uint32_t i=0;  // SAADC Channel
       // Check if single-ended or differential SAADC mode
       if (AnalogueChannelN == SAADC_CH_PSELN_PSELN_NC)
       {
          // Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/6 gain, no pull-up or pull-down
          NRF_SAADC->CH[i].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6    << SAADC_CH_CONFIG_GAIN_Pos)   |
                                    (SAADC_CH_CONFIG_MODE_SE         << SAADC_CH_CONFIG_MODE_Pos)   |
                                    (SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESN_Pos)   |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESP_Pos)   |
                                    (SAADC_CH_CONFIG_TACQ_10us       << SAADC_CH_CONFIG_TACQ_Pos);
       }
       else
       {
          // Configure SAADC differential channel, Internal reference (0.6V) and 1/6 gain, no pull-up or pull-down
          // Could use higher gain as differential values are low, maybe 2V max
          NRF_SAADC->CH[i].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6    << SAADC_CH_CONFIG_GAIN_Pos)   |
                                    (SAADC_CH_CONFIG_MODE_Diff       << SAADC_CH_CONFIG_MODE_Pos)   |
                                    (SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESN_Pos)   |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESP_Pos)   |
                                    (SAADC_CH_CONFIG_TACQ_10us       << SAADC_CH_CONFIG_TACQ_Pos);
       }
       NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL << SAADC_RESOLUTION_VAL_Pos;
       // Analog positive and negative input channels have strange numbering:
       //  PSELP_NC           0UL  Not connected
       //  PSELP_AnalogInput0 1UL  AIN0
       //  PSELP_AnalogInput1 2UL  AIN1
       //  PSELP_AnalogInput2 3UL  AIN2
       //  PSELP_AnalogInput3 4UL  AIN3
       //  PSELP_AnalogInput4 5UL  AIN4
       //  PSELP_AnalogInput5 6UL  AIN5
       //  PSELP_AnalogInput6 7UL  AIN6
       //  PSELP_AnalogInput7 8UL  AIN7
       //  PSELP_VDD          9UL  VDD
       NRF_SAADC->CH[i].PSELP = AnalogueChannelP << SAADC_CH_PSELP_PSELP_Pos;
       NRF_SAADC->CH[i].PSELN = AnalogueChannelN << SAADC_CH_PSELN_PSELN_Pos;
       // Note the SAMPLE task must be triggered 2^OVERSAMPLE times for each output value
       //NRF_SAADC->OVERSAMPLE = SAADC_OVERSAMPLE_OVERSAMPLE_Over32x;
       // Enable SAADC
       NRF_SAADC->ENABLE = 1;
       NRF_SAADC->RESULT.PTR = (uint32_t)buffer;
       NRF_SAADC->RESULT.MAXCNT = 1;
       //NRF_SAADC->RESULT.AMOUNT
       // Do an initial calibration as the offset shows up in comparing +ve and -ve current measurements
       // Any gain changes require recalibration
       if(!mAmCalibrated)
       {
          NRF_SAADC->EVENTS_CALIBRATEDONE = 0;
          NRF_SAADC->TASKS_CALIBRATEOFFSET = 1;
          while (!NRF_SAADC->EVENTS_CALIBRATEDONE) ;
          mAmCalibrated = true;
       }
       NRF_SAADC->EVENTS_END = 0;
       NRF_SAADC->TASKS_START = 1;
       NRF_SAADC->TASKS_SAMPLE = 1;
       while ((!NRF_SAADC->EVENTS_END) && timeout > 0)
       {
          timeout--;
       }
       NRF_SAADC->TASKS_STOP = 1;
       NRF_SAADC->EVENTS_STARTED = 0;
       NRF_SAADC->EVENTS_END = 0;
       // Disable command
       NRF_SAADC->ENABLE = 0;
       if (timeout != 0)
       {
          // Calculate mVolt value with rounding, assume 16-bit unsigned for prints
          result = (uint16_t)((((int32_t)buffer[0] * 1000L)+(ADC12_COUNTS_PER_VOLT_SE/2)) / ADC12_COUNTS_PER_VOLT_SE);
       }
       if (AnalogueChannelN == SAADC_CH_PSELN_PSELN_NC)
       {
          // Display in mVolts
          return result;
       }
       else
       {
          // Display and calculate in SAADC counts for best resolution
          return abs(buffer[0]);
       }
    }
    
    #define AVERAGING_NUMBER 16
    #define REPORTS_NUMBER    8 //16
    const float Rref_Ohm  = 2014.5f;  // 2014.5 Ohm
    const float Rtest_Ohm =  909.5f;  //  909.5 Ohm 2993.8 Ohm
    float Rrtd = 0.0f;
    float Rrtd_Sum = 0.0f;
    
    
    void TestRTD_ResistanceMeasurement(void)
    {
       char RtdInfoPacket[240] = "?";
       uint16_t BatteryVolts0 = 0, BatteryVolts1 = 0, BatteryVolts2 = 0, BatteryVolts3 = 0, BatteryVolts4 = 0;
       mClocksInit();
       mRtcInit();
       // Take some samples forward current and then some reverse
       for (uint32_t SampleCount=0; SampleCount<REPORTS_NUMBER; SampleCount++)
       {
          uint32_t Vrtd = 0;
          uint32_t Vref = 0;
          uint32_t FET_RdsOnA = 1;
          uint32_t FET_RdsOnB = 1;
          // Configuration               Direction                Input                          Pullup                 Drive Level        Sense Level
          // ==========================  =======================  =============================  =====================  =================  =======================
          nrf_gpio_cfg(PIN_EXCITATION_A, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL,   NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
          nrf_gpio_cfg(PIN_EXCITATION_B, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL,   NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
          // Test with A high and B low then reverse current with A low and B high, probably average the result
          if (SampleCount < REPORTS_NUMBER/2)
          {
             // Turn on forward current through RTD and Reference
             nrf_gpio_pin_set(PIN_EXCITATION_A);
             nrf_gpio_pin_clear(PIN_EXCITATION_B);
          }
          else
          {
             // Turn on reverse current through RTD and Reference
             nrf_gpio_pin_clear(PIN_EXCITATION_A);
             nrf_gpio_pin_set(PIN_EXCITATION_B);
          }
          if (SampleCount == 0)
          {
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Internal 0.6v Ref %s S0S1 RTD actual value %0.2f Ohm (reference %0.2f Ohm) - Forward current measurement\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rref_Ohm);
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref        Rrtd  Error\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========== ======\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
          }
          else if (SampleCount == REPORTS_NUMBER/2)
          {
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Internal 0.6v Ref %s S0S1 RTD actual value %0.2f Ohm (reference %0.2f Ohm) - Reverse current measurement\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rref_Ohm);
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref        Rrtd  Error\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========== ======\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
          }
          // Short arbitrary delay to allow current to stabalise after turning on
          for (uint32_t i=0; i<1000UL; i++) {}
          // Get battery voltage first
          BatteryVolts0 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_VDD, SAADC_CH_PSELN_PSELN_NC);
          // Differential RTD and reference resistor voltage values
          Vrtd = 0;
          Vref = 0;
          for (uint32_t i=0; i<AVERAGING_NUMBER; i++)
          {
             Vrtd += GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput4, SAADC_CH_PSELP_PSELP_AnalogInput5);
             Vref += GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput7, SAADC_CH_PSELP_PSELP_AnalogInput6);
          }
          Vrtd /= AVERAGING_NUMBER;
          Vref /= AVERAGING_NUMBER;
          // Single-ended measurement voltages for testing
          BatteryVolts1 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput4, SAADC_CH_PSELN_PSELN_NC);
          BatteryVolts3 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput7, SAADC_CH_PSELN_PSELN_NC);
          // Single-ended FET drive voltages
          BatteryVolts2 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput5, SAADC_CH_PSELN_PSELN_NC);
          BatteryVolts4 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput6, SAADC_CH_PSELN_PSELN_NC);
          // Rrtd = (Vrtd * Rref)/Vref Ohms
          float Rrtd = ((float)Vrtd * Rref_Ohm)/(float)Vref;
          // Accumulate for sum of both forward and reverse measurements
          Rrtd_Sum += Rrtd;
          // Calculate % error
          mMeasurementError = (Rrtd - Rtest_Ohm) * 100.0f/Rtest_Ohm;
          // Calculate mVolt value of Vref using rounding, differential mode
          uint32_t Vref_mV = (((Vref * 1000)+(ADC12_COUNTS_PER_VOLT_DIFF/2)) / ADC12_COUNTS_PER_VOLT_DIFF);
          // Current Iref = Vref/Rref  uA
          uint32_t Iref_uA = (Vref_mV * 1000)/Rref_Ohm;
          // RdsOn = Vref_mV/Iref_uA Ohms
          if (SampleCount < REPORTS_NUMBER/2)
          {
             FET_RdsOnA = ((BatteryVolts0 - BatteryVolts1) * 1000) / Iref_uA;
             FET_RdsOnB = ((BatteryVolts4) * 1000) / Iref_uA;
          }
          else
          {
             FET_RdsOnA = (BatteryVolts1 * 1000) / Iref_uA;
             FET_RdsOnB = ((BatteryVolts0 - BatteryVolts4) * 1000) / Iref_uA;
          }
          //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
          //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
          // RTD 2980mV,  919 uA,  170 Ohm,  137 Ohm, 2823mV, 1982mV, 1982mV,  126mV,  477 counts, 1054 counts,  911 Ohms  0.22%
          snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "// RTD %4humV, %4u uA, %4u Ohm, %4u Ohm, %4humV, %4humV, %4humV, %4humV, %4u counts, %4u counts, %4.1f Ohms % 0.2f%%\r\n", BatteryVolts0, Iref_uA, FET_RdsOnA, FET_RdsOnB, BatteryVolts1, BatteryVolts2, BatteryVolts3, BatteryVolts4, Vrtd, Vref, Rrtd, mMeasurementError);
          uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
       }
       // Accumulate for sum of both forward and reverse measurements
       Rrtd_Sum /= (float)REPORTS_NUMBER;
       // Calculate % error
       mMeasurementError = (Rrtd_Sum - Rtest_Ohm) * 100.0f/Rtest_Ohm;
       // Measured 12-bit value of 905.0 Ohm test resistor is 905.2 Ohms with  0.02% error
       // Measured 12-bit value of 2984.6 Ohm test resistor is 2984.3 Ohms with -0.01% error
       snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Measured %s value of %4.1f Ohm test resistor is %4.1f Ohms with % 0.2f%% error\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rrtd_Sum, mMeasurementError);
       uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
       // Hold
       while(true) {}
    }

Reply
  • The nRF52833 supports both 4-wire and 3-wire RTD modes on the SAADC, and the performance is better than the discussions above indicate. The trick is to use ratiometric measurements, and assuming no space for large S/H caps this can be done with a single reference resistor - typically mid-range say 2k0 - and a single 100nF capacitor (2 capacitors are better). Performance is within a few Ohms. No SAADC calibration is required due to the ratiometric measurement. 14-bit mode gives the best results, though 12-bit is almost as good. Sampling time of 10uSecs works fine, though if the remote lead length to the RTD is capacitive a longer setup time for the excitation may be required. Current is VDD dependent, but again ratiometric mode removes any issues with that.

    These results are using a noisy USB as power source; even better results if operating on a battery. This test is with current flowing from RTD to Reference and then reverse current through RTD and reference and the results would be averaged. Using both current directions removes long-term DC offset which avoids other issues. Current is off except during measurement.

    Edit: I decided to use two 100nF capacitors; if you have room on the board this improves the readings. I updated my schematic and code to clarify.

    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2980mV,  919 uA,  170 Ohm,  137 Ohm, 2823mV, 1982mV, 1982mV,  126mV,  477 counts, 1054 counts,  911 Ohms  0.22%
    // RTD 2977mV,  919 uA,  179 Ohm,  140 Ohm, 2812mV, 1976mV, 1983mV,  129mV,  476 counts, 1054 counts,  909 Ohms  0.00%
    // RTD 2984mV,  921 uA,  175 Ohm,  136 Ohm, 2822mV, 2006mV, 1980mV,  126mV,  477 counts, 1056 counts,  909 Ohms  0.00%
    // RTD 2966mV,  919 uA,  156 Ohm,  137 Ohm, 2822mV, 1988mV, 1981mV,  126mV,  475 counts, 1053 counts,  908 Ohms -0.11%
    // RTD 2982mV,  920 uA,  168 Ohm,  145 Ohm, 2827mV, 1982mV, 1991mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2980mV,  920 uA,  169 Ohm,  145 Ohm, 2824mV, 1981mV, 1982mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2975mV,  920 uA,  161 Ohm,  145 Ohm, 2826mV, 1982mV, 1986mV,  134mV,  477 counts, 1055 counts,  910 Ohms  0.11%
    // RTD 2980mV,  920 uA,  169 Ohm,  139 Ohm, 2824mV, 2000mV, 1973mV,  128mV,  476 counts, 1055 counts,  908 Ohms -0.11%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2976mV,  919 uA,  130 Ohm,  173 Ohm,  120mV,  969mV,  973mV, 2817mV,  475 counts, 1053 counts,  908 Ohms -0.11%
    // RTD 2976mV,  919 uA,  139 Ohm,  175 Ohm,  128mV,  962mV,  967mV, 2815mV,  474 counts, 1053 counts,  906 Ohms -0.33%
    // RTD 2982mV,  917 uA,  138 Ohm,  175 Ohm,  127mV,  965mV,  971mV, 2821mV,  475 counts, 1051 counts,  910 Ohms  0.11%
    // RTD 2975mV,  917 uA,  131 Ohm,  174 Ohm,  121mV,  966mV,  968mV, 2815mV,  475 counts, 1051 counts,  910 Ohms  0.11%
    // RTD 2976mV,  917 uA,  133 Ohm,  167 Ohm,  122mV,  970mV,  967mV, 2822mV,  474 counts, 1051 counts,  908 Ohms -0.11%
    // RTD 2982mV,  918 uA,  143 Ohm,  183 Ohm,  132mV,  976mV,  958mV, 2814mV,  475 counts, 1052 counts,  909 Ohms  0.00%
    // RTD 2971mV,  918 uA,  141 Ohm,  167 Ohm,  130mV,  965mV,  963mV, 2817mV,  475 counts, 1052 counts,  909 Ohms  0.00%
    // RTD 2981mV,  919 uA,  140 Ohm,  168 Ohm,  129mV,  962mV,  966mV, 2826mV,  476 counts, 1053 counts,  910 Ohms  0.11%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2973mV,  920 uA,  168 Ohm,  133 Ohm, 2818mV, 1987mV, 1983mV,  123mV, 1901 counts, 4217 counts,  907 Ohms -0.22%
    // RTD 2974mV,  919 uA,  173 Ohm,  141 Ohm, 2815mV, 1978mV, 1971mV,  130mV, 1901 counts, 4215 counts,  908 Ohms -0.11%
    // RTD 2968mV,  918 uA,  155 Ohm,  137 Ohm, 2825mV, 1985mV, 1981mV,  126mV, 1900 counts, 4210 counts,  908 Ohms -0.11%
    // RTD 2969mV,  917 uA,  162 Ohm,  145 Ohm, 2820mV, 1978mV, 1976mV,  133mV, 1897 counts, 4207 counts,  908 Ohms -0.11%
    // RTD 2973mV,  919 uA,  157 Ohm,  139 Ohm, 2828mV, 1980mV, 1977mV,  128mV, 1899 counts, 4213 counts,  907 Ohms -0.22%
    // RTD 2973mV,  919 uA,  177 Ohm,  134 Ohm, 2810mV, 1982mV, 1977mV,  124mV, 1903 counts, 4215 counts,  909 Ohms  0.00%
    // RTD 2973mV,  919 uA,  166 Ohm,  138 Ohm, 2820mV, 1975mV, 1971mV,  127mV, 1900 counts, 4213 counts,  908 Ohms -0.11%
    // RTD 2973mV,  919 uA,  159 Ohm,  131 Ohm, 2826mV, 1979mV, 1985mV,  121mV, 1900 counts, 4213 counts,  908 Ohms -0.11%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 909 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2981mV,  920 uA,  120 Ohm,  178 Ohm,  111mV,  962mV,  947mV, 2817mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    // RTD 2978mV,  920 uA,  129 Ohm,  179 Ohm,  119mV,  979mV,  963mV, 2813mV, 1913 counts, 4219 counts,  913 Ohms  0.44%
    // RTD 2973mV,  920 uA,  131 Ohm,  173 Ohm,  121mV,  959mV,  960mV, 2813mV, 1908 counts, 4218 counts,  911 Ohms  0.22%
    // RTD 2966mV,  920 uA,  144 Ohm,  170 Ohm,  133mV,  965mV,  947mV, 2809mV, 1913 counts, 4219 counts,  913 Ohms  0.44%
    // RTD 2973mV,  920 uA,  130 Ohm,  171 Ohm,  120mV,  958mV,  965mV, 2815mV, 1913 counts, 4218 counts,  913 Ohms  0.44%
    // RTD 2978mV,  920 uA,  132 Ohm,  179 Ohm,  122mV,  962mV,  964mV, 2813mV, 1909 counts, 4218 counts,  911 Ohms  0.22%
    // RTD 2977mV,  920 uA,  127 Ohm,  178 Ohm,  117mV,  955mV,  960mV, 2813mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    // RTD 2978mV,  920 uA,  140 Ohm,  186 Ohm,  129mV,  964mV,  962mV, 2806mV, 1910 counts, 4220 counts,  911 Ohms  0.22%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2969mV,  556 uA,  161 Ohm,  115 Ohm, 2879mV, 1202mV, 1206mV,   64mV,  953 counts,  638 counts, 3008 Ohms  0.47%
    // RTD 2979mV,  558 uA,  202 Ohm,  132 Ohm, 2866mV, 1194mV, 1194mV,   74mV,  953 counts,  640 counts, 2998 Ohms  0.13%
    // RTD 2975mV,  557 uA,  172 Ohm,  132 Ohm, 2879mV, 1198mV, 1209mV,   74mV,  953 counts,  639 counts, 3003 Ohms  0.30%
    // RTD 2974mV,  557 uA,  159 Ohm,  150 Ohm, 2885mV, 1200mV, 1200mV,   84mV,  954 counts,  639 counts, 3006 Ohms  0.40%
    // RTD 2971mV,  556 uA,  161 Ohm,  158 Ohm, 2881mV, 1202mV, 1199mV,   88mV,  952 counts,  638 counts, 3005 Ohms  0.37%
    // RTD 2968mV,  556 uA,  156 Ohm,  138 Ohm, 2881mV, 1197mV, 1202mV,   77mV,  953 counts,  638 counts, 3008 Ohms  0.47%
    // RTD 2977mV,  558 uA,  177 Ohm,  118 Ohm, 2878mV, 1196mV, 1196mV,   66mV,  954 counts,  640 counts, 3002 Ohms  0.27%
    // RTD 2978mV,  556 uA,  176 Ohm,  133 Ohm, 2880mV, 1198mV, 1195mV,   74mV,  952 counts,  638 counts, 3005 Ohms  0.37%
    
    // Internal 0.6v Ref 12-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2974mV,  559 uA,  132 Ohm,  173 Ohm,   74mV, 1757mV, 1751mV, 2877mV,  954 counts,  641 counts, 2997 Ohms  0.10%
    // RTD 2962mV,  559 uA,  132 Ohm,  148 Ohm,   74mV, 1745mV, 1755mV, 2879mV,  956 counts,  641 counts, 3003 Ohms  0.30%
    // RTD 2973mV,  560 uA,  135 Ohm,  182 Ohm,   76mV, 1745mV, 1754mV, 2871mV,  957 counts,  642 counts, 3002 Ohms  0.27%
    // RTD 2978mV,  560 uA,   83 Ohm,  191 Ohm,   47mV, 1747mV, 1755mV, 2871mV,  957 counts,  642 counts, 3002 Ohms  0.27%
    // RTD 2974mV,  561 uA,  131 Ohm,  167 Ohm,   74mV, 1747mV, 1759mV, 2880mV,  956 counts,  643 counts, 2994 Ohms  0.00%
    // RTD 2973mV,  561 uA,  178 Ohm,  176 Ohm,  100mV, 1757mV, 1752mV, 2874mV,  956 counts,  643 counts, 2994 Ohms  0.00%
    // RTD 2967mV,  559 uA,  118 Ohm,  171 Ohm,   66mV, 1764mV, 1749mV, 2871mV,  956 counts,  641 counts, 3003 Ohms  0.30%
    // RTD 2979mV,  560 uA,  133 Ohm,  175 Ohm,   75mV, 1749mV, 1741mV, 2881mV,  956 counts,  642 counts, 2999 Ohms  0.17%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Forward current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2981mV,  558 uA,  175 Ohm,  132 Ohm, 2883mV, 1197mV, 1196mV,   74mV, 3816 counts, 2560 counts, 3002 Ohms  0.27%
    // RTD 2981mV,  557 uA,  179 Ohm,  131 Ohm, 2881mV, 1198mV, 1200mV,   73mV, 3812 counts, 2556 counts, 3003 Ohms  0.30%
    // RTD 2966mV,  557 uA,  143 Ohm,  134 Ohm, 2886mV, 1205mV, 1207mV,   75mV, 3815 counts, 2557 counts, 3004 Ohms  0.33%
    // RTD 2974mV,  558 uA,  145 Ohm,  134 Ohm, 2893mV, 1209mV, 1205mV,   75mV, 3813 counts, 2561 counts, 2998 Ohms  0.13%
    // RTD 2974mV,  558 uA,  159 Ohm,  123 Ohm, 2885mV, 1213mV, 1204mV,   69mV, 3815 counts, 2559 counts, 3002 Ohms  0.27%
    // RTD 2977mV,  558 uA,  161 Ohm,  132 Ohm, 2887mV, 1172mV, 1206mV,   74mV, 3821 counts, 2561 counts, 3004 Ohms  0.33%
    // RTD 2966mV,  557 uA,  113 Ohm,  123 Ohm, 2903mV, 1198mV, 1198mV,   69mV, 3813 counts, 2557 counts, 3003 Ohms  0.30%
    // RTD 2974mV,  558 uA,  161 Ohm,  125 Ohm, 2884mV, 1204mV, 1206mV,   70mV, 3815 counts, 2560 counts, 3001 Ohms  0.23%
    
    // Internal 0.6v Ref 14-bit S0S1 RTD actual value 2994 Ohm (reference 2014 Ohm) - Reverse current measurement
    //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
    //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
    // RTD 2973mV,  560 uA,  133 Ohm,  155 Ohm,   75mV, 1751mV, 1750mV, 2886mV, 3824 counts, 2569 counts, 2997 Ohms  0.10%
    // RTD 2975mV,  561 uA,  124 Ohm,  201 Ohm,   70mV, 1755mV, 1750mV, 2862mV, 3825 counts, 2572 counts, 2995 Ohms  0.03%
    // RTD 2973mV,  561 uA,   99 Ohm,  171 Ohm,   56mV, 1753mV, 1739mV, 2877mV, 3830 counts, 2571 counts, 3000 Ohms  0.20%
    // RTD 2979mV,  561 uA,  128 Ohm,  183 Ohm,   72mV, 1749mV, 1758mV, 2876mV, 3828 counts, 2572 counts, 2997 Ohms  0.10%
    // RTD 2977mV,  561 uA,  135 Ohm,  176 Ohm,   76mV, 1754mV, 1758mV, 2878mV, 3826 counts, 2571 counts, 2997 Ohms  0.10%
    // RTD 2979mV,  561 uA,  124 Ohm,  185 Ohm,   70mV, 1751mV, 1765mV, 2875mV, 3831 counts, 2575 counts, 2996 Ohms  0.07%
    // RTD 2975mV,  559 uA,  139 Ohm,  164 Ohm,   78mV, 1753mV, 1752mV, 2883mV, 3821 counts, 2565 counts, 3000 Ohms  0.20%
    // RTD 2973mV,  562 uA,  122 Ohm,  160 Ohm,   69mV, 1746mV, 1752mV, 2883mV, 3830 counts, 2576 counts, 2994 Ohms  0.00%
    

    This is a working design to produce these results:

    // RTD Measurement - Reversible current option
    //                                         +----------------------------------------------------+
    //                                         | nRF52832/nRF52833/nRF52840                         |
    //                                         |                                                    |
    //                                         |    VDD      VDD            VDD                     |
    //                                         |   --#--    --#--          --#--                    |
    //                                         |     |        |              |                      |
    //                                         |    _|__      | +Excitation  |   Option             |
    //                                         |    / \       +-|   Drive A  +-|   13k              |
    //                                         |   /-+-\        |<- High       |<- Pullup           |
    //                                         |     |        +-|   115R     +-|   (not used)       |
    //                                   P0.04 |     |        |              |                      |
    //                       +-----------------O-----#--------#--------------#------------ In       |
    //                       |                 |     |        | -Excitation  |   Option             |
    //                       |                 |   __|__      +-|   Drive A  +-|   13k              |
    //                       |                 |    / \         |<- Low        |<- Pulldown         |
    //                       |                 |   /-+-\      +-|   115R     +-|   (not used)       |
    //                       |                 |     |        |              |                      |
    //                       |                 |   =====    =====          =====                    |
    //                       |                 |    ===      ===            ===                     |
    //                       |                 |     =        =              =                      |
    //                       |                 |                                                    |
    //                       |                 |    VDD                                             |
    //                       |                 |   --#--                                            |
    //                       |                 |     |   Option                                     |
    //                       |                 |     +-|   160k                                     |
    //     Red Excitation A  |                 |       |<- High                                     |
    //   +--------/~/--------+                 |     +-|   Bias (not used)                          |
    //   | White Sense A                 P0.28 |     |                                              |
    //   #--------/~/------------------#-------O-----#------------#------#--> PIN_VOLTAGE_1         |
    //   |                             |       |     |   Option   |      |    AIN4 Ref=Int          |
    //   |                             |       |     +-|   160k  +++     |                          |
    //   |                             |       |       |<- Low   | |   -----                        |
    //  +++                      100nF |       |     +-|   Bias  | |   -----                        |
    //  | |                          -----     |     |    (nu)   +++     | 2.5pF                    |
    //  | |                          -----     |     |            |1M0   |                          |
    //  +++RTD                         |       |   =====        =====  =====                        |
    //   | Remote                      |       |    ===          ===    ===                         |
    //   |                             |       |     =            =      =                          |
    //   | White Sense B               | P0.29 |                                                    |
    //   #--------/~/------------------#-------O-----#------------#------#--> PIN_VOLTAGE_2         |
    //   |                               P0.31 |                              AIN5 Ref=Int          |
    //   +--------/~/--------#---------#-------O-----#------------#------#--> PIN_VOLTAGE_3         |
    //     Red Excitation B  |         | P0.30 |                              AIN7 Ref=Int          |
    //                       |         |   +---O-----#------------#------#--> PIN_VOLTAGE_4         |
    //                       |         |   |   |                              AIN6 Ref=Int          |
    //                       |   100nF |   |   |                                                    |
    //                       |       ----- |   |                                                    |
    //                       |       ----- |   |    VDD      VDD            VDD                     |
    //                       |         |   |   |   --#--    --#--          --#--                    |
    //                Rref  +++        |   |   |     |        |              |                      |
    //                2k0   | |        |   |   |    _|__      | +Excitation  |   Option             |
    //                1%    | |        |   |   |    / \       +-|   Drive B  +-|   13k              |
    //               (0.1%) +++        |   |   |   /-+-\        |<- High       |<- Pullup           |
    //                       |         |   |   |     |        +-|   115R     +-|   (not used)       |
    //                       |         |   |   |     |        |              |                      |
    //                       +---------#---#---O-----#--------#--------------#------------ In       |
    //                                   P0.03 |     |        | -Excitation  |   Option             |
    //                                         |   __|__      +-|   Drive B  +-|   13k              |
    //                                         |    / \         |<- Low        |<- Pulldown         |
    //                                         |   /-+-\      +-|   115R     +-|   (not used)       |
    //                                         |     |        |              |                      |
    //                                         |   =====    =====          =====                    |
    //                                         |    ===      ===            ===                     |
    //                                         |     =        =              =                      |
    //                                         +----------------------------------------------------+
    // Vrtd = differential voltage V1 and V2 in SAADC counts
    // Vref = differential voltage V3 and V4 in SAADC counts
    // Rrtd = (Vrtd * Rref)/Vref Ohms

    This code sample is designed to work with the schematic above on the nRF52833DK; I haven't bothered to optimise this code as it is already pretty quick and it is a simple proof-of-concept:

    #define SAADC_RESOLUTION_VAL   SAADC_RESOLUTION_VAL_12bit  // 12- or 14-bit in this code
    #define PIN_EXCITATION_A  4 // Red lead A to remote RTD
    #define PIN_EXCITATION_B  3 // Connected via Reference resistor to Red lead B to remote RTD
    //      PIN_VOLTAGE_0   VDD // VDD as source of excitation
    #define PIN_VOLTAGE_1    28 // AIN4 White lead from remote RTD (PIN_EXCITATION_A end)   2027
    #define PIN_VOLTAGE_2    29 // AIN5 White lead from remote RTD (PIN_EXCITATION_B end)     33
    #define PIN_VOLTAGE_3    31 // AIN7 Red lead B to remote RTD and Reference resistor     2967
    #define PIN_VOLTAGE_4    30 // AIN6 Reference resistor and PIN_EXCITATION_B             2017
    
    // Input range = (0.6 V)/(1/6) = 3.6 V. Differential mode has 1 bit less than single-ended due to sign bit
    #if (SAADC_RESOLUTION_VAL == SAADC_RESOLUTION_VAL_12bit)
     #define ADC12_COUNTS_PER_VOLT_SE   1138  // 12-bit Mode Singe-ended:  4096/3.6V
     #define ADC12_COUNTS_PER_VOLT_DIFF  569  // 12-bit Mode Differential: 2048/3.6V
     const uint8_t SAADC_ResolutionStr[] = "12-bit";
    #elif (SAADC_RESOLUTION_VAL == SAADC_RESOLUTION_VAL_14bit)
     #define SAADC_RESOLUTION_VAL SAADC_RESOLUTION_VAL_14bit
     #define ADC12_COUNTS_PER_VOLT_SE   4551  // 14-bit Mode Singe-ended: 16384/3.6V
     #define ADC12_COUNTS_PER_VOLT_DIFF 2276  // 14-bit Mode Differential: 8192/3.6V
     const uint8_t SAADC_ResolutionStr[] = "14-bit";
    #elif
     #error SAADC_RESOLUTION_VAL   not 12- or 14-bit in this code
    #endif
    
    // Do an initial calibration as the offset shows up in comparing +ve and -ve current measurements
    static bool mAmCalibrated = false;
    static float mMeasurementError = 0.0f;
    
    uint16_t GetRTD_Voltage(uint32_t AnalogueChannelP, uint32_t AnalogueChannelN)
    {
       uint16_t result = 9999;
       uint32_t timeout = 10000;
       volatile int16_t buffer[8];
       uint32_t i=0;  // SAADC Channel
       // Check if single-ended or differential SAADC mode
       if (AnalogueChannelN == SAADC_CH_PSELN_PSELN_NC)
       {
          // Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/6 gain, no pull-up or pull-down
          NRF_SAADC->CH[i].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6    << SAADC_CH_CONFIG_GAIN_Pos)   |
                                    (SAADC_CH_CONFIG_MODE_SE         << SAADC_CH_CONFIG_MODE_Pos)   |
                                    (SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESN_Pos)   |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESP_Pos)   |
                                    (SAADC_CH_CONFIG_TACQ_10us       << SAADC_CH_CONFIG_TACQ_Pos);
       }
       else
       {
          // Configure SAADC differential channel, Internal reference (0.6V) and 1/6 gain, no pull-up or pull-down
          // Could use higher gain as differential values are low, maybe 2V max
          NRF_SAADC->CH[i].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6    << SAADC_CH_CONFIG_GAIN_Pos)   |
                                    (SAADC_CH_CONFIG_MODE_Diff       << SAADC_CH_CONFIG_MODE_Pos)   |
                                    (SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESN_Pos)   |
                                    (SAADC_CH_CONFIG_RESN_Bypass     << SAADC_CH_CONFIG_RESP_Pos)   |
                                    (SAADC_CH_CONFIG_TACQ_10us       << SAADC_CH_CONFIG_TACQ_Pos);
       }
       NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL << SAADC_RESOLUTION_VAL_Pos;
       // Analog positive and negative input channels have strange numbering:
       //  PSELP_NC           0UL  Not connected
       //  PSELP_AnalogInput0 1UL  AIN0
       //  PSELP_AnalogInput1 2UL  AIN1
       //  PSELP_AnalogInput2 3UL  AIN2
       //  PSELP_AnalogInput3 4UL  AIN3
       //  PSELP_AnalogInput4 5UL  AIN4
       //  PSELP_AnalogInput5 6UL  AIN5
       //  PSELP_AnalogInput6 7UL  AIN6
       //  PSELP_AnalogInput7 8UL  AIN7
       //  PSELP_VDD          9UL  VDD
       NRF_SAADC->CH[i].PSELP = AnalogueChannelP << SAADC_CH_PSELP_PSELP_Pos;
       NRF_SAADC->CH[i].PSELN = AnalogueChannelN << SAADC_CH_PSELN_PSELN_Pos;
       // Note the SAMPLE task must be triggered 2^OVERSAMPLE times for each output value
       //NRF_SAADC->OVERSAMPLE = SAADC_OVERSAMPLE_OVERSAMPLE_Over32x;
       // Enable SAADC
       NRF_SAADC->ENABLE = 1;
       NRF_SAADC->RESULT.PTR = (uint32_t)buffer;
       NRF_SAADC->RESULT.MAXCNT = 1;
       //NRF_SAADC->RESULT.AMOUNT
       // Do an initial calibration as the offset shows up in comparing +ve and -ve current measurements
       // Any gain changes require recalibration
       if(!mAmCalibrated)
       {
          NRF_SAADC->EVENTS_CALIBRATEDONE = 0;
          NRF_SAADC->TASKS_CALIBRATEOFFSET = 1;
          while (!NRF_SAADC->EVENTS_CALIBRATEDONE) ;
          mAmCalibrated = true;
       }
       NRF_SAADC->EVENTS_END = 0;
       NRF_SAADC->TASKS_START = 1;
       NRF_SAADC->TASKS_SAMPLE = 1;
       while ((!NRF_SAADC->EVENTS_END) && timeout > 0)
       {
          timeout--;
       }
       NRF_SAADC->TASKS_STOP = 1;
       NRF_SAADC->EVENTS_STARTED = 0;
       NRF_SAADC->EVENTS_END = 0;
       // Disable command
       NRF_SAADC->ENABLE = 0;
       if (timeout != 0)
       {
          // Calculate mVolt value with rounding, assume 16-bit unsigned for prints
          result = (uint16_t)((((int32_t)buffer[0] * 1000L)+(ADC12_COUNTS_PER_VOLT_SE/2)) / ADC12_COUNTS_PER_VOLT_SE);
       }
       if (AnalogueChannelN == SAADC_CH_PSELN_PSELN_NC)
       {
          // Display in mVolts
          return result;
       }
       else
       {
          // Display and calculate in SAADC counts for best resolution
          return abs(buffer[0]);
       }
    }
    
    #define AVERAGING_NUMBER 16
    #define REPORTS_NUMBER    8 //16
    const float Rref_Ohm  = 2014.5f;  // 2014.5 Ohm
    const float Rtest_Ohm =  909.5f;  //  909.5 Ohm 2993.8 Ohm
    float Rrtd = 0.0f;
    float Rrtd_Sum = 0.0f;
    
    
    void TestRTD_ResistanceMeasurement(void)
    {
       char RtdInfoPacket[240] = "?";
       uint16_t BatteryVolts0 = 0, BatteryVolts1 = 0, BatteryVolts2 = 0, BatteryVolts3 = 0, BatteryVolts4 = 0;
       mClocksInit();
       mRtcInit();
       // Take some samples forward current and then some reverse
       for (uint32_t SampleCount=0; SampleCount<REPORTS_NUMBER; SampleCount++)
       {
          uint32_t Vrtd = 0;
          uint32_t Vref = 0;
          uint32_t FET_RdsOnA = 1;
          uint32_t FET_RdsOnB = 1;
          // Configuration               Direction                Input                          Pullup                 Drive Level        Sense Level
          // ==========================  =======================  =============================  =====================  =================  =======================
          nrf_gpio_cfg(PIN_EXCITATION_A, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL,   NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
          nrf_gpio_cfg(PIN_EXCITATION_B, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL,   NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
          // Test with A high and B low then reverse current with A low and B high, probably average the result
          if (SampleCount < REPORTS_NUMBER/2)
          {
             // Turn on forward current through RTD and Reference
             nrf_gpio_pin_set(PIN_EXCITATION_A);
             nrf_gpio_pin_clear(PIN_EXCITATION_B);
          }
          else
          {
             // Turn on reverse current through RTD and Reference
             nrf_gpio_pin_clear(PIN_EXCITATION_A);
             nrf_gpio_pin_set(PIN_EXCITATION_B);
          }
          if (SampleCount == 0)
          {
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Internal 0.6v Ref %s S0S1 RTD actual value %0.2f Ohm (reference %0.2f Ohm) - Forward current measurement\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rref_Ohm);
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref        Rrtd  Error\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========== ======\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
          }
          else if (SampleCount == REPORTS_NUMBER/2)
          {
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Internal 0.6v Ref %s S0S1 RTD actual value %0.2f Ohm (reference %0.2f Ohm) - Reverse current measurement\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rref_Ohm);
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref        Rrtd  Error\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
             snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "//     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========== ======\r\n");
             uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
          }
          // Short arbitrary delay to allow current to stabalise after turning on
          for (uint32_t i=0; i<1000UL; i++) {}
          // Get battery voltage first
          BatteryVolts0 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_VDD, SAADC_CH_PSELN_PSELN_NC);
          // Differential RTD and reference resistor voltage values
          Vrtd = 0;
          Vref = 0;
          for (uint32_t i=0; i<AVERAGING_NUMBER; i++)
          {
             Vrtd += GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput4, SAADC_CH_PSELP_PSELP_AnalogInput5);
             Vref += GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput7, SAADC_CH_PSELP_PSELP_AnalogInput6);
          }
          Vrtd /= AVERAGING_NUMBER;
          Vref /= AVERAGING_NUMBER;
          // Single-ended measurement voltages for testing
          BatteryVolts1 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput4, SAADC_CH_PSELN_PSELN_NC);
          BatteryVolts3 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput7, SAADC_CH_PSELN_PSELN_NC);
          // Single-ended FET drive voltages
          BatteryVolts2 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput5, SAADC_CH_PSELN_PSELN_NC);
          BatteryVolts4 = GetRTD_Voltage(SAADC_CH_PSELP_PSELP_AnalogInput6, SAADC_CH_PSELN_PSELN_NC);
          // Rrtd = (Vrtd * Rref)/Vref Ohms
          float Rrtd = ((float)Vrtd * Rref_Ohm)/(float)Vref;
          // Accumulate for sum of both forward and reverse measurements
          Rrtd_Sum += Rrtd;
          // Calculate % error
          mMeasurementError = (Rrtd - Rtest_Ohm) * 100.0f/Rtest_Ohm;
          // Calculate mVolt value of Vref using rounding, differential mode
          uint32_t Vref_mV = (((Vref * 1000)+(ADC12_COUNTS_PER_VOLT_DIFF/2)) / ADC12_COUNTS_PER_VOLT_DIFF);
          // Current Iref = Vref/Rref  uA
          uint32_t Iref_uA = (Vref_mV * 1000)/Rref_Ohm;
          // RdsOn = Vref_mV/Iref_uA Ohms
          if (SampleCount < REPORTS_NUMBER/2)
          {
             FET_RdsOnA = ((BatteryVolts0 - BatteryVolts1) * 1000) / Iref_uA;
             FET_RdsOnB = ((BatteryVolts4) * 1000) / Iref_uA;
          }
          else
          {
             FET_RdsOnA = (BatteryVolts1 * 1000) / Iref_uA;
             FET_RdsOnB = ((BatteryVolts0 - BatteryVolts4) * 1000) / Iref_uA;
          }
          //        VDD     Iref    RdsOnA    RdsOnB      V1      V2      V3      V4         Vrtd         Vref       Rrtd  Error
          //     ======   ======  ========  ========  ======  ======  ======  ======  ===========  ===========  ========= ======
          // RTD 2980mV,  919 uA,  170 Ohm,  137 Ohm, 2823mV, 1982mV, 1982mV,  126mV,  477 counts, 1054 counts,  911 Ohms  0.22%
          snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "// RTD %4humV, %4u uA, %4u Ohm, %4u Ohm, %4humV, %4humV, %4humV, %4humV, %4u counts, %4u counts, %4.1f Ohms % 0.2f%%\r\n", BatteryVolts0, Iref_uA, FET_RdsOnA, FET_RdsOnB, BatteryVolts1, BatteryVolts2, BatteryVolts3, BatteryVolts4, Vrtd, Vref, Rrtd, mMeasurementError);
          uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
       }
       // Accumulate for sum of both forward and reverse measurements
       Rrtd_Sum /= (float)REPORTS_NUMBER;
       // Calculate % error
       mMeasurementError = (Rrtd_Sum - Rtest_Ohm) * 100.0f/Rtest_Ohm;
       // Measured 12-bit value of 905.0 Ohm test resistor is 905.2 Ohms with  0.02% error
       // Measured 12-bit value of 2984.6 Ohm test resistor is 2984.3 Ohms with -0.01% error
       snprintf(RtdInfoPacket, sizeof(RtdInfoPacket)-1, "\r\n// Measured %s value of %4.1f Ohm test resistor is %4.1f Ohms with % 0.2f%% error\r\n", SAADC_ResolutionStr, Rtest_Ohm, Rrtd_Sum, mMeasurementError);
       uartSend(RtdInfoPacket, strlen(RtdInfoPacket));
       // Hold
       while(true) {}
    }

Children
No Data
Related