Xilinx XAPP438 CoolRunner-II Low Cost, Low Power Thermometer for Embedded Designs
Application Note: CPLD CoolRunner-II Low Cost, Low Power R Thermometer for Embedded Designs XAPP438 (v1.0) November 29, 2004 Summary This application note describes the implementation of a simple temperature controller in a CoolRunnerTM-II CPLD device. This thermometer uses a minimum of design resources and on board components (resistors, capacitor, and NTC) to measure, observe, monitor or control temperatures. CoolRunner-II devices, the latest CPLD family from Xilinx, offer low power and high performance and come in a variety of sizes. A thermometer or temperature controller can be implemented beside additional designs and provides a low cost method of measuring temperatures.
XAPP438 (v1.0) November 29, 2004 www.xilinx.com 1 1-800-255-7778 © 2003 Xilinx, Inc. All rights reserved. All Xilinx trademarks, registered trademarks, patents, and further disclaimers are as listed at http://www.xilinx.com/legal.htm. All other trademarks and registered trademarks are the property of their respective owners. All specifications are subject to change without notice. NOTICE OF DISCLAIMER: Xilinx is providing this design, code, or information “as is.” By providing the design, code, or information as one possible implementation of this feature, application, or standard, Xilinx makes no representation that this implementation is free from any claims of infringement. You are responsible for obtaining any rights you may require for your implementation. Xilinx expressly disclaims any warranty whatsoever with respect to the adequacy of the implementation, including but not limited to any warranties or representations that this implementation is free from claims of infringement and any implied warranties of merchantability or fitness for a particular purpose. Summary This application note describes the implementation of a simple temperature controller in a CoolRunnerTM-II CPLD device. This thermometer uses a minimum of design resources and on board components (resistors, capacitor, and NTC) to measure, observe, monitor or control temperatures. CoolRunner-II devices, the latest CPLD family from Xilinx, offer low power and high performance and come in a variety of sizes. A thermometer or temperature controller can be implemented beside additional designs and provides a low cost method of measuring temperatures. Introduction Xilinx CoolRunner-II devices provide features, such as Schmidt Trigger inputs, which allow users to implement an easy and simple ADC. This can be used to monitor an analog input value (in this case the temperature) and compute the result in a digital manner for further arrangements. This application consists of four different blocks: · Analog · Analog to Digital Converter · Digital · Monitoring, computing, displaying, or controlling, depending on the application Figure 1: Thermometer Block Diagram The analog portion of the design consists of a sensor, which changes its resistance depending on the temperature. This characteristic changes in the analog to digital converter to a time based variable, which can be handled by a CPLD. How to implement the last part is up to the application, the elicit temperature can be used for a temperature controller, for an overload and overheat protector or it just can be used to display or observe temperatures. All these features are implemented in the same design. The only limitation is the size of the design. Application Note: CPLD XAPP438 (v1.0) November 29, 2004 CoolRunner-II Low Cost, Low Power Thermometer for Embedded Designs R Control BCD CPLD Digital Feedback Analog Part = R*C A/D Converter Display 2 www.xilinx.com XAPP438 (v1.0) November 29, 2004 1-800-255-7778 Description of Parts R Description of Parts Analog Circuit Temperature Range and Reliability The limitation of the temperature range is primarily given by the sensor. Any sensor that changes its resistance depending on temperature can be used for this application. It is up to the user to choose range, accuracy and type of sensor. In this application an NTC is used, as it is a cost efficient solution, and the range is ideal for observing the ambient temperature. Let's look at the following example: General Purpose Thermistors (NTC). For example, from RS Components. · 50 Ohms at 25° C · Resistance tolerance ±10% at 25° C · Maximum ambient temperature up to 125° C For exact details and characteristics see the data sheet: http://rswww.com NTC An NTC is used as sensor in this application. The analog circuit is based on the following term: Tau (time constant) = R (NTC sensor) * C (capacitor) Figure 2: Resistance by Temperature Description of Parts XAPP438 (v1.0) November 29, 2004 www.xilinx.com 3 1-800-255-7778 R As shown in the NTC characteristics of Figure 2, there is a coherence between the temperature and the resistance. See the Monitoring / Computing / Displaying for information on how to adjust the NTC curve. Figure 3: Analog Circuitry The analog part (Figure 3) consists of a sensor and a capacitor. The waveforms on the right show the stimulus (Charge) given from the CPLD and the resulting response (Feedback) resulting from the analog part. Analog to Digital Convertor The easiest way to ascertain t (tau) is to set the threshold (Figure 3). CoolRunner-II provides a feature (Schmitt Trigger) to elicit the threshold. Digital Circuitry The digital part consists of a FSM. Figure 4 shows the Waveforms of the required signals. Figure 4: Required Signals · The CPLD charges (signal Charge) the capacitor through the NTC and counts the clock cycles until the feedback (signal D Feedback) coming from the analog-to-digital converter tells the CPLD that the threshold for t is reached. · The number of counted clock cycles correlates to the temperature (depending on accuracy and temperature range, this can seen as a linear coherence). · When the threshold is reached the signal Charge changes to `0' and the signal Discharge changes from `Z' to `0'. So the current will be discharged through the NTC and the signal Discharge into the CPLD (to protect the CPLD IOB, a resistor on the Feedback signal will limit the current). Charge Feedback Threshold NTC Charge driven from CPLD Feedback/Discharge observed and controlled by CPLD Clock Charge Discharge D Feedback Counter = 3 wait wait z z = 3 4 www.xilinx.com XAPP438 (v1.0) November 29, 2004 1-800-255-7778 Description of Parts R · The FSM will stay in this state for a certain time (for a low power application this time can increase; for a fast response application this value can decrease, but the minimum should not be less then 5 times t to make sure the capacitor is completely discharged). · At this point the FSM begins charging the capacitor with the signal Charge. The signal Discharge changes back to `Z' at the same time. Monitoring / Computing / Displaying This section of the design can be customized for your application. The design can be used for overload protection, or just for observing and/or monitoring the temperature. It is also possible to control the temperature (see “Reliability”). This example shows how to display the temperature on a 7-segment Liquid Crystal Display (LCD): 1. For the most accurate solution create a look-up table (LUT) that correlates clock cycles to temperature (Figure 2). For example: f t is between 5 and 7 clock cycles the temperature corresponds (for example) to 15°C or If t is between 7 and 9 clock cycles the temperature corresponds (for example) to 14°C… 2. Or, an arithmetic expression can be used to evaluate the temperature. Note: To display the temperature, a simple “BIN2BCD” decoder can be used in the design. Note: For an LCD display, a frequency is required to refresh the segments (typically 20 Hz – 50 Hz). Note: For an LED display, see the CoolRunner-II data sheet concerning information on maximum power consumption. Drive a LCD Display To drive an LCD, a clock at the common pin of the display is required. The following example shows how to enable the display: Figure 5: LCD Clocking Calculation The following calculations are for example purposes. The values depend on the temperature range, the specific sensor, and the application. · Choose a value for the NTC: NTC_min = Vcc/I_max where I_max is from the data sheet `IOB'. Example: NTC_min = 3.3 Volts/200 mAmps. = 15.5 Ohms (Choose 50 Ohms at 25°C) · Select a minimum value for the resistor that limits the discharge current at the Feedback and Tau signal: R_discharge_min = VDD33/I_max where I_max is from the data sheet `IOB'. Example: R_discharge_min = approx. 3V/200 mAmps. = 15 Ohms (Choose 100 Ohms) Common Pin Disabled Segment Enabled Segment Reliability XAPP438 (v1.0) November 29, 2004 www.xilinx.com 5 1-800-255-7778 R · Define the range of t which corresponds to the temperature range (t_max – t_min): t_diff = (NTC_range_min * Capacitance) – (NTC_range_max * Capacitance) Example: t_diff = (66 Ohms * 470 uF) – (44 Ohms * 470 uF) = 100 ms. · Define a sample frequency depending on the range of t and accuracy (x defines resolution): F_clock = 1/t_diff * x Example: F_clock = 1/100 ms * 100 = 1 kHz (resolution of 100 in given range). · Define the Time to discharge the capacitor (5 is the recommended minimum value): Wait_min = 5 * (NTC_range_min * Capacitance) Example: Wait_min = 5 * (66 Ohms * 470 uF) = 155 ms. · Define t_25: t_25 = NTC_25 * Capacitance Example: Tau_25 = 50 Ohms * 470 uF = 23.5 ms Why Low Power? · Current consumption at 25° C: I_25 = (VDD/NTC_25) * (t_25/Wait_min) Example: I_25 = (3.3 Volts/50 Ohms) * (23.5 ms/155 ms) = 10 uA maximum. Note: Double the time Wait will halve the current consumption! Note: Additionally, there is some current used by the voltage divider and the CoolRunner-II itself. Reliability The first step to make the system reliable is to make sure the chosen sensor can handle the required temperature range. Further deterioration can be a problem. The influence of ambient temperature (junction temperature of the CoolRunner-II) can carefully be ignored. Test Design Note: This design is a functional example. It can be easily optimized by simple changes, such as using vectors instead of integers, or using the “clock divider” feature. This example is written for a better understanding and therefore not “size optimized.” 6 www.xilinx.com XAPP438 (v1.0) November 29, 2004 1-800-255-7778 Test Design R Behavior Simulation The following simulation shows the detailed function of this application. Figure 6: Behavior Simulation VHDL Code and UCF File THIRD PARTIES MAY HAVE PATENTS ON THE CODE PROVIDED. BY PROVIDING THIS CODE AS ONE POSSIBLE IMPLEMENTATION OF THIS DESIGN, XILINX IS MAKING NO REPRESENTATION THAT THE PROVIDED IMPLEMENTATION OF THIS DESIGN IS FREE FROM ANY CLAIMS OF INFRINGEMENT BY ANY THIRD PARTY. XILINX EXPRESSLY DISCLAIMS ANY WARRANTY OR CONDITIONS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, AND XILINX SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE, THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OR REPRESENTATION THAT THE IMPLEMENTATION IS FREE FROM CLAIMS OF ANY THIRD PARTY. FURTHERMORE, XILINX IS PROVIDING THIS REFERENCE DESIGN “AS IS” AS A COURTESY TO YOU. XAPP438 – http://www.xilinx.com/products/xaw/coolvhdlq.htm Clock Tau Charge Discharge Charge Time Updated Time Wait LCD Clock Display Summary XAPP438 (v1.0) November 29, 2004 www.xilinx.com 7 1-800-255-7778 R How to Connect Sensor and LCD Display to CoolRunner-II Design Kit Figure 7 shows how to connect the Sensor and LCD Display according the .ucf File. Figure 7: Connecting to CoolRunner-II Design Kit Summary CoolRunner-II devices, the latest CPLD family from Xilinx, offer low power and high performance and come in a variety of sizes. A thermometer or temperature controller can be implemented beside additional designs and provides a low cost method of measuring temperatures. Revision History The following table shows the revision history for this document. D Connector of CoolRunner-II DesignKit GND 1 2 VU VDD33 3 4 TAU 5 6 CHARGE 7 8 DISCHARGE 9 10 OSCILL 11 12 DISP 13 14 DISP 15 16 DISP 17 18 DISP 19 20 DISP 21 22 DISP 23 24 DISP 25 26 DISP 27 28 DISP 29 30 DISP 31 32 DISP 33 34 DISP 35 36 DISP 37 38 DISP 39 40 07 1 2 3 4 OSCILL 6 8 9 10 11 12 5 13 OSCILL Sensor CHARGE Discharge Tau Date Version Revision 11/29/04 1.0 Initial Xilinx release. 13>12>11>10>9>8>7>6>5>4>3>2>1>0>