boylesg
Advanced Member level 4
- Joined
- Jul 15, 2012
- Messages
- 1,023
- Helped
- 5
- Reputation
- 10
- Reaction score
- 6
- Trophy points
- 1,318
- Location
- Epping, Victoria, Australia
- Activity points
- 11,697
#include <Wire.h>
//13 is the input to the circuit (connects to 150ohm resistor), 11 is the comparator/op-amp output.
double frequency, capacitance, inductance;
uint32_t nPulse = 0;
void setup()
{
Serial.begin(115200);
pinMode(11, INPUT);
pinMode(12, OUTPUT);
delay(200);
}
void loop()
{
digitalWrite(12, HIGH);
delay(100);//give some time to charge inductor.
digitalWrite(12,LOW);
//delayMicroseconds(100); //make sure resination is measured
nPulse = pulseIn(11,HIGH,5000);//returns 0 if timeout
if(nPulse > 0){ //if a timeout did not occur and it took a reading:
// #error insert your used capacitance value here. Currently using 2uF. Delete this line after that
capacitance = 10.0; // - insert value here
frequency = 1/(2*(float)nPulse);
inductance = 1/(capacitance*frequency*frequency*4*3.14159*3.14159);//one of my profs told me just do squares like this
//Serial print
Serial.print("High for uS:");
Serial.print( nPulse );
Serial.print("\tfrequency kHz:");
Serial.print( frequency * 1000);
Serial.print("\tinductance uH:");
Serial.println( inductance );
delay(500);
}
}
The response AFTER the pulse has ended will only be a few (<10) cycles and they will rapidly shrink in amplitude. Adding anything in the ground of the tuned circuit will reduce it's 'Q' and make the ringing finish even faster. The circuit isn't very good and I wouldn't expect it to work with small inductances. As a guess, anything below about 2mH will not show at all because the diode and series resistor will be unable to charge the capacitors to any reasonable voltage that the comparator could reliably use.
This line "//delayMicroseconds(100); //make sure resination is measured" is wisely commented out as the entire measurement window might be finished before the delay ended!
The whole method of measuring a brief and decaying waveform is unreliable unless you have very controlled conditions, using an Arduino certainly doesn't fall into that category! Look at this design instead, it appears on many web sites with minor variations but it is reliable and far more accurate than the one you are trying : https://electronics-diy.com/lc_meter.php
Brian.
Before going further, there is a variation of the LM311 on the internet that uses the internal comparator in the 16F628 instead of the external one, it makes the circuit even simpler.
The problem with the original design is it isn't an oscillator, all it does is 'kick' the LC circuit with a single pulse and hope it resonates for long enough to take a period measurement. An LC circuit with higher 'Q' will ring with higher amplitude and for longer so should be more reliable. If you add any resistance in the LC circuit you reduce the Q and instead of measuring the resonant frequency, you measure the tail end of it's own trigger pulse instead.
Brian.
Applying a decade counter like CD4017 would increase the accuracy of measurements for an Arduino.This is the one I had in mind: https://www.electronics-lab.com/project/simple-lc-meter/
I think, but have not tried it, you can make it even simpler by substituting a 16F1847 and using it's internal oscillator.
Brian.
Incidentally that uses a MEGA328 MCU.
Boylesg, I'm not sure what that schematic actually does or how it measures inductance. It seems to be two oscillators, the first driving a divider through an unbiased comparator and the second doing nothing useful at all.
Brad, It's certainly an oscillator but Boylesg is looking for a digital readout of inductance. Without further calculation based on frequency measurement it doesn't move us any further along. I think what he needs is something that you just connect an inductor across and it shows the value.
Incidentally that uses a MEGA328 MCU.
(sorry about the fur on the display - the cat is 'helping' me at the moment!)
Brian.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?