14-Bit, 4-20 mA, Loop Powered, Thermocouple Temperature Measurement System Using ARM Cortex-M3
This circuit provides a low cost solution to temperature monitoring because most of the circuit functionality is integrated into the ADuCM360 precision analog microcontroller, including dual 24-bit Σ-Δ ADCs, the ARM Cortex™-M3 processor core, and the PWM/DAC features for controlling the 4 mA-to-20 mA loop for loop voltages up to 28 V.
The ADuCM360 is connected to a Type T thermocouple and a 100 Ω platinum resistance temperature detector (RTD). The RTD is used for cold junction compensation. The low power Cortex-M3 core converts the ADC readings to a temperature value. The Type T thermocouple temperature range supported is −200°C to +350°C, and this temperature range is converted to an output current range of 4 mA to 20 mA.
This circuit is similar to the circuit in Circuit Note CN-0300 with the additional benefit of the higher resolution of the PWM driving the 4 mA-to-20 mA loop. The PWM-based output provides 14 bits of resolution. For details on the temperature sensor interface to the ADC and on linearization techniques for the RTD measurements, see Circuit Note CN-0300 and the AN-0970 Application Note.
This part of the circuit is similar to the temperature monitor circuit described in CN-0300. The following features of the ADuCM360 are used:
- The 24-bit Σ-Δ ADC with a PGA set for a gain of 32 in the software for the thermocouple and the RTD. ADC1 switches continuously between sampling the thermocouple and the RTD voltages.
- Programmable excitation current sources force a controlled current through the RTD. The dual current sources are configurable in steps from 0 μA to 2 mA. For this example, a 200 μA setting is used to minimize the error introduced by the RTD self-heating.
- An internal 1.2 V reference is provided for the ADC in the ADuCM360. When measuring the thermocouple voltage, the internal voltage reference is used due to its precision.
- An external voltage reference for the ADC in the ADuCM360. When measuring the RTD resistance, a ratiometric setup was used where an external reference resistor (RREF) was connected across the external VREF+ and VREF− pins. The on-chip reference input buffer is enabled because the reference source in this circuit is high impedance. The on-chip reference buffer means no external buffer is required to minimize input leakage effects.
- A bias voltage generator (VBIAS). The VBIAS function is used to set the thermocouple common-mode voltage to AVDD_REG/2 (900 mV). Again, this removes the need for external resistors to set the thermocouple common-mode voltage.
- The ARM Cortex-M3 core. The powerful 32-bit ARM core with integrated 126 kB flash and 8 kB SRAM memory runs the user code that configures and controls the ADCs and converts the ADC conversions from the thermocouple and RTD inputs to a final temperature value. It also controls the PWM output driving the 4mA to 20 mA loop. For extra debug purposes, it also controls the communications over the UART/USB interface.
- The 16-bit PWM output is externally buffered using OP193, and is controlling an external NPN transistor, BC548. By controlling the VBE voltage of this transistor, the current passing through a 47.5 Ω load resistor can be set to the desired value. This provides better then ±0.5°C accuracy (between –200°C to +350°C) on the 4 mA-to-20 mA output (see test results).
- The internal DAC is used to provide the 1.2 V reference to the OP193. Alternatively, the ADR3412, a 1.2 V precision reference could be used, for higher precision over temperature. This external reference consumes similar power than the internal DAC (~50 μA). See current consumption measurement tests section.
The 4 mA-20 mA loop is controlled by the ADuCM360 on-chip 16-bit PWM (pulse width modulator). The duty cycle of the PWM is configured in software to control the voltage across the 47.5 Ω RLOOP resistor, which in turn sets the loop current. Note the top of RLOOP connects to the ADuCM360 ground. The bottom of RLOOP connects to the loop ground. Because of this, the current due to the ADuCM360, ADP1720, ADR3412 and OP193, plus the current set by the filtered PWM output, flows across RLOOP.
The voltage at the junction of R1 and R2 can be expressed:
After the loop settles:
Since R1 = R2:
VRLOOP = VREF − 2VIN
Full-scale current will flow when VIN = 0, at which point VRLOOP = VREF. Hence, full-scale current is VREF/RLOOP, or ≈24 mA. When VIN = VREF/2, no current will flow.
The OP193 amplifier impedance at VIN is high and will not load the PWM filtered output. The amplifier output varies only a small amount of about 0.7 V.
Performance at the range extremes, 0 mA to 4 mA, and 20 mA to 24 mA, is not critical; therefore, the op amp does not require good performance at the supply rails.
Absolute values of R1 and R2 are not critical. However, note that matching of R1 and R2 is important.
ADC1 is used for temperature measurements, therefore this circuit note is directly applicable to the ADuCM361 which has only one ADC. The EVAL-CN0319-EB1Z board includes the option for measuring the voltage at the point marked VR12 by using an input channel of ADC0 on the ADuCM360. This ADC measurement can be used as feedback for the PWM control software to adjust the 4 mA-to-20 mA current setting.
- The UART is used as the communication interface to the host PC. This is used to program the on-chip flash. It is also used as a debug port and for calibrating the filtered PWM output.
- Two external switches are used to force the part into its flash boot mode. By holding SD low and toggling the RESET button, the ADuCM360 enters boot mode instead of normal user mode. In boot mode, the internal flash can be reprogrammed through the UART interface.
The link to the source code used to test the circuit can be found in the CN0319 Design Support Package at http://www.analog.com/CN0319-DesignSupport. The source code uses the function libraries provided with the example code.
Figure 2 shows the list of source files used in the project when viewed with the Keil μVision4 tools.
ADC1 is used for temperature measurements on the thermocouple and on the RTD. This section of the code is copied from Circuit Note CN-0300. Refer to this circuit note for more details.
The PWM filtered output needs to be adjusted in order to ensure 4 mA at minimum temperature and 20 mA at maximum temperature. A calibration routine is provided, it can be included or removed easily using the #define CalibratePWM parameter.
To calibrate the PWM, the interface board (USB-SWD/UART) must be connected to J1 and to the USB port on a PC. A COM port viewer program, such as HyperTerminal, can be used to view the calibration menus and step through the calibration routines.
When calibrating the PWM, connect the VLOOP+ and VLOOP– outputs to an accurate current meter. The first part of the PWM calibration routine adjusts the DAC to set a 4 mA output, and the second part of the PWM calibration routine adjusts the PWM to set a 20 mA output. The PWM code used to set a 4 mA and 20 mA output is stored to flash.
The UART is configured for a baud rate of 19200, 8 data bits, no parity, and no flow control. If the circuit is connected directly to a PC, a communication port viewing application, such as HyperTerminal or CoolTerm, can be used to view the results sent by the program to the UART, as shown in Figure 3.
To enter the characters required by the calibration routines, type the required character in the viewing terminal and this character will be received by the ADuCM360 UART port.
After calibration, the demo code switches off the UART clock for further power saving.
Calibration coefficients are saved in Flash, therefore it is not necessary to run calibration each time the board is powered unless VLOOP level is changed.
A code flowchart is shown in Figure 4.
Figure 4. Code Flowchart
PWM Differential Nonlinearity (DNL)
The setup shown in Figure 6 was used to test the communication section of the circuit.
The PC sends temperature values to the ADuCM360 via UART, and the ADuCM360 adjusts the PWM output accordingly. The current in the loop is measured and recorded.
A 1°C temperature increase corresponds to
(20 mA – 4 mA)/550 = 0.029029 mA.
Table 1. Temperature and Expected Current
|Temperature in °C
||Expected current in mA
||4 mA + 0.029029 mA
||20 mA - 0.029029 mA
These results show that after calibration, the accuracy of the PWM-controlled loop without feedback is better than with the DAC-controlled loop with feedback.
For higher accuracy, the feedback loop could be added. This would require using an ADuCM360 with the second ADC enabled to monitor the loop. This would increase current consumption (ADC0 on), and slow down the response time of the loop.
The update rate of the current loop depends on the CPU and ADC configuration. In the example code, the CPU speed is set to 1 MHz and the ADC frequency at 5 Hz. The ADC converts a number of samples on the RTD and on the thermocouple, before averaging the result. The number of samples is defined by the parameter SAMPLEN0. It is set to 8 by default in the example code. This gives a current loop update rate of 740 ms.
For faster response time of the loop, SAMPLEN0 can be reduced.
When operating normally, the entire circuit consumes 2 mA typically. When held in a reset state, the entire circuit consumes less than 550 μA.
To facilitate low power operation, the ADuCM360/ ADuCM361 core operating speed can be reduced by programming the internal CLKSYSDIV register that enable the low power systems which giving system clock is 8 MHz. Also programming the CLKCON0 register allows the core frequency of 16 MHz to be divided in binary multiples of 2 to 128. In this example code , a clock divide value of 8 is used, giving a core speed of 1 MHz.
The primary ADC is enabled with a gain of 32. The PWM and DAC are also enabled for communication on the loop.
All unused peripherals are disabled in order to minimize current consumption.
Table 2 gives a breakdown of the IDD current consumption for the entire circuit.
Table 2. Typical IDD Values for Components of Temperature Monitor Circuit
||IDD Value at 25°C
ADC1 On, Gain = 32, FADC = 5 Hz
CPU speed = 1 MHz
PWM On. 240 Hz
External reference generated by DAC.
Excitation current value to this figure.
Typical value is 200 µA.
All other peripherals off.
|ADP1720, 3.3 V Output Linear Regulator
OP193, Low Power Op Amp
Total Current Less Excitation Current
|ADR3412||Micro-Power, High-Accuracy 1.2V Voltage Reference|
|ADUCM360||Low power precision analog microcontroller, ARM cortex M3 with dual sigma-delta ADCs
|ADUCM361||Low Power Precision Analog Microcontroller, ARM Cortex M3 with single Sigma-Delta ADC||
|OP193||Precision, Micropower Single Operational Amplifier|
|ADP1720||50 mA, High Voltage, Micropower Linear Regulator||
|ADuCM362||Low Power, Precision Analog Microcontroller with Dual Sigma-Delta ADCs, ARM Cortex-M3||
|ADuCM363||Low Power, Precision Analog Microcontroller with Single Sigma-Delta ADC, ARM Cortex-M3||