Arduino Inductance Meter

Hi!

This project, which should be kind of easy, has stumped me. Hoping for some suggestions as what I could have missed.

I am trying to build a Arduino based inductance meter. I have followed the tutorial at electronoobs.
My problem is that the "pulseIn" function returns 0.000. I have checked the breadboard against the schematics several times. I have verified the components and switched the LM339 for a new one. I have simply run out of possibilities to check.

Link to the tutorial:
Electronoobs Inductance Meter

I have simplified the code (omitted the LCD-panel):

#include <Wire.h>
double pulse, frequency, capacitance, inductance;
void setup(){
  Serial.begin(9600);
  pinMode(11, INPUT);
  pinMode(13, OUTPUT);
  delay(200);
}
void loop(){
  digitalWrite(13, HIGH);
  delay(5);
  digitalWrite(13,LOW);
  delayMicroseconds(500); 
  pulse = pulseIn(11,HIGH,10000);
  Serial.println( pulse );
  if(pulse > 0.01){
    capacitance = 1.E-6; 
    frequency = 1.E6/(2*pulse);
    inductance = 1./(capacitance*frequency*frequency*4.*3.14159*3.14159);
    inductance *= 1E6; 
    Serial.print("High for uS:");
    Serial.print( pulse );
    Serial.print("\tfrequency Hz:");
    Serial.print( frequency );
    Serial.print("\tinductance uH:");
    Serial.println( inductance );
    delay(10);
    }
}

The code loads and runs OK.

Forum software prohibits me from attaching a photo of my breadboard (only one media allowed?), but I connected a scope to the resonator input (from D13) and the LM339 Output (to D11). The waveforms from this measurement is shown here:

This tells me that something is wrong. If I have read the specs LM339 Specs correctly then the output should remain high for the duration of the positive part of the measured wave. What am I missing?

Thanks in advance for any guidance or suggestions as to what to try next.

Thanks, Marie

1 Like

I have attached a photo of the breadboard here:

Thanks, Marie

1 Like

Those are "float" variables. Pulseln() returns an unsigned long.

Thanks! Good catch! They got that wrong in the tutorial too.

The problem continues, though. But pulseIn has changed from 0.000 to 0

Modificed code:

#include <Wire.h>
double frequency, capacitance, inductance;
unsigned long pulse;
void setup(){
  Serial.begin(9600);
  pinMode(11, INPUT);
  pinMode(13, OUTPUT);
  delay(200);
}
void loop(){
  digitalWrite(13, HIGH);
  delay(5);
  digitalWrite(13,LOW);
  delayMicroseconds(500); 
  pulse = pulseIn(11,HIGH,10000);
  Serial.println( pulse );
  if(pulse > 0.01){
    capacitance = 1.E-6; 
    frequency = 1.E6/(2*pulse);
    inductance = 1./(capacitance*frequency*frequency*4.*3.14159*3.14159);
    inductance *= 1E6; 
    Serial.print("High for uS:");
    Serial.print( pulse );
    Serial.print("\tfrequency Hz:");
    Serial.print( frequency );
    Serial.print("\tinductance uH:");
    Serial.println( inductance );
    delay(10);
    }
}

Thanks, Marie

Bread board power rail split


Thanks for posting your properly formatted code in code tags as well as project images. Quite refreshing.

1 Like

Thanks!

It works now!

I am used to the small breadboards. I havn't noticed this at all! This is a rather embarassing mistake!

I really appreciate your help! I have been checking and testing for two days before I asked for help!

Thanks, Marie

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.