LC Meter with 32 bit maths

by Cristi Morariu


Cristi's email about the 32 bit LC Meter

Hi, Phil, my best wishes for the new year! I closed the LC-meter project in December but due to end of the year hollydays i didn't find the time to post you the latest information. I try to do it now, before i switch to other projects. Here is a list of all the enhancements that i made and a short explanation of every of them:
LC006d32  FEATURES:
                        -32 bit float math **
                        -rounding of displayed result **
                        -24 bit (using interrupts) counter for frequency ** 
                        -theoretical precision for 0.4s gate time is 0.007pF and 0.05 uH **
                        -measure precision extended to 0.01 pF, 0.1nH **
                        -two range / four scales
                        -calibration constant for every scale in EEPROM
                        -oscillators frequency test
                        -display and change calibration constants from LC-meter keys **
     ** NEW (december 2006) features
  1. 32 bit float math - looking closely to the Microchip math routines i found that they were written to optimize speed at the expense of code consumption. I did the compression of the code by three means: first, i skipped the 'shortcuts' written to avoid computation bit by bit of null mantissa bytes, second i skipped the code which was written to round the result, because anyway the ROUND option wasn't used in LC-meter software and third, i made as subroutines some sequences of code which were repeated more than 2 times. I compressed the code without deleting any line of program but defining 2 variables and installing some "ifdef"s. ;#define FPROUND ;^& define if round of binary result is used ;#define FAST ;^& define if speed prevails code consumption The modified math lib is in file FP32modi.ASM. The difference in speed of computation isn't noticeable in this application. Most of the time is spent while gate is open and frequency acquisition is done. Declaring both FPROUND and FAST variables, initial fast code will appear untouched. Using 32 bit math i have to extended all precalculated constants and measured values to 32 bit floating point format, also the BCD result area from 8 to 10 digits

  2. rounding of displayed result - after computation, the floating point result is converted to BCD fix point format which is stored in 10 nibbles. Basically the software used to display the 4 most significants digits of the result, and also the measure subunit according to their position in the result stream, truncating the rest of the result. For example if the result was 0004699995 the display showed 46.99 nF. I added a sequence of program which tests the truncated part of the result and adjusts the displayed digits accordingly, by rounding . So after rounding, the display will show in this version of software 47.00 nF.

  3. 24 bit (using interrupts) counter for frequency - being able to work with 32 floating points numbers, the program is now able to handle integers of 32 bits as result of frequency measure. Due to working frequency limitations of oscillator, gate time requested to acquire such huge numbers will be extremely long. I modified the frequency acquisition routine to be able to get frequency numbers up to 24 bits long, up from 16. However i decided to get 'only' a 18 bit number as a result of frequency measure, extending gate time 4 times. I declared a constant in program N_Gate which can be easily modified to obtain more accurate (but more time consuming) frequency measures. Note that the modification of N_Gate requests modification of L_cal also.

  4. theoretical precision for 0.4s gate time, 0.007pF and 0.05 uH - results as a consequence of the 18 bit resolution of frequency measure

  5. measure precision extended to 0.01 pF, 0.1nH - due to the extension of theoretical precision. Note that last digit may fluctuate one unit due to hardware components and connections instability. Long measured component leads are also a reason At this stage i think a good PCB project will improve stability.

  6. two range / four scales - range LOW/HIGH by switching oscillators. C mode to measure capacitances, L mode to measure inductances. LOW is always the range which measures lowest values, so for low range in C mode 1000pF oscillator is used and low range in L mode uses the 10000pF oscillator. High range is indicated on the display by "^" preceding mode letter. The four scales are C, ^C, L and ^L.

  7. calibration constant for every scale in EEPROM - for every scale i defined a constant which adjusts the measured values with a percentage between -10% and +10%. The constant resides in the EEPROM and can be modified in order to align scales or match with a "trustful" meter

  8. oscillators frequency test - holding down RANGE button at power up or holding it down and pressing CALIB will enter a sequence showing oscillators frequency. Pressing RANGE button will show successively F1, F2, ^F1 and ^F2 in kHz

  9. display and change calibration constants from LC-meter keys - holding down RANGE button while in oscillators frequency test will enter display and change cal constants sequence. Switching MODE will show successively the constants for every scale. Memorized constants will be succeded by a "*". To change the value of a constant press RANGE to increment or hold RANGE to scroll through all possible values. Chosen value will be memorized by switching MODE button.

Best regards, Cristi