The circuit shown in Figure 1 is a complete loop powered thermocouple temperature measurement system where the 4 mA-to-20 mA output current is controlled using the PWM function of a precision analog microcontroller.
Figure 1. ADuCM360 Controlling 4 mA-to-20 mA Loop-Based Temperature Monitor Circuit. (Simplified Schematic: All Connections and Decoupling Not Shown)
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.
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:
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.Programming, Debugging, and Testing
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.
Figure 2. Source Files Viewed with Keil μVision4. 11386-002
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.Communication Section
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 20 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.
Figure 3. Output of HyperTerminal when Calibrating the PWM
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
This circuit includes the footprint for HART communication and for an external reference.
This document does not cover the temperature sensing section as this is already covered in CN-0300. The focus is in the performance of the temperature-to-current output.PWM Differential Nonlinearity (DNL)
The filtered PWM output DNL was first measured. The DNL graph in Figure 5 shows a better than 0.3 LSB typical performance in the critical 4 mA-to-20 mA range. These tests were conducted with a second order filter on the PWM output. Two 47 kΩ resistors and two 100 nF capacitors were used as shown in Figure 1.
Figure 5. Typical DNL Performance of Circuit
The setup shown in Figure 6 was used to test the communication section of the circuit.
Figure 6. Measurement Setup
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
|Temperature in °C||Expected current in mA|
|-199°C||4 mA + 0.029029 mA|
|+349°C||20 mA - 0.029029 mA|
Figure 7. Error in Current Loop vs. Temperature Readings for DAC Control (CN-0300) and PWM Control (CN-0319)
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.Current Consumption Measurement Tests
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.
|Component||IDD Value at 25°C|
| ADuCM360/ ADuCM361
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