Math
Moderators: David Barker, Jerry Messina
Mast if you send me the data in excel format ([email protected]) I can make a 10 bit look up table in matlab that you can use pretty easily.
Thank you ohararp,
but with ds18s20, i have more accuracy, i need -15 + 120 °c, and with the ntc it's difficult to have this without problem. after 2 days on web, i see the ds18s20 is better. i need to make inside a ctn sensor car, a ds18s20 !.
Mast
but with ds18s20, i have more accuracy, i need -15 + 120 °c, and with the ntc it's difficult to have this without problem. after 2 days on web, i see the ds18s20 is better. i need to make inside a ctn sensor car, a ds18s20 !.
Mast
ohararp wrote:Mast if you send me the data in excel format ([email protected]) I can make a 10 bit look up table in matlab that you can use pretty easily.
If a lookup table isn't going to do the job for you, would something like this math unit be a possible solution?
http://www.micromegacorp.com/umfpu-v3.html
http://www.micromegacorp.com/umfpu-v3.html
-
- Registered User
- Posts: 185
- Joined: Mon Mar 10, 2008 8:20 am
- Location: Seattle, WA USA
- Contact:
Have you looked atsample code section on the web page? The following sounds exactly like what you are trying to do:
Thermistor Linearisation Using a Stein-Hart Equation. Written by TimBox. A Thermistor linearisation program using a Stein-Hart equation, originally written for the PROTON compiler by Les Johnston.
http://www.sfcompiler.co.uk/wiki/pmwiki ... rtEquation
Thermistor Linearisation Using a Stein-Hart Equation. Written by TimBox. A Thermistor linearisation program using a Stein-Hart equation, originally written for the PROTON compiler by Les Johnston.
http://www.sfcompiler.co.uk/wiki/pmwiki ... rtEquation
-
- Registered User
- Posts: 185
- Joined: Mon Mar 10, 2008 8:20 am
- Location: Seattle, WA USA
- Contact:
-
- Registered User
- Posts: 185
- Joined: Mon Mar 10, 2008 8:20 am
- Location: Seattle, WA USA
- Contact:
Here is the matlab code to generate a lookup file for Tim in PDS. It could be easily converted to SF. The idea is to use matlab's math functions to generate a LUT of our choosing. It's super handy and I use this quite a bit.
Code: Select all
% Tim LUT
clc
clear
close all
;
offset = 80
data = 0:1024-offset;
result = data.^2;
result = result/max(result)*(1024-offset)+offset;
result = round([0:79 result]);
% Plot Fit
plot(0:1024,result,'.-')
xlabel('AD Input')
ylabel('Cdata Output')
grid on
axis tight
%------------------------------------------------------
% Print Out Table
%------------------------------------------------------
fid=fopen('lin_exp_pot.bas','w');
fprintf(fid,'lin_exp_pot: Cdata ');
fprintf(fid,'%3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d,_\n',result(1:15));
fprintf(fid,'%3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d, %3d,_\n',result(16:length(result)));
fclose(fid);
Code: Select all
lin_exp_pot: Cdata 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,_
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,_
30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,_
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,_
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,_
75, 76, 77, 78, 79, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,_
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 81, 81, 81,_
81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 82, 82,_
82, 82, 82, 82, 82, 82, 82, 82, 82, 83, 83, 83, 83, 83, 83,_
83, 83, 83, 84, 84, 84, 84, 84, 84, 84, 84, 85, 85, 85, 85,_
85, 85, 85, 86, 86, 86, 86, 86, 86, 87, 87, 87, 87, 87, 87,_
88, 88, 88, 88, 88, 89, 89, 89, 89, 89, 90, 90, 90, 90, 90,_
91, 91, 91, 91, 91, 92, 92, 92, 92, 93, 93, 93, 93, 94, 94,_
94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 97, 98,_
98, 98, 98, 99, 99, 99, 100, 100, 100, 100, 101, 101, 101, 102, 102,_
102, 103, 103, 103, 104, 104, 104, 104, 105, 105, 105, 106, 106, 106, 107,_
107, 107, 108, 108, 108, 109, 109, 110, 110, 110, 111, 111, 111, 112, 112,_
112, 113, 113, 114, 114, 114, 115, 115, 115, 116, 116, 117, 117, 117, 118,_
118, 119, 119, 119, 120, 120, 121, 121, 122, 122, 122, 123, 123, 124, 124,_
125, 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, 129, 130, 130, 131,_
131, 132, 132, 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138,_
139, 139, 140, 140, 141, 141, 142, 142, 143, 143, 144, 144, 145, 145, 146,_
146, 147, 147, 148, 148, 149, 149, 150, 151, 151, 152, 152, 153, 153, 154,_
154, 155, 156, 156, 157, 157, 158, 158, 159, 160, 160, 161, 161, 162, 162,_
163, 164, 164, 165, 165, 166, 167, 167, 168, 168, 169, 170, 170, 171, 172,_
172, 173, 173, 174, 175, 175, 176, 177, 177, 178, 179, 179, 180, 180, 181,_
182, 182, 183, 184, 184, 185, 186, 186, 187, 188, 188, 189, 190, 191, 191,_
192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 200, 200, 201, 202,_
202, 203, 204, 205, 205, 206, 207, 208, 208, 209, 210, 211, 211, 212, 213,_
214, 214, 215, 216, 217, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224,_
225, 226, 227, 227, 228, 229, 230, 231, 231, 232, 233, 234, 235, 235, 236,_
237, 238, 239, 239, 240, 241, 242, 243, 244, 244, 245, 246, 247, 248, 249,_
249, 250, 251, 252, 253, 254, 255, 255, 256, 257, 258, 259, 260, 261, 262,_
262, 263, 264, 265, 266, 267, 268, 269, 270, 270, 271, 272, 273, 274, 275,_
276, 277, 278, 279, 280, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,_
290, 291, 292, 293, 294, 295, 295, 296, 297, 298, 299, 300, 301, 302, 303,_
304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318,_
319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333,_
334, 335, 336, 337, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349,_
350, 351, 352, 353, 354, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365,_
366, 368, 369, 370, 371, 372, 373, 374, 375, 376, 378, 379, 380, 381, 382,_
383, 384, 385, 387, 388, 389, 390, 391, 392, 393, 395, 396, 397, 398, 399,_
400, 402, 403, 404, 405, 406, 407, 409, 410, 411, 412, 413, 415, 416, 417,_
418, 419, 421, 422, 423, 424, 425, 427, 428, 429, 430, 431, 433, 434, 435,_
436, 438, 439, 440, 441, 443, 444, 445, 446, 448, 449, 450, 451, 453, 454,_
455, 456, 458, 459, 460, 461, 463, 464, 465, 466, 468, 469, 470, 472, 473,_
474, 475, 477, 478, 479, 481, 482, 483, 485, 486, 487, 489, 490, 491, 492,_
494, 495, 496, 498, 499, 500, 502, 503, 504, 506, 507, 508, 510, 511, 513,_
514, 515, 517, 518, 519, 521, 522, 523, 525, 526, 528, 529, 530, 532, 533,_
534, 536, 537, 539, 540, 541, 543, 544, 546, 547, 548, 550, 551, 553, 554,_
556, 557, 558, 560, 561, 563, 564, 566, 567, 568, 570, 571, 573, 574, 576,_
577, 579, 580, 581, 583, 584, 586, 587, 589, 590, 592, 593, 595, 596, 598,_
599, 601, 602, 604, 605, 607, 608, 610, 611, 613, 614, 616, 617, 619, 620,_
622, 623, 625, 626, 628, 629, 631, 632, 634, 635, 637, 638, 640, 641, 643,_
645, 646, 648, 649, 651, 652, 654, 655, 657, 659, 660, 662, 663, 665, 666,_
668, 670, 671, 673, 674, 676, 677, 679, 681, 682, 684, 685, 687, 689, 690,_
692, 693, 695, 697, 698, 700, 702, 703, 705, 706, 708, 710, 711, 713, 715,_
716, 718, 720, 721, 723, 724, 726, 728, 729, 731, 733, 734, 736, 738, 739,_
741, 743, 744, 746, 748, 750, 751, 753, 755, 756, 758, 760, 761, 763, 765,_
766, 768, 770, 772, 773, 775, 777, 778, 780, 782, 784, 785, 787, 789, 791,_
792, 794, 796, 798, 799, 801, 803, 805, 806, 808, 810, 812, 813, 815, 817,_
819, 820, 822, 824, 826, 827, 829, 831, 833, 835, 836, 838, 840, 842, 844,_
845, 847, 849, 851, 853, 854, 856, 858, 860, 862, 863, 865, 867, 869, 871,_
873, 874, 876, 878, 880, 882, 884, 885, 887, 889, 891, 893, 895, 897, 898,_
900, 902, 904, 906, 908, 910, 912, 913, 915, 917, 919, 921, 923, 925, 927,_
929, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 951, 953, 955,_
957, 959, 961, 963, 965, 967, 969, 971, 973, 975, 977, 979, 981, 982, 984,_
986, 988, 990, 992, 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014,_
1016, 1018, 1020, 1022, 1024,