SQ003104E008 ML610Q400 Series Sample Program AP Notes For Humidity Calculation Module 2nd edition Issue Date : January 27, 2010 NOTICE No copying or reproduction of this document, in part or in whole, is permitted without the consent of LAPIS Semiconductor Co., Ltd. The content specified herein is subject to change for improvement without notice. The content specified herein is for the purpose of introducing LAPIS Semiconductor's products (hereinafter "Products"). If you wish to use any such Product, please be sure to refer to the specifications, which can be obtained from LAPIS Semiconductor upon request. Examples of application circuits, circuit constants and any other information contained herein illustrate the standard usage and operations of the Products. The peripheral conditions must be taken into account when designing circuits for mass production. Great care was taken in ensuring the accuracy of the information specified in this document. However, should you incur any damage arising from any inaccuracy or misprint of such information, LAPIS Semiconductor shall bear no responsibility for such damage. The technical information specified herein is intended only to show the typical functions of and examples of application circuits for the Products. LAPIS Semiconductor does not grant you, explicitly or implicitly, any license to use or exercise intellectual property or other rights held by LAPIS Semiconductor and other parties. LAPIS Semiconductor shall bear no responsibility whatsoever for any dispute arising from the use of such technical information. The Products specified in this document are intended to be used with general-use electronic equipment or devices (such as audio visual equipment, office-automation equipment, communication devices, electronic appliances and amusement devices). The Products specified in this document are not designed to be radiation tolerant. While LAPIS Semiconductor always makes efforts to enhance the quality and reliability of its Products, a Product may fail or malfunction for a variety of reasons. Please be sure to implement in your equipment using the Products safety measures to guard against the possibility of physical injury, fire or any other damage caused in the event of the failure of any Product, such as derating, redundancy, fire control and fail-safe designs. LAPIS Semiconductor shall bear no responsibility whatsoever for your use of any Product outside of the prescribed scope or not in accordance with the instruction manual. The Products are not designed or manufactured to be used with any equipment, device or system which requires an extremely high level of reliability the failure or malfunction of which may result in a direct threat to human life or create a risk of human injury (such as a medical instrument, transportation equipment, aerospace machinery, nuclear-reactor controller, fuel-controller or other safety device). LAPIS Semiconductor shall bear no responsibility in any way for use of any of the Products for the above special purposes. If a Product is intended to be used for any such special purpose, please contact a ROHM sales representative before purchasing. If you intend to export or ship overseas any Product or technology specified herein that may be controlled under the Foreign Exchange and the Foreign Trade Law, you will be required to obtain a license or permit under the Law. Copyright 2009 - 2011 LAPIS Semiconductor Co., Ltd. Contents 1. OVERVIEW............................................................................................................................................ 1 2. HUMIDITY CALCULATION MODULE .............................................................................................. 2 2.1. 2.2. 2.3. 2.4. 2.5. 2.6. 3. FUNCTION OVERVIEW ......................................................................................................................... 8 OPERATING CONDITIONS ..................................................................................................................... 8 SAMPLE PROGRAM .............................................................................................................................. 9 FLOWCHART OF HUMIDITY CALCULATION ..........................................................................................11 TYPICAL PERIPHERAL CIRCUIT DIAGRAM ......................................................................................... 12 HOW TO PREPARE THE HUMIDITY RATIO - HUMIDITY CONVERSION TABLE ....................................... 13 CELSIUS FAHRENHEIT CONVERSION MODULE........................................................................ 16 3.1. 3.2. FUNCTION OVERVIEW ........................................................................................................................ 16 OPERATION CONDITION .................................................................................................................... 16 i 1. Overview This document describes the application programming notes (hereafter called the AP notes) arranged to help customers develop software that, by using the RC-ADC, which is hardware that the ML610Q400 Series MCU (hereafter called the MCU) has, performs humidity sensor measurements. APIs are provided for each function module. The AP notes describe the functions and operating conditions of each API and samples of use of those APIs. In connection with the AP notes, a sample program is provided that actually operates using APIs. on ML610Q400 Series Demo Kit. * This AP note also describes about “Celsius Fahrenheit conversion module” that is included in the sample program in the section 3. Related Documents The following are the related documents. Read them as required. ML610Q400 Series Sample Program AP Notes For Sensor/Mesurement Application ML610Q400 Series Sample Program API Manual ML610Q431/ML610Q432 User’s Manual ML610Q411/ML610Q412/ML610Q415 User’s Manual ML610Q421/ML610Q422 User’s Manual ML610Q482 User’s Manual ML610Q400 Series Demo Kit Hardware User’s Manual nX-U8/100 Core Instruction Manual MACU8 Assembler Package User’s Manual CCU8 User’s Manual CCU8 Programming Guide CCU8 Language Reference DTU8 User’s Manual IDEU8 User’s Manual uEASE User’s Manual uEASE Connection Manual ML610Qxxx FWuEASE Flash Writer Host Program User’s Manual LCD Image Tool User’s Manual 1 2. Humidity calculation module Humidity is measured from the resistor value of humidity sensor. The variable band of resistance value is from several hundred ohm to several mega ohm. Therefore, to fix measurement time, use Resistance Measurement Method 1(*). And humidity sensor has the temperature characteristics like the figure below. By making use of this characteristics, calculate humidity. First, calculate humidity of 25 degrees centigrade as base, second revise humidity using current temperature. (*) For detailed description, refer “ML610Q400 Series Sample Program AP Notes For Sensor/Mesurement Application”, topic ‘How to Measure Resistance Value’ of chapter 3.2 RC-ADC Control Module. 100000 Resistance (K ohm) 10000 1000 25°C 5°C 45°C 100 10 1 0 20 40 60 80 100 Relative Humidity (%RH) Figure 2-1 The characteristic graph for resistance – humidity (C10-M53R, Shinyei Technology) 2 %rh 0°C 5°C 10°C 15°C 20°C 25°C 30°C 35°C 40°C 45°C 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 38000 14000 5012 2017 1014 544 313 183 104 63.8 38 23.5 15.8 10.6 7.41 5.3 24000 8619 3367 1469 751 406 230 139 80.2 49.3 29.9 18.4 12.3 8.32 5.49 4 14000 5821 2251 1076 583 320 183 111 62.5 37.8 23.8 15.3 10.2 6.89 4.85 3.5 8664 3870 1615 815 437 246 142 86.3 50.4 30.5 18.9 12.3 8.21 5.55 4.1 3 5549 2500 1248 649 352 191 112 66.2 39.2 24.3 15.4 10.3 7.18 4.82 3.37 2.5 3900 1880 960 495 270 150 87 50.2 31 19.8 13 8.65 5.8 4 2.9 2.11 2920 1401 734 380 213 121 68.7 40.1 24.9 16.2 10.5 7.42 5.09 3.49 2.57 1.9 2203 1126 579 322 177 98 55.9 33.8 19.9 13.2 9.04 6.37 4.35 3.09 2.26 1.7 1760 852 461 247 135 77.4 44.8 27.6 17.5 11.7 8.04 5.74 3.93 2.8 2.04 1.5 1304 699 353 193 108 63.8 37.8 24.5 15 10.2 7.03 5 3.42 2.41 1.8 1.35 * The data in the shade field is not a standard data. Figure 2-2 The characteristic table for resistance – humidity (C10-M53R, Shinyei Technology) 3 50°C 1098 571 294 160 87.5 49.9 30.7 19.8 13 8.8 6.01 4.26 3.02 2.1 1.55 1.17 Unit:Kohm First, the measured humidity range, the desired resolution, and the measured state need to be determined. They must be determined by taking the functions and specification of the product that uses the MCU into account. When these are determined, the value of humidity sensor Rh, connected to the microcomputer, the reference resistor Rs and the reference capacitor Cs must be determined. Select a humidity sensor by taking its characteristics and the used environments into account. The value of Rs is defined by the humidity sensor. In this case of the humidity sensor which the sample program uses, the value of Rs is 150Kohm. For more detail, please see the section “2.6.1. Selection of the reference registor”. You must select enough capacity to gain the required oscillation frequenceis by CR oscillation. Select Rh, Rs and Cs so that the oscillation frequencies within the measured temperature range can be measured within the specification of the RC-ADC of the MCU. For instance, the following setting is acceptable: If VDD = 3 V and Cs = 820 pF, Rh must be 1 kΩ or more. If VDD = 1.5 V and Cs = 820 pF, Rh must be 2 K or more. For detailed description, refer the chapter “RC Oscillation Type A/D Converter” of the User’s Manual for your target MCU. Next, make the conversion table between humidity and humidity-ratio.This humidity-ratio is the ratio of the below two counter value. a) The number of counter which is gained by the RC oscillation between Rt(humidity sensor) and Cs within base time(This sample program uses 500ms. b) The number of counter which is gained by RC oscillation between Rs(Base side) and Cs within same base time. Define each symbol is as follows: Rh: the resistor of humidity sensor H: Humidity frclk: the oscillation frequency by CR oscillation between Rh and Cs fsclk: the oscillation frequency by CR oscillation between Rs and Cs. Humidity-ratio (H-ratio) can calculate by frclk/fsclk. Note: This sample program multiplies the humidity-ratio by 1024 because of the calculation by an integer. (If the humidity-ratio is 1024, the humidity is 50% at 25 degrees centigrade because the oscillation frequency of Rh is equivalent to Rs) The humidity changes by the temperature. For example, although if the humidity-ratio is 1024 at 25 degrees centigrade, the humidity will be 45%, if the temperature is 45 degrees centigrade, the humidity will be approximately 36%. Similarly, if the temperature is 5 degrees centigrade, the humidity will be 54%. This sample program calculate the humidity by the below procedure. 1 Find the humidity of 25 degrees centigrade. 2 If current temperature is lower than 25 degrees centigrade, find the humidity of 5 degrees centigrade. 3 If current temperature is 25 degrees centigrade or higher, find the humidity of 45 degrees centigrade. 4 The difference between the humidity of 5 or 45 degrees centigrade and the humidity of 25 degrees centigrade divided 20 makes the humidity per 1 degree centigrade. 5 Find current humidity by the below calculation. Current humidity = the humidity of 25 degrees + (the difference between current temperature and 25 degrees centigrade * humidity per 1 degree centigrade) 4 Resistor(Rt) Resistor(Rh) Humidity(H) Characteristic of H-Hratio Fig2-3 How to make the characteristic of H-rasio - H From the Rh-H characteristics, resistance r1 for h1 is obtained. Next, from the Rh– H-rasio characteristics, find n1 (n1 = base count value (@150Kohm)/the count value for r1 * 1024) Similarly, n2 and n3 for h2 and h3, respectively, can be obtained. The humidity(H)– Humidity ratio (H-ratio) characteristics can be then obtained using the above information. Repeat the above procedure, make the humidity raito table of 25 degrees centigrade, the upper limit table and lower limit table of temperature where the revised calculation is needed. This sample program is using the table for 5 degrees centigrade and 45 degrees centigrade. 5 The H-ratio – H characteristics are converted to multiple linear approximation formulas. Moreover store multiple linear approximation formulas to revise humidity at 25 degrees centigrade by temperature in the program. The approximation formula can be made by considering the following: 1 The maximum error between the linear approximation and the actual characteristics must be smaller than the desired accuracy. 2 The slope of the linear approximation must be less than the desired maximum resolution of temperatures. 3 The linear approximation must be stored within the program area. The following are examples of linear approximation. The H– H-ratio characteristics are divided into several intervals (4 portions in this example). Draw a straight line in each interval as a linear approximation. Linear approximations can be expressed by the following: Approximation characteristics of H – H-ratio Humidity Humidity Characteristics of h5 h4 H – H-ratio h5 h4 h3 h3 h2 h2 h1 h1 H25 = a45×(H-ratio – n4) + h4 H25 = a34×(H-ratio – n3) + h3 n1 n2 n3 n4 n5 H-ratio H25 = a23×(H-ratio – n2) + h2 n1 n2 n3 n4 n5 H-ratio An enlarged e graph 6 H25 = a12×(H-ratio – n1) + h1 Here, the maximum error between the linear approximation and actual characteristics is defined as “e”. If “e” is larger than the maximum error for measuring humidity, it is necessary to make a finer portion and redo the approximation procedure. When all the program ROM areas are exhausted because there are too many approximate formulas, reduce the number of approximate formulas by sacrificing accuracy. The approximate formulas can be input as the ROM table data. items: The ROM table data are composed of the following 3 H-ratio Slope a(5,25,45 degrees) Offset h(5,25,45 degrees) After finding the humidity using 25 degree’s table, decide applied expression h1 or hh from H-TEMP characteristics. And calculate the humidity using applied expression. Determine data length (= number of places) for the desired operation accuracy. 7 2.1. Function overview The humidity calculation module calculates the humidity value from the converted result of RC-ADC and measured temperature based on the frequency ratio(that is, humidity ratio) – humidity conversion table of the humidity sensor for C10-M53R made by Shinyei Technology. If you change the humidity sensor, change this conversion table corresponded with the using humidity sensor. Table2-1 Humidity calculation module API Function name Function humid_calc Calculate the humidity from the counter value of RC-ADC and temperature. 2.2. Operating conditions This section describes operating conditions, valid range, restrictions of this module. -Valid temperature measurement range -Humidity measurement range :0~50 degrees centigrade (display character ‘–‘ of humidity means that temperature is not within 0~50 degrees centigrade ) :20~95% For the reference resistor Rs, 150K ohm is selected. Its resistance value is the same as the resistance value of the humidity sensor at the condition of temperature 25 degrees centigrade and humidity 45%. The following table shows the Humidity ratio - Humidity conversion table. Table.2-1-2 Humidity ratio - Humidity Conversion Table If you use this table in the program, use the shade field as data. Table address 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Humidity at 25 °C 105-95 95-80 80-75 74-70 69-60 59-55 54-45 44-40 39-35 34-30 29-25 24-20 19-18 17-16 Humidity ratio 72796 26482 17757 11815 4954 3059 1024 568 310 160 81 39 17 6 25 °C Slope 25 °C 264 340 601 882 1528 2767 5151 11520 20275 34882 66961 123894 123894 123894 Offset 25 °C 99614720 83886080 78643200 73400320 62914560 57671680 47185920 41943040 36700160 31457280 26214400 20971520 18299932 16884929 45 °C 8 Slope 45 °C 202 328 676 945 1469 2795 5227 11444 19269 35107 51425 123894 123894 123894 Offset 45 °C 91328599 76138872 70240883 64628578 54547315 49250937 38609802 33401393 28418816 23142116 19115612 13872732 11201144 9786141 5 °C Slope 5 °C 360 398 577 922 1473 2646 5508 13322 21282 36767 63104 103632 188605 459052 Offset 5 °C 111995687 93548004 88510816 83034525 72927554 67913477 56699923 50637041 45133928 39607742 34666863 30281395 26214400 20971520 2.3. Sample program The below flowchart explains the procedure of humidity measurement using the humidity calculation module. Main routine Get the oscillaton counter value of reference resistor RS1-CS1(Refer ‘AD conversion procedure’) Get the oscillaton counter value of sensor RT1-CS1(Refer ‘AD conversion procedure’) Calculate Humidity (Humid-calc function) Fig2-4 Procedure of getting humidity [Main routine] z Change the circuit for the humidity sensor when the temperature measured. z If the temperature is not within valid measurement range(50.1 degrees centigrade and up or under 0 degrees centigrade), skip the measurement procedure, and display ‘- -%’. 1)Get the value of oscillation count for reference resistor RS1-CS1 Get the value of oscillation count for reference resistor RS1-CS1 (value of Counter B) 1 Mode of RC oscillation circuit: RS-CS oscillation mode 2 Base clock of counter A(BSCLK):LSCLK 3 Setting value of counter A: the base value of oscillation count for reference resistor RS-CS (at interval of 500mS) 4 Setting value of counter B: 0 2)Get the value of oscillation count for sensor RT1-CS1 Get the value of oscillation count for sensor RT1-CS1 (value of Counter B) 1 Mode of RC oscillation circuit: RT-CS oscillation mode 2 Base clock of counter A(BSCLK):LSCLK 3 Setting value of counter A: the base value of oscillation count for reference resistor RS-CS (at interval of 500mS) 4 Setting value of counter B: 0 3)Humidity calculation Calculate the value of temperature by humid_calc function using the above mentioned oscillation count. *For detailed procedure, refer “ML610Q400 Series Sample Program AP Notes For Sensor/Mesurement Application” Section 3.2.3.1 A/D Conversion Procedure 9 [humid_calc] 1) Get a ratio for base value. 2) Calculate the ratio (H_ratio) from the below expression. H_ratio = (the oscillation count base value of sensor RH-CS / the oscillation count value of sensor RH-CS) × 1024 1024 means the revision for processing the integer calculation. Note that the circuit parameter Rh, Rs and Cs must be selected in advance so that the value of H_ratio can not overflow its range when 1024 is multiplied. Next, search entries of humidity ratio from address 0 in the Humidity ratio–Humidity conversion table until H_ratio is less than an entry of humidity ratio. 3) Calculate the distance between the searched humidity ratio and H_ratio by the following expression. RH_distance = H_ratio - (the searched humidity ratio) 4) Calculate the humidity at 25 degrees centigrade (RH25) by using the slope and offset at 25 degrees centigrade (Slope25 and Offset25), which correspond to the searched humidity ratio. RH25 = (RH_distance × Slope25 + Offset25) >> 20 The value 20 is a multiplier that has already been multiplied to the slope and offset in the Humidity ratio–Humidity conversion table in order to improve calculation accuracy. 5) Calculate the revised humidity RH from current temperature (T). (a)If current temperature is 25 degrees centigrade and over, calculate the humidity at 45 degrees centigrade (RH45) from the entries of 45 degrees centigrade in the Humidity ratio–Humidity conversion table. RH45 = (RH_distance × Slope45 + Offset45) >> 20 Calculate the humidity per temperature 1 degree between 25 and 45 degrees centigrade, and multiple it by the difference between current temperature and 25 degrees centigrade, then it is possible to get current humidity. The expression of this operation is as follows: RH = RH25 - ((RH25 - RH45) / 20) × (T - 25) (b)If current temperature is less than 25 degrees centigrade, calculate the humidity at 5 degrees centigrade (RH5) from the entries of 5 degrees centigrade in the Humidity ratio–Humidity conversion table. RH5 = (RH_distance × Slope5 + Offset5) >> 20 Calculate the humidity per temperature 1 degree between 5 and 25 degrees centigrade, and multiple it by the difference between current temperature and 25 degrees centigrade, then it is possible to get current humidity. The expression of this operation is as follows: RH = RH25 + ((RH5 - RH25) / 20) × (25 - T) *After calculation, if the humidity is 100% and over, the result becomes 100%. And if the humidity is 20% and under, the result becomes 20%. Example: In the case that the temperature is 40 degrees centigrade, a humidity ratio is 4000, it is possible to calculate the humidity by the below procedure. In this case, use table address 5. calculate the humidity at 25 degrees centigrade (RH25) using RH25 = (RH_distance × Slope25 + Offset25) >> 20 RH25 = ((4000 - 3059) × 2767 + 57671680) >> 20 = 57 The temperature is over 25 degrees centigrade. Therefore calculate the humidity at 40 degrees using the 45 degrees centigrade table RH45 = ((4000 - 3059) × 2795 + 49250937) >> 20 = 49 Calculate an objective humidity (RH) from RH25 and RH45. RH=RH25 - ((RH25 - RH45) / 20)× (T - 25) =57 - (57 - 49) / 20× (40 - 25) =57 - 6 =51(%) 10 2.4. Flowchart of humidity calculation humid_calc *hum=0 Search humidity ratio in the table from the first entry. temp<0 or temp>50 RH_distance = RH_ratio – (the searched humidity ratio) YES! ret = -1 exit NO! Calculate the humidity of 25 degrees. RH25=(Slope25*RH_distance + Offset25)>> (coefficient for table revision)) << 16 *Multiply 0x10000 (shifts 16 bits) to improve the precision of calculation. base_ct=0 or Humid_ct=0? YES! temp>=25? NO! ret = -1 YES! exit NO! RH_ratio=(humid_ct <<11)/base_ct, *Multiply 0x400 to improve the precision of calculation. RH_ratio>131281? Calculate the humidity of 45 degrees. RH45=((Slope45 * RH_distance + Offset45)>> (coefficient for table revision)) << 16 Calculate the humidity of 5 degrees. RH5=((Slope5 * RH_distance + Offset5)>> (coefficient for table revision)) << 16 *Multiply 0x10000 (shifts 16 bits) to improve the precision of calculation. *Multiply 0x10000 (shifts 16 bits) to improve the precision of calculation. *hum=(RH25-((RH25-RH45)/20 * (T-25)) >> 16 *hum=(RH25+((RH5-RH25)/20 * (25-T)) >> 16 NO! ret = -1 *hum>=100? exit YES! NO! *hum<=20? YES! *hum=100 *hum=20 NO! ret = 0 exit 11 2.5. Typical Peripheral Circuit Diagram LCD Coin Cell NMI VDD COM0~3 (*) SEG0~63 (*) NMI S1 S2 P00/CAP0 EXVDDV P01/CAP1 EXGND P02 S3 P03 S4 RESET_N ML610Q4xx P30/IN0 P31/CS0 CX Cd Cc Cb Ca VDDX P32/RS0 VL4 P33/RT0 VL3 P34/RCT0 VL2 P35/RCM VL1 P44/IN1 C4 P45/CS1 C34 P46/RS1 C3 C2 1/4 Bias P47/RT1 CS0 CVR0 RS0 RT0 CS1 CVR1 RS1 RT1 C12 C1 XT0 CGL AVDD AVref XL CDL AVSS XT1 32.768KHz Xtal P22 /MD0 P43 P41 P40 P42 P43 /RXD /TXD AIN0 (Output) /SCL /SDA Buzzer ICL2332 GND R1In T1Out 4 3 V+ 2 GND TXD RXD V- WP SCL SDA 9-pin D-SUB A0 A1 CV :1uF :1uF CL0 :0.1uF CL1 :1uF C1 CX :0.1uF Ca,Cb,Cc,Cd :1uF :1uF C12,C34 : No ( 0 pF ) CGL : No ( 0 pF ) CDL Vcc 2 I C EEPROM A2 Vss RS0 CS0 CVR0 RT0 : 10 Kohm : 560 pF : 820 pF : 103AT (Semitec) thermister RS1 CS1 CVR1 RT1 : 150 Kohm : 680 pF : 820 pF : C10-M53R (Shinyei) humidity sensor Fig2-5 Peripheral Circuit Diagram (*) The number of COM/SEG pin that can be connected to LCD panel depends on the type of the LCD driver built into the MCU. Please see the chapter “LCD Driver” of the User’s Manual for your target MCU. For more detail about the peripheral curcuit, please see the “ML610Q400 Series Demo Kit Hardware User’s Manual”. 12 2.6. How to prepare the Humidity ratio - Humidity conversion table 2.6.1. Selection of the reference resistor This humidity calculation module calculates the humidity value by using the frequency count value from RC-ADC oscillation of the humidity sensor and the reference resistor. Therfore it is necessary to estimate the frequency count value of the humidity sensor, in advance. If the frequency count value of the humidity sensor and the reference resistor is the same, we can regard that the humidity sensor and the reference resistor have the same impedance. It means that the frequency count value of the humidity sensor can be estimated as the ratio against the count value of the reference resister, from the humidity-resistance characteristics of the humidity sensor. Example: In the following case, the reference resistor = 150 Kohm the frequency count value of the humidity sensor = 2040 the frequency count value of the reference resistor = 1024 the ratio of frequency count (the humidity sensor / the reference resistor) is about 2. The impedance of the humidity sensor can be estimated to be about 300 Kohm. * About the way of calculating the frequency count value from the resistance (impedance), refer to the chapter “RC Oscillation Type A/D Converter (RC-ADC)” of the User’s Manual for your target MCU. For the sample program, the resister of 150 Kohm is selected as the reference resistor so that the ratio of frequency count is 1 on the condition that temparature is 25 degrees centigrade and humidity is 45%rh. 2.6.2. Conversion from the Humidity-Resictance chracteristic to the Humidity-Count ratio charateristic To estimate the RC-ADC frequency count value and calculate the humidity at each temparature (25, 45 and 5 degrees centigrade), follow the procedure below. 1. 2. 3. 4. Calculate the RC-ADC frequency count value of the reference resistor (150 Kohm), from the Humidity-Resistance characteristic at 25 degrees centigrade. Similarly, calculates the RC-ADC frequency count value of other impedances. Then, calculate the ratio (A) against the count value that was calculated in the above procedure 1, and make the approximation formula (f25). Extract the impedance of the humidity sensor from the Humidity-Resistance characteristic at 45 degrees centigrade. Then, calculates the RC-ADC frequency count value and the ratio against the count value of the reference resistor for each impedance of the humidity sensor. Make the the approximate formula (f45) of the Humidity-Count ratio characteristic, from the result of the above procedure 3. Example: %rh 40 45 50 55 60 Count ratio against the Impedance reference at 45°C resistor 250 100 500 60 1000 37 2000 24 4000 15 13 Humidity Humidity-Count ratio characteristic (45°C) 60 55 50 f45=a60×(Count ratio – n4)+f45(n4) 45 f45=a55×(Count ratio – n3)+f45(n3) 40 f45=a50×(Count ratio – n2)+f45(n2) n1 n2 n3 n4 f45=a45×(Count ratio – n1)+f45(n1) n5 Count ratio 5. Similarly, extract the impedance of the humidity sensor from the Humidity-Resistance characteristic at 5 degrees centigrade. Then, calculates the RC-ADC frequency count value and the ratio against the count value of the reference resistor for each impedance of the humidity sensor. From this result, make the the approximate formula (f5) of the Humidity-Count ratio characteristic. Note: If the RC-ADC frequency count value is not enough to calcurate the count ratio, it is necessary to consider adjusting the reference registor and the capacitor (Cs). 2.6.3. Making up into a table for humidity calculation By the following procedure, calculate the slope and offset of the approximate formula of the Humidity-Count ratio characteristic for 25, 45and 5 degrees centigrade, and make up them into a table. The resistance at the condition that temparature is 25 degrees centigrade and humidity is 45%rh is selected as the reference register, and the count ratio against this reference registor is searched in the table. Therefore it is necessary to calculate the humidity for 45 and 5 degrees centigrade, that corresponds to each entry of the count ratio in the Humidity-Count ratio characteristic for 25 degrees centigrade. 1. From the approximate formula (f45), calculate the humidity f45(n25), which corresponds to each entry of the count ratio in the Humidity-Count ratio characteristic for 25 degrees centigrade. Exampe: %rh 40 45 50 55 60 Entry of count ratio in 25°C characteristic n25 320 750 1200 2050 4010 Range of count ratio in 45℃ characteristic 250<= x < 500 500 <= x < 1000 1000 <= x < 2000 2000 <= x < 4000 Slope Offset a4540 a4545 a4550 a4555 b4540 b4545 b4550 b4555 14 When the count ratio is 320, the humidity at 45 °C is : f45(320) = a4540 * (320-250) + b4540 When the count ratio is 2050, the humidity at 45 °C is : f45(2050) = a4555 * (2050-2000) + b4555 By the above procedure, the humidity at 45 degrees centigrade, which corresponds to each entry of the count ratio in the Humidity-Count ratio characteristic for 25 degrees centigrade, is caluculated as follows. Humidity 2. Humidity–Count ratio characteristic (45°C) 60 55 50 45 40 250 500 1000 320 750 1200 2000 2050 4000 Count ratio Entries of count ratio in 25°C characteristic 3. Similarly, calculates the humidity at 5 degrees centigrade, which corresponds to each entry of the count ratio in the Humidity-Count ratio characteristic for 25 degrees centigrade. 4. Make up the following data into a table. The count ratio at 25 degrees centigrade, that was calculated at the procedure 2 in the chapter 2.6.2.(A) The slope in the Humidity-Count ratio characteristic at 25 degrees centigrade. The offset in the Humidity-Count ratio characteristic at 25 degrees centigrade. The slope in the Humidity-Count ratio characteristic at 45 degrees centigrade. The offset in the Humidity-Count ratio characteristic at 45 degrees centigrade. The slope in the Humidity-Count ratio characteristic at 5 degrees centigrade. The offset in the Humidity-Count ratio characteristic at 5 degrees centigrade. 15 3. Celsius Fahrenheit conversion module 3.1. function overview This module converts from Fahrenheit to Celsius. Table3.1 API list Function name convertCtoF_asm function Convert from Celsius degrees centigrade to Fahrenheit degrees centigrade. 3.2. Operation condition This section describes operating conditions, valid range, restrictions of this module. Calculation range :105.0~-50.0 degrees centigrade [Note] U8 has a powerful ’Decimal adjustment instruction’. And this instruction is so useful for this module. However, CCU8 compiler does not support this instruction. So, this module is made by assembler language. By using’ Decimal adjustment instruction’ and shift operation, it is possible to process this conversion effectively See the below description for more detail. Operation overview Transform the expression to process faster like the below: 1F=9/5C+32=1.8C+32 // Decompose 1.8C to C+8/10C 21.8C=C+8C/10=C+((C+C)×2)×2/10 // 8 can transform to 2x2x2. Then it is possible to use shift operation instead of multiple operation. 3if C>=0 then F= (C+((C+C)×2)×2/10)+32 else F=32-(C+((C+C)×2)×2/10) end 16 Revision History 17 Revision History Edition Page Isuue Date Contents Before After 1 June 26, 2009 – – First Edition 2 January 27, 2010 5 2 Description about the resistance mesurement method, which is used by the temperature calculation module, is corrected. 18