Components and supplies
Arduino Nano R3
Apps and platforms
Arduino IDE
Project description
Code
LC Meter
arduino
1// OZOX Elc. 2020 https://youtu.be/eMAkOg5kXIs 2//LCD config 3#include <Wire.h> 4#include <LiquidCrystal.h> 5 6LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 7 8const int inp = 10, outp = 13; 9const int lcd_L = 6, lcd_Back = 7, flag_inp = 8; 10 11int deger = 0; 12int btn_dly = 0; 13int btn_sta = 0; 14int btn_Flag = 0; //Buton durum kaydedicisi. 15int btn_Light = 0; 16double pulse, frequency, capacitance, inductance; 17 18bool islem = false; 19 20void setup() { 21 22 lcd.begin(16, 2); 23 Serial.begin(115200); 24 25 pinMode(lcd_Back, OUTPUT); 26 pinMode(flag_inp, INPUT_PULLUP); 27 pinMode(lcd_L, INPUT); 28 pinMode(inp, INPUT); 29 pinMode(outp, OUTPUT); 30 31 Serial.println("Why hello!"); 32 lcd.clear(); 33 lcd.setCursor(0, 0); 34 lcd.print("OZOX Elc. 2020"); 35 lcd.setCursor(0, 1); 36 lcd.print("Mode:Inductance"); 37 delay(2000); 38} 39 40void loop() { 41 btn_sta = digitalRead(flag_inp); 42 while (btn_sta == 0) 43 { 44 delay(100); 45 btn_dly++; 46 btn_sta = digitalRead(flag_inp); 47 islem = true; 48 } 49 50 if (islem == true) 51 { 52 if (btn_dly > 0 && btn_dly <= 10) 53 { 54 btn_Flag = 0; 55 btn_dly = 0; 56 } 57 else if (btn_dly > 10 && btn_dly <= 20) 58 { 59 btn_Flag = 1; 60 btn_dly = 0; 61 } 62 else if (btn_dly > 20 && btn_dly <= 30) 63 { 64 btn_Flag = 2; 65 btn_dly = 0; 66 } 67 else 68 { 69 btn_dly = 0; 70 islem = false; 71 } 72 } 73 if (btn_Flag == 0) 74 { 75 induc(); 76 } 77 else if (btn_Flag == 1) 78 { 79 capasit(); 80 } 81 else if (btn_Flag == 2) 82 { 83 lcd.clear(); 84 lcd.setCursor(0, 0); 85 lcd.print("-Osman SEN-"); 86 lcd.setCursor(0, 1); 87 lcd.print("Tel:05338250164"); 88 delay(100); 89 } 90 91 if (digitalRead(lcd_L) == HIGH) 92 { 93 digitalWrite(lcd_Back, HIGH); 94 } 95 else 96 { 97 digitalWrite(lcd_Back, LOW); 98 } 99} 100 101void induc() { 102 digitalWrite(outp, HIGH); 103 delay(5);//give some time to charge inductor. 104 digitalWrite(outp, LOW); 105 delayMicroseconds(100); //make sure resination is measured 106 pulse = pulseIn(inp, HIGH, 5000); //returns 0 if timeout 107 if (pulse > 0.1) { //if a timeout did not occur and it took a reading: 108 109 capacitance = 1.E-6; // - insert value here 110 111 frequency = 1.E6 / (2 * pulse); 112 inductance = 1. / (capacitance * frequency * frequency * 4.*3.14159 * 3.14159); //one of my profs told me just do squares like this 113 inductance *= 1E6; //note that this is the same as saying inductance = inductance*1E6 114 //Serial print 115 Serial.print("High for uS:"); 116 Serial.print( pulse ); 117 Serial.print("\ frequency Hz:"); 118 Serial.print( frequency ); 119 Serial.print("\ inductance uH:"); 120 Serial.println( inductance ); 121 delay(20); 122 //LCD print 123 lcd.clear(); 124 lcd.setCursor(0, 0); 125 lcd.print("Mode:Inductance"); 126 127 lcd.setCursor(0, 1); 128 lcd.print("Ind :"); 129 if (inductance <= 999) { 130 lcd.print(inductance); 131 lcd.setCursor(9, 1); 132 lcd.print("uH"); 133 } 134 else { 135 lcd.print(1.E-3 * inductance); 136 lcd.setCursor(9, 1); 137 138 lcd.print("mH"); 139 } 140 delay(20); 141 } 142} 143 144void capasit() { 145 digitalWrite(outp, HIGH); 146 delay(5);//give some time to charge inductor. 147 digitalWrite(outp, LOW); 148 delayMicroseconds(100); //make sure resination is measured 149 pulse = pulseIn(inp, HIGH, 5000); //returns 0 if timeout 150 if (pulse > 0.1) { //if a timeout did not occur and it took a reading: 151 152 inductance = 110.34; // - insert value here 153 154 frequency = 1.E6 / (2 * pulse); 155 capacitance = 1. / (inductance * frequency * frequency * 4.*3.14159 * 3.14159); //one of my profs told me just do squares like this 156 capacitance *= 1E15; //note that this is the same as saying inductance = inductance*1E6 157 //Serial print 158 Serial.print("High for uS:"); 159 Serial.print( pulse ); 160 Serial.print("\ frequency Hz:"); 161 Serial.print( frequency ); 162 Serial.print("\ Capacitance nF:"); 163 Serial.println( capacitance ); 164 delay(20); 165 //LCD print 166 lcd.clear(); 167 lcd.setCursor(0, 0); 168 lcd.print("Mode:Capacitance"); 169 lcd.setCursor(0, 1); 170 lcd.print("Cap :"); 171 if (capacitance <= 980) { 172 lcd.print(capacitance); 173 lcd.setCursor(9, 1); 174 lcd.print("nF"); 175 } 176 else { 177 lcd.print(capacitance * 1.E-3); 178 lcd.setCursor(9, 1); 179 180 lcd.print("uF"); 181 } 182 delay(20); 183 } 184}
Downloadable files
Block Diagram
LCR-Meter_bb.jpg
Shematic Diagram
LCR-Meter_şema.jpg
Proteus Project
All files for the Proteus project.
https://www.girnebelediyesi.co.uk/src/LCR_Meter.rar
Comments
Only logged in users can leave comments