Arduino Inductance/Capacitance/Resistance Meter

Published

Introduction: Arduino Inductance/Capacitance/Resistance Meter

About: Student of Computer Science, Faculty of Sciences, National Autonomous University of Mexico, I like mechatronics and robotics and programming course, my favorite food is pizza like most, I love pizza

Hello such friends, will show you how to create a measuring inductance, capacitance and resistance using Arduino most commonly the ATmega328P, all programming is thrown into Arduino and components commonly found in our laboratory and will also be very cheap to do so, this meter measures pF to nF and also measuring uH and mH, as well as use a 7805 regulator can be powered from 24V to 6V, I used a 9V battery

Step 1: Material

This is the material to be used.

Integrated:
IC ATMEGA 328P (Arduino UNO / Duemilanove)

LM741

LM393

Regulatory L7805CV

LCD 16X2

Crystal 16MHz

Capacitors:

0.33uF

100nF

2 x 22pF

Polyester 1uF

Resistances:

10K potentiometer

7 x 10K

2 x 220 Ohm

1 M

150 Ohm

330 Ohm

Diodes:

1N4004

Connectors:

Terminal Block 2 pin

4 x MOLEX 100 spent 2 pin

4 pin MOLEX spent 100

4 x Borne

2 x switch

2 x push button chasis

Step 2: Code and Performance

As three functions measuring bone capacitance, inductance and resistance, we must choose we want to do, to choose the function and use 2 bits can count 0-0,0-1,1-0,1-1.

So we use two switch to choose, making them function as a dip switch using them as pull down, to measure inductance is 0-0, 0-1 for capacitance, resistance to 1-0, that's how we choose to measure.

To measure inductance use the LM393 comparator to measure the capacitance the LM741, and to measure resistances easily use a 10k resistor and make a voltage divider.

Suppose we want to calculate R1. We know that R2 has a value of 10k, we know that Vin has a value of 5V (which we usually find in the Arduino environment) and that reading on an analog Vout pin of Arduino is 750.

1.- We know that the resolution of the ADC Arduino is 10 bits, which means that 1024 is possible divisions (2 raised to 10) for an input value between 0V and 5V. So if we put 5V on an analog pin, its value will be 1023 (1024 will not remember that starts counting at 0, not 1); if we put 0V on pin, its value will be 0 and if for example we 2.5V its value will be 511.

Therefore, if the value that gives the reading analog pin in its digital value is 750, we can calculate the Vout, the output voltage of the voltage divider.

>> 5V / 1024 divisions = 0,00488V / division

>> 0.00488 volts / division • 750 divisions = 3.66V

2.-We can already clear R1, that was the question:

>> Vout = (R2 / R1 + R2) • Vin

>> 3.66 V = (10k / R1 + 10k) • 5V

>> R1 + 10k = 10k • 5V / 3.66V

>> R1 = (10k • 5V / 3.66V) - 10k = 3.66KΩ

In general, we can calculate the value of R1 as:

>> R1 = (R2 • Vin / Vout) - R2

The same code is in Spanish documentation, so if you have any questions please say so:

#include LiquidCrystal lcd(13, 8, 7, 5, 4, 2);

#define R_1 A1
#define R_2 A2
#define IND_1 6
#define IND_2 12
#define fuente_pin 11
#define switch_pin 10
#define descarga_pin 9

#define PIN_1 A3
#define PIN_2 A4

//Variables leer pines
int pin_1;
int pin_2;

//Variables para inductometro
double pulso;
double frecuencia;
double capacitancia;
double inductancia;

//Capacimetro
float R = 1.0e6;
float C = 0;
float RC = 0;
long t_inicio = 0;
volatile long t_alto = 0;
long T = 0;
float VCC = 4.50;
float Vref = VCC / 2;
float V0 = 0;
float error_correccion = 40.;
int retardo_delay = 20;

//Variables resistometro
int vR_1 = 0;
int vR_2 = 0;
float Vin = 5;
float Vout = 0;
float Res_1 = 10000;
float Res_2 = 9000000;
float r_1 = 0;
float r_2 = 0;
float Resistor_1[8];
float Resistor_2[5];
float ResArreglo_1;
float ResArreglo_2;

void setup() {
lcd.begin(16, 2);

//Configuracion de pines
pinMode(PIN_1, INPUT);
pinMode(PIN_2, INPUT);
//Configuracion Inductometro
pinMode(IND_1, INPUT);
pinMode(IND_2, OUTPUT);
capacitancia = 0.000001021;
//delay(200);
//Configuracion de Resistometro
pinMode(R_1, INPUT);
pinMode(R_2, INPUT);

//Configuracion Capacimetro
attachInterrupt(1, stop, RISING);
Vref = VCC / 2;
pinMode(fuente_pin, OUTPUT);
digitalWrite(fuente_pin, LOW);
pinMode(switch_pin, INPUT);
pinMode(descarga_pin, INPUT);
}

void loop() {
leerpines();

if (pin_1 == LOW && pin_2 == LOW) {
digitalWrite(IND_2, HIGH);
delay(5);
digitalWrite(IND_2, LOW);

delayMicroseconds(100);

pulso = pulseIn(IND_1, HIGH, 5000);
lcd.clear();
if (pulso > 0.1) {
frecuencia = 1.E6 / (2 * pulso);
inductancia = 1. / (capacitancia * frecuencia * frecuencia * 4.*3.1459 * 3.14159);
inductancia *= 1E6;

lcd.setCursor(2, 0);
lcd.print("INDUCTANCIA:");
//delay(200);
if (inductancia >= 1000) {
lcd.setCursor(0, 1);
int valor = (inductancia / 1000) - 0.5;
lcd.print(valor);
lcd.setCursor(6, 1);
lcd.print("mH");
} else {
lcd.setCursor(0, 1);
int valor_2 = inductancia + 10;
lcd.print(valor_2);
lcd.setCursor(6, 1);
lcd.print("uH");
}
} else if (pulso < 0.1) {
lcd.setCursor(2, 0);
lcd.print("INSERTAR IND");
}
delay(300); } if (pin_1 == LOW && pin_2 == HIGH) {
lcd.clear();
for (int i = 0 ; i <= 7; i++) {
Resistor_1[i] = analogRead(R_1);
ResArreglo_1 = ResArreglo_1 + Resistor_1[i];
}
vR_1 = (ResArreglo_1 / 8.0);
Vout = (Vin * vR_1) / 1023;
r_1 = Res_1 * (1 / ((Vin / Vout) - 1));
lcd.setCursor(2, 0);
lcd.print("RESISTENCIA:");
if (r_1 <= 999) {
lcd.setCursor(0, 1);
lcd.print(r_1);
lcd.setCursor(9, 1);
lcd.print("Omhs");
} else if (r_1 >= 1000) {
r_1 = r_1 / 1000;
lcd.setCursor(0, 1);
lcd.print(r_1);
lcd.setCursor(9, 1);
lcd.print("KOmhs");
}
delay(500);
ResArreglo_1 = 0;
} if (pin_1 == HIGH && pin_2 == LOW) {
lcd.clear();
if (debounce(switch_pin) == LOW)
{
pinMode(descarga_pin, OUTPUT);
digitalWrite(descarga_pin, LOW);
delay(100);
pinMode(descarga_pin, INPUT);
digitalWrite(fuente_pin, HIGH);
t_inicio = micros(); } if (t_alto > 0 && t_inicio > 0 && (t_alto - t_inicio) > 0 )
{
T = (t_alto - t_inicio);
RC = -T / log((Vref - VCC) / (V0 - VCC));
//Vref = VCC/2
//V0 = 0V
C = RC / R; //Valor en uF

lcd.setCursor(0, 0);
lcd.print("C:");
lcd.setCursor(3, 0);
lcd.print(C * 1000, 1);
lcd.setCursor(13, 0);
lcd.print("nF");
lcd.setCursor(0, 1);
lcd.print("C:");
lcd.setCursor(3, 1);
lcd.print(C * 1000000 - error_correccion , 0);
lcd.setCursor(13, 1);
lcd.print("pF"); t_inicio = 0;
t_alto = 0; digitalWrite(fuente_pin, LOW);
delay(2000);
}
}
}void leerpines() {
pin_1 = digitalRead(PIN_1);
pin_2 = digitalRead(PIN_2);
}void stop()
{
t_alto = micros();
}int debounce(int pin)
{
int estado;
int previo_estado;
previo_estado = digitalRead(pin);
for (int i = 0; i < retardo_delay; i++)
{
delay(1);
estado = digitalRead(pin);
if ( estado != previo_estado)
{
i = 0;
previo_estado = estado;
}
}
return estado;
}

Step 3: Circuit, Schematic and Pcb

Here you can see how everything is connected in the schematic, I upload files made with EAGLE.

Hope you find it helpful, any questions or comments let him know, greetings.

3 People Made This Project!

Recommendations

  • Make it Move Contest

    Make it Move Contest
  • Casting Contest

    Casting Contest
  • Oil Contest

    Oil Contest
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

36 Comments

hi

there are some differences between the schematic and the code

A0 pin used in schematic while it doesn't exist in the code and A2 vicevirsa.

1 reply

On Arduino, the code #define IND_2 12 is not in accordance with the schematic diagram. It has to be modified to #define IND_2 14 since it is the A0 and it will work perfectly

Me podría mandar las PCB porque no le entendí muy bien, gracias.

irene35_96@hotmail.com

1 reply

Como podrás ver los archivos se encuentran en el instructable

temp_-1132932694.jpg

in which pins the unkonown resistors ,unknown capacitorsor the unknown inductors will be connected

3 replies

if i want to find an unknown resistance(or capacitance or inductance) ,then in which pins i should connect that element to measure the parameters,

i have already simulated the design in proteus but in LCD It only showing "INSERTAR IND" .

You have to select the combination to measure either inductor, capacitor or resistance, see the previous comments and read in instructable correctly

Buenas noches quisiera saber si me pudiera mandar el como hizo las conexiones de los componentes con los circuitos y este con el arduino.

Gracias.

toca.vargas.sgh@gmail.com

1 reply

I just don't understand what JP1 is. It has connections to it but where do they go???

very nice instructable, i´ll try to make it soon.

A few questions though: why do you assign 4.5V to VCC, for what i understood the voltage is 5V (is the "factor de correción" for that?).

Another is that you define R_2 with pin A2 but i don't see it connected in the schematic.., similar thing with A0 in the inductance part of the schematic.

I would thank if you could please explain how to operate this meter, i don't quite understand the function of the "pulsador" (hablo español, no me refiero a la traducción sino a para que se utiliza)

El LM393 puede ser reemplazado por el LM358?

Muy buen proyecto.

Saludos

6 replies

@lean04

how you solved those questions?

finally, did you make the LC meter?

Pls send me circuit for lc meter pls to my email is aagajibo1449@gmail.com

not yet, i didn't have time. I'll try to do it in the next few months

Hola amigo que bueno que hablas español, lo del voltaje si fue como corrección pero puedes cambiarlo a 5V, pero a mi parecer da mejor los valores el LM393 es un comparador de voltaje puedes usar otro pero de las mismas características, este sirve para medir la inductancia, haciendo los cálculos con la frecuencia, y lo de la resistencia como explique para medir la otra resistencia tenemos que hacer un divisor de voltaje, y el pulsador sirve para mostrar y calcular la capacitancia

hola, gracias por la respuesta. Si utilizo el LM311, hay que cambiar algún valor en el código?

Puedes probar, como solo se usa el comparador derecho del lm393, y el lm311 solo tiene uno, puedes probar y ver que resultados te arroja, y no hay que cambiar nada

amigo la programación me manda muchos errores me puedes ayudara resolverlo porfa

1 reply