enum Scale {uf, nf};
//in nF so we don't have to worry about decimals, and thus our array will be smaller in terms of bytes
//1uf (microfarad)=1000nf (nanofarad)
//unsigned int CommonValues[]={1000, 15000, 22000, 33000, 47000, 68000, 1000, 15000, 2000, 22000, 3000, 33000, 4000, 47000, 5000, 56000, 68000, 7000, 8000, 82000, 10000, 12000, 15000, 16000, 18000, 20000, 21000, 22000, 24000, 25000, 27000, 30000, 33000, 35000, 36000, 39000, 40000, 43000, 47000, 50000, 53000, 56000, 60000, 68000, 72000, 75000, 82000, 88000, 100000, 108000, 120000, 124000, 130000, 140000, 145000, 150000, 161000, 170000, 180000, 189000, 200000, 210000, 216000, 220000, 230000, 233000, 240000, 243000, 250000, 270000, 300000, 320000, 324000, 330000, 340000, 350000, 370000, 378000, 380000, 390000, 400000, 420000, 430000, 450000, 460000, 470000, 480000, 500000, 510000, 520000, 540000, 550000, 560000, 590000, 620000, 645000, 650000, 680000, 700000, 708000, 730000, 800000, 820000, 850000, 860000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 2000000, 2100000, 2200000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000, 3100000, 3300000, 3400000, 3500000, 3600000, 3700000, 3900000, 4000000, 4100000, 4200000, 4300000, 4600000, 4700000, 4800000, 5000000, 5100000, 5400000, 5500000, 5600000, 5800000, 6000000, 6500000, 6800000, 7200000, 7400000, 7600000, 7800000, 8200000, 8300000, 8400000, 8700000, 9000000, 9600000, 10000000, 11000000, 12000000, 13000000, 15000000, 16000000, 17000000, 18000000, 20000000, 22000000, 23000000, 24000000, 25000000, 26000000, 27000000, 28000000, 30000000, 31000000, 32000000, 33000000, 34000000, 36000000, 37000000, 38000000, 39000000, 40000000, 41000000, 47000000, 48000000, 50000000, 55000000, 56000000, 60000000, 62000000, 66000000, 68000000, 76000000};
//unsigned int CommonValues[]={1, 15, 22, 33, 47, 68, 1, 15, 2, 22, 3, 33, 4, 47, 5, 56, 68, 7, 8, 82, 10, 12, 15, 16, 18, 20, 21, 22, 24, 25, 27, 30, 33, 35, 36, 39, 40, 43, 47, 50, 53, 56, 60, 68, 72, 75, 82, 88, 100, 108, 120, 124, 130, 140, 145, 150, 161, 170, 180, 189, 200, 210, 216, 220, 230, 233, 240, 243, 250, 270, 300, 320, 324, 330, 340, 350, 370, 378, 380, 390, 400, 420, 430, 450, 460, 470, 480, 500, 510, 520, 540, 550, 560, 590, 620, 645, 650, 680, 700, 708, 730, 800, 820, 850, 860, 1, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 2, 2100, 2200, 2500, 2600, 2700, 2800, 2900, 3, 3100, 3300, 3400, 3500, 3600, 3700, 3900, 4, 4100, 4200, 4300, 4600, 4700, 4800, 5, 5100, 5400, 5500, 5600, 5800, 6, 6500, 6800, 7200, 7400, 7600, 7800, 8200, 8300, 8400, 8700, 9, 9600, 10, 11, 12, 13, 15, 16, 17, 18, 20, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 47, 48, 50, 55, 56, 60, 62, 66, 68, 76};
unsigned int CommonValues[]={10,15,22,33,47,68,100,150,200,220,300,330,400,470,500,560,680,700,800,820,1000,1200,1500,1600,1800,2000,2100,2200,2400,2500,2700,3000,3300,3500,3600,3900,4000,4300,4700,5000,5300,5600,6000,6800,7200,7500,8200,8800,10000,10800,12000,12400,13000,14000,14500,15000,16100,17000,18000,18900,20000,21000,21600,22000,23000,23300,24000,24300,25000,27000,30000,32000,32400,33000,34000,35000,37000,37800,38000,39000,40000,42000,43000,45000,46000,47000,48000,50000,51000,52000,54000,55000,56000,59000,62000,64500,65000,68000,70000,70800,73000,80000,82000,85000,86000,100000,110000,120000,130000,140000,150000,160000,170000,180000,200000,210000,220000,250000,260000,270000,280000,290000,300000,310000,330000,340000,350000,360000,370000,390000,400000,410000,420000,430000,460000,470000,480000,500000};
//float CommonValuesMultiplier=0.1;
//float CommonValuesMultiplier=100;
float CommonValuesMultiplier=.01;
Scale CommonValues_Scale= nf;
int CommonValuesCount =sizeof CommonValues/sizeof CommonValues[0];
float Tolerance=0.2; //+-20%
//long CommonValue=0;
float Actual_Value_nf;
int totalCommonValues = sizeof(CommonValues) / sizeof(CommonValues[0]);
float CommonValue_nf;
//String ToleranceAmt=Tolerance;
void setup()
{ Serial.begin(9600);
/*
label: 100uf
0 mS 0 microFarads
936 mS 93 microFarads
915 mS 91 microFarads
909 mS 90 microFarads
80 mS 8 microFarads
912 mS 91 microFarads
903 mS 90 microFarads
902 mS 90 microFarads
900 mS 90 microFarads
897 mS 89 microFarads
0 mS 0 microFarads
0 mS 0 microFarads
*/
Get_LabelValue(93,uf);//312 microfarads
//119 microfarads
//Get_LabelValue(119,uf);
// 300µf
//320 T:62.4 min 257.6 max 382.4
//324 T:64.8 min 259.2 max 388.8
//330 T:66 min 264 max 396
// Get_LabelValue(312,uf);//312 microfarads
//label: 330
//registered values
// 221 microFarads
// 336 microFarads
// 227 microFarads
// 339 microFarads
//1123/4=280.75
//get the average???? ergo, if it isn't 0, add to array, if 0, then end array,
//take average then get computer label value
//330*0.2=66
//(66)+330=396
//330-66=264
//Get_LabelValue(5800,nf);
}
void loop()
{
}
//1000nf (nanofarad)=1uf (microfarad)
float Get_LabelValue(float Actual_Value,Scale scale)
{
// Actual_Value_nf=Actual_Value;
CommonValue_nf=0;
float Min=0;
float Max=0;
long microFarads; // floating point variable to preserve precision, make calculations
long nanoFarads;
if(Actual_Value == 0){return 0;}
//Actual_Value_nf=Actual_Value;
//Serial.print("Actual_Value_nfasdfsdaf:");
// Serial.println(String(Actual_Value_nf, 5));
if(scale==nf) { Actual_Value_nf= Actual_Value * 1000; }else if(scale==uf) {Actual_Value_nf= Actual_Value;}else{ return 0;}
// Actual_Value_nf=Actual_Value_nf*CommonValuesMultiplier;
// Serial.print("Actual_Value_nfmultiplier:");
// Serial.println(String(Actual_Value_nf, 5));
//Serial.println(Actual_Value_nf);
//long Min=0;
// long Max=0;
for (int i=0; i<CommonValuesCount; i++)
// for (int i=0; i<10; i++)
{
//CommonValue_nf=CommonValues[i];
//1uf (microfarad)=1000nf (nanofarad)
//CommonValue_nf=CommonValue_nf*CommonValuesMultiplier;
if(CommonValues_Scale==uf)
{
CommonValue_nf=CommonValues[i]*1000;
}
else if ( CommonValues_Scale==nf)
{
CommonValue_nf=CommonValues[i];
}
else
{
return 0;
}
//Serial.print("CommonValuesMultiplier:");
//Serial.println(float(CommonValuesMultiplier));
//Serial.print("CommonValueNF:");
// Serial.println(CommonValue_nf);
CommonValue_nf=CommonValue_nf * CommonValuesMultiplier;
// Serial.print("CommonValueNasdfsadfF:");
//Serial.println(float(CommonValue_nf));
Max=(CommonValue_nf + (Tolerance* CommonValue_nf));
Min=CommonValue_nf - (Tolerance* CommonValue_nf);
// Serial.print("Max:");
// Serial.println(float(Max));
// Serial.print("Min:");
// Serial.println(float(Min));
// Serial.print("Actual_Value_nf:");
// Serial.println(Actual_Value_nf);
if(Actual_Value_nf>=Min && Actual_Value_nf<=Max)
{
Serial.print("CommonValues[i]:");
Serial.println(CommonValues[i]);
Serial.print("CommonValuesnf:");
Serial.println(CommonValue_nf);
Serial.print("Max:");
Serial.println(float(Max));
Serial.print("Min:");
Serial.println(float(Min));
Serial.print("Actual_Value_nf:");
Serial.println(float(Actual_Value_nf));
Serial.print("LabelValue:");
Serial.println(CommonValue_nf);
// Serial.println(""); Serial.println("");
return CommonValue_nf;
}
// Actual_Value
}
Serial.print("LabelValue: UNKNOWN");
return Actual_Value_nf;
}