README file for maf_cub.c (C)2002 Perry Harrington How to use The program takes 4 command line arguments: input point count, output point count, output min voltage, and output max voltage. input point count is the number of points in your input data file output point count is the desired number of data points to generate from the input data output min voltage is the min x value to output for the generated data points output max voltage is the max x value to output for the generated data points Dataset The only "RULE" about the dataset is that it MUST be ordered. ALL your X values must be in numerical order from LEAST to GREATEST. If you do not order your dataset, the program will emit an error to inform you. If you are rearranging numbers to make them compatible with the input format, it's easy to accidentally mess up the X order. The input dataset can be massaged to produce a desired output dataset. If you are generating a zero based output dataset (where the vmin is 0.0) then you will likely not want any negative output values. To ensure this, make the first line of your input file '0.0, 0.0' without the quotes. As you see in the dataset below, that is what I did to get non-negative results. If you are using the program for general interpolation, like for an NTC thermistor, you don't need to massage the input data. There is an example below showing such an application. Piping This program is designed to work as a filter and can have data piped to and from it. Only the dataset and tag names appear on STDOUT. The input verification data is on STDERR. Input data is fed in STDIN. Examples Here is an example for generating a MAF flow table using the 10 points on the calibration sheet that Pro-Flow shipped with my MAF. [pedward]$ cat maf_data.txt 0.0, 0.0 0.016, 0 0.302, 10.3 0.537, 17.2 0.917, 34.4 2.436, 199.1 3.422, 453.2 3.860, 601.5 4.393, 853.0 4.513, 901.1 4.907, 1150.0 [pedward]$ ./maf_cub 11 30 0.0 5.0 < maf_data.txt vmin = 0.000000 vmax = 5.000000 step = 0.172414 points = 30 /* ( Voltage, Flow ) */ ( 5.0000, 1217.4816 ) ( 4.8276, 1092.6801 ) ( 4.6552, 976.9308 ) ( 4.4828, 888.2458 ) ( 4.3103, 817.7397 ) ( 4.1379, 734.7899 ) ( 3.9655, 649.4869 ) ( 3.7931, 574.1686 ) ( 3.6207, 513.3171 ) ( 3.4483, 460.8804 ) ( 3.2759, 410.8358 ) ( 3.1034, 362.0396 ) ( 2.9310, 315.2585 ) ( 2.7586, 271.2638 ) ( 2.5862, 230.8270 ) ( 2.4138, 194.7188 ) ( 2.2414, 163.4087 ) ( 2.0690, 136.5423 ) ( 1.8966, 113.6258 ) ( 1.7241, 94.1654 ) ( 1.5517, 77.6674 ) ( 1.3793, 63.6379 ) ( 1.2069, 51.5832 ) ( 1.0345, 41.0094 ) ( 0.8621, 31.4316 ) ( 0.6897, 22.9519 ) ( 0.5172, 16.6175 ) ( 0.3448, 11.8453 ) ( 0.1724, 4.4119 ) ( 0.0000, 0.0000 ) Here is an example for generating a complete table of resistance values for an NTC thermistor. The datasets are Temp, Resistance. [pedward]$ cat res1.txt 6.8, 10700 44.6, 5700 55, 3310 58, 3250 71, 2240 80, 1820 91, 1470 109, 1020 114, 900 138, 470 165, 330 170, 310 179, 260 [pedward]$ ./maf_cub 13 15 -40 210 < res1.txt vmin = -40.000000 vmax = 210.000000 step = 17.857143 points = 15 /* ( Voltage, Flow ) */ ( 210.0000, 73.6395 ) ( 192.1429, 180.9900 ) ( 174.2857, 287.7505 ) ( 156.4286, 357.1371 ) ( 138.5714, 463.9298 ) ( 120.7143, 750.3044 ) ( 102.8571, 1164.7104 ) ( 85.0000, 1657.1409 ) ( 67.1429, 2590.0137 ) ( 49.2857, 4356.9180 ) ( 31.4286, 8502.7588 ) ( 13.5714, 10294.7158 ) ( -4.2857, 11336.8848 ) ( -22.1429, 12362.7959 ) ( -40.0000, 13388.7061 )