Please help me understand this code

Excellent, JohnLincoln. And thank you all for the replies.

My project is a coil Q measurement device using the ring down method. It uses hardware to measure and create an interval pulse (rising, high, falling) during which a number of coil oscillations get counted. The circuit has two outputs that become inputs into the Arduino. One is the interval pulse on pin 2, the other is the train of pulses to be counted. With high Q coils, the maximum number of pulses counted would be 250-300. Low Q coils might have a count of 50.

Yes, the measuring frequency is 1 MHz. Actually there are three coil/capacitor combinations to be measured at three resonant frequencies, 500 kHz, 1 MHz, and 1.5 MHz, hence my stated range of 1-2 MHz. The code developer gave the working pulse reading as 250 nS, which is 4 MHz, so I figured this would work.

I don't have a function generator, but I know how to use a 555 timer to make a pulse debouncer and will do that for my next testing.

And thank you, johnLincoln, for testing the code and demonstrating its limits. If I don't like how it performs in the MHz ranges, I can add a hardware frequency divider and compensate for it in the Arduino. But having to do that kind of defeats the purpose of directly using the Arduino's internal timers to speed things up, doesn't it.

To be clear, did you simply remove the line " Serial << "Ready ... "; "

1 Like