KiCad PCB EDA Suite
eserie.h File Reference

Go to the source code of this file.

Classes

struct  r_data
 
class  eserie
 

Macros

#define E1_VAL
 6 decade E-series values from 10 Ohms to 1M and its associated BOM strings. More...
 
#define E3_ADD
 
#define E6_ADD
 
#define E12_ADD
 
#define MAX_CMB   7442
 

Enumerations

enum  { E1, E3, E6, E12 }
 If BENCHMARK is defined, any 4R E12 calculations will print its execution time to console My Hasswell Enthusiast reports 225 mSec what are reproducable within plusminus 2 percent. More...
 
enum  { S2R, S3R, S4R }
 This calculator suggests solutions for 2R, 3R and 4R replacement combinations. More...
 

Functions

double DoubleFromString (const wxString &TextValue)
 

Macro Definition Documentation

◆ E12_ADD

#define E12_ADD
Value:
{ true, "12R", 12 },\
{ true, "18R", 18 },\
{ true, "27R", 27 },\
{ true, "39R", 39 },\
{ true, "56R", 56 },\
{ true, "82R", 82 },\
{ true, "120R", 120 },\
{ true, "180R", 180 },\
{ true, "270R", 270 },\
{ true, "390R", 390 },\
{ true, "560R", 560 },\
{ true, "820R", 820 },\
{ true, "1K2", 1200 },\
{ true, "1K8", 1800 },\
{ true, "2K7", 2700 },\
{ true, "3K9", 3900 },\
{ true, "5K6", 5600 },\
{ true, "8K2", 8200 },\
{ true, "12K", 12000 },\
{ true, "18K", 18000 },\
{ true, "27K", 27000 },\
{ true, "39K", 39000 },\
{ true, "56K", 56000 },\
{ true, "82K", 82000 },\
{ true, "120K", 120000 },\
{ true, "180K", 180000 },\
{ true, "270K", 270000 },\
{ true, "390K", 390000 },\
{ true, "560K", 560000 },\
{ true, "820K", 820000 }

Definition at line 86 of file eserie.h.

◆ E1_VAL

#define E1_VAL
Value:
{ true, "1K", 1000 },\
{ true, "10K", 10000 },\
{ true, "100K", 100000 },\
{ true, "10R", 10 },\
{ true, "100R", 100 },\
{ true, "1M", 1000000 }

6 decade E-series values from 10 Ohms to 1M and its associated BOM strings.

Series E3,E6,E12 are defined by additional values for cumulative use with previous series

Definition at line 52 of file eserie.h.

◆ E3_ADD

#define E3_ADD
Value:
{ true, "22R", 22 },\
{ true, "47R", 47 },\
{ true, "220R", 220 },\
{ true, "470R", 470 },\
{ true, "2K2", 2200 },\
{ true, "4K7", 4700 },\
{ true, "22K", 22000 },\
{ true, "47K", 47000 },\
{ true, "220K", 220000 },\
{ true, "470K", 470000 }

Definition at line 59 of file eserie.h.

◆ E6_ADD

#define E6_ADD
Value:
{ true, "15R", 15 },\
{ true, "33R", 33 },\
{ true, "68R", 68 },\
{ true, "150R", 150 },\
{ true, "330R", 330 },\
{ true, "680R", 680 },\
{ true, "1K5", 1500 },\
{ true, "3K3", 3300 },\
{ true, "6K8", 6800 },\
{ true, "15K", 15000 },\
{ true, "33K", 33000 },\
{ true, "68K", 68000 },\
{ true, "150K", 150000 },\
{ true, "330K", 330000 },\
{ true, "680K", 680000 }

Definition at line 70 of file eserie.h.

◆ MAX_CMB

#define MAX_CMB   7442

Definition at line 228 of file eserie.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

If BENCHMARK is defined, any 4R E12 calculations will print its execution time to console My Hasswell Enthusiast reports 225 mSec what are reproducable within plusminus 2 percent.

E-Values derived from a geometric sequence formula by Charles Renard were already accepted and widely used before the ISO recommendation no. 3 has been published. For this historical reason, rounding rules of some values are sometimes irregular. Although all E-Values could be calculated at runtime, we initialize them in a lookup table what seems the most easy way to consider any inconvenient irregular rules. Same table is also used to lookup non calculatable but readable BOM value strings. Supported E-series are:

Enumerator
E1 
E3 
E6 
E12 

Definition at line 39 of file eserie.h.

39 { E1, E3, E6, E12 };
Definition: eserie.h:39
Definition: eserie.h:39
Definition: eserie.h:39
Definition: eserie.h:39

◆ anonymous enum

anonymous enum

This calculator suggests solutions for 2R, 3R and 4R replacement combinations.

Enumerator
S2R 
S3R 
S4R 

Definition at line 45 of file eserie.h.

45 { S2R, S3R, S4R };
Definition: eserie.h:45
Definition: eserie.h:45
Definition: eserie.h:45

Function Documentation

◆ DoubleFromString()

double DoubleFromString ( const wxString &  TextValue)

Definition at line 36 of file params_read_write.cpp.

37 {
38  double value = 0;
39 
40  /* Acquire the 'right' decimal point separator */
41  const struct lconv* lc = localeconv();
42  wxChar decimal_point = lc->decimal_point[0];
43  wxString buf( TextValue.Strip( wxString::both ) );
44 
45  /* Convert the period in decimal point */
46  buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
47  // An ugly fix needed by WxWidgets 2.9.1 that sometimes
48  // back to a point as separator, although the separator is the comma
49  buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
50 
51  /* Find the end of the numeric part
52  *(when units are append to the number, remove them)
53  */
54  unsigned brk_point = 0;
55  while( brk_point < buf.Len() )
56  {
57  wxChar ch = buf[brk_point];
58  if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' )
59  || ( ch == '+' ) || ( ch == 'e' ) || ( ch == 'E' ) ) )
60  {
61  break;
62  }
63  ++brk_point;
64  }
65 
66  // Check for strings that cannot qualify as a number
67  if( brk_point == 0 )
68  {
69  return std::nan( "" );
70  }
71 
72  /* Extract the numeric part */
73  if( !buf.Left( brk_point ).ToDouble( &value ) )
74  {
75  return std::nan( "" );
76  }
77  return value;
78 }