====== 簡易高抵抗測定器 ====== ===== 概要 ===== 前回は、1Ω以下(最小は、約1mΩ)の低い抵抗値を測定する、“簡易低抵抗測定器"を製作しました。 今回は、1MΩ以上(最高は、約100MΩ)の高い抵抗値を測定する、“簡易高抵抗測定器"を製作しました。 ===== 動作原理 ===== 基本的には、オームの法則です。 つまり、未知の抵抗Rxに、電流(I)を流し、そのときのRxの両端の電圧(V)から求めます。 Rx=V÷I <電流(I)の求め方> I=V2÷基準抵抗(R1=9.1MΩ) <電圧(V)の求め方> V=V1-V2 <未知の抵抗(Rx)の求め方> Rx=V÷I ※今回の回路で、重要な役割を果たすのが、オペアンプ(LMC662)です。 このオペアンプの、入力インピーダンスは、1テラΩ以上あります。従って、基準抵抗(R1=9.1MΩ)には、殆ど影響を与えません。 ===== 回路図 ===== {{:imgpaste:202004:htmikan-20200430-125932.png}} ===== ソースコード ===== ※基準抵抗(R1=9.1MΩ)の精度が重要なので、プログラム上は、R1の実測値を反映させています。 ※出来るだけ精度の高い抵抗を使用してください。 //********************************************************************** /*   『簡易高抵抗測定器(High Resistance Meter)』 */ //********************************************************************** #define SW PORTA.F5 //********************************************************************** void main() { static unsigned char buf[20]; static unsigned int cnt; static double v1, v2, ohm, offset; // OSCCON = 0b01110000; // クロックは8Mhz CMCON = 0b00000111; // コンパレータは使用しない。 // A/D変換を使用する。 ANSEL = 0b000000011; ADCON1.VCFG1 = 1; ADCON1.VCFG0 = 0; // ポートを初期化する。 TRISA = 0b11111111; TRISB = 0b00000000; // LCDを初期化する。 Lcd_Custom_Config(&PORTB,7,6,5,4,&PORTB,3,2,1); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); Lcd_Custom_Out(1, 1, "Resistance Meter"); Delay_ms(1000); Lcd_Custom_Cmd(LCD_CLEAR); Lcd_Custom_Chr(1, 12, 0xF4); Lcd_Custom_Out(2, 6, "mV"); Lcd_Custom_Out(2, 14, "mV"); // offset = 1.0; // while (1) { //非測定抵抗の入力電圧(V1)を測定します。 v1 = 0.0; for (cnt = 0; cnt < 5000; cnt++) { v1 += Adc_Read(0); } v1 = (v1 / 5000.0) * 2.44140625; WordToStr(v1, buf); Lcd_Custom_Out(2, 1, buf); // //非測定抵抗の出力電圧(V2)を測定します。 v2 = 0.0; for (cnt = 0; cnt < 5000; cnt++) { v2 += Adc_Read(1); } v2 = (v2 / 5000.0) * 2.44140625; // if (SW == 0) { offset = v1 / v2; // WordToStr(v2, buf); Lcd_Custom_Out(2, 9, buf); LongToStr(offset * 1000000, buf); buf[0] = buf[1]; buf[1] = buf[2]; buf[2] = buf[3]; buf[3] = buf[4]; buf[4] = '.'; Lcd_Custom_Out(1, 1, buf); Lcd_Custom_Chr(1, 12, '%'); // Lcd_Custom_Chr(1, 16, '*'); Delay_ms(100); Lcd_Custom_Chr(1, 16, ' '); Delay_ms(100); continue; } v2 = v2 * offset; WordToStr(v2, buf); Lcd_Custom_Out(2, 9, buf); //非測定抵抗の抵抗値を求めます。 ohm = (v1 - v2) / (v2 / 9800000); //基準となる抵抗の実測値を設定し精度を上げます。 //各値を表示します。 LongToStr(ohm, buf); Lcd_Custom_Out(1, 1, buf); Lcd_Custom_Chr(1, 12, 0xF4); } } //********************************************************************** ===== 動作確認 ===== {{:imgpaste:202004:htmikan-20200430-130132.png?500}} 測定端子を短絡させて、オフセット値を設定します。(SW1を押下します) LCDの表示内容(上側=オフセット比率、左下=V1、右下=V2) {{:imgpaste:202004:htmikan-20200430-130157.png?500}} 実際に測定した、手持ちの高抵抗です。 左側から、1MΩ、2.7MΩ、3.3MΩ、4.7MΩ、9.1MΩです。 {{:imgpaste:202004:htmikan-20200430-130209.png?500}} 1MΩの測定結果です。(右側は、手持ちのテスターの測定結果です) LCDの表示内容(上側=Rxの値、左下=V1、右下=V2) {{:imgpaste:202004:htmikan-20200430-130222.png}}{{:imgpaste:202004:htmikan-20200430-130225.png}} 2.7MΩの測定結果です。(右側は、手持ちのテスターの測定結果です) {{:imgpaste:202004:htmikan-20200430-130259.png}}{{:imgpaste:202004:htmikan-20200430-130302.png}} 3.3MΩの測定結果です。(右側は、手持ちのテスターの測定結果です) {{:imgpaste:202004:htmikan-20200430-130309.png}}{{:imgpaste:202004:htmikan-20200430-130313.png}} 4.7MΩの測定結果です。(右側は、手持ちのテスターの測定結果です) {{:imgpaste:202004:htmikan-20200430-130320.png}}{{:imgpaste:202004:htmikan-20200430-130324.png}} 9.1MΩの測定結果です。(右側は、手持ちのテスターの測定結果です) {{:imgpaste:202004:htmikan-20200430-130342.png}}{{:imgpaste:202004:htmikan-20200430-130346.png}} このページは稲崎様の閉鎖したHPのコピーで、著作権は稲崎様にあります。[[elechobby:picdic:picdic|詳細]] This page is a copy of Mr. Inasaki's closed website, and the copyright is held by him.[[elechobby:picdic:picdic|Details]]