📜 ⬆️ ⬇️

Nominal rows for JavaScript and GOST-28884-90


Order is chaos that we understand.
Henry Miller
Links
Information:Wiki
PDF GOST
Repository:Github
Npmjs
Source
#!/usr/bin/env node /** * @name nominal.js * @author XGuest <xguest@list.ru> * @link https://github.com/xguest/nominal * @version 2.0.1.0 * @copyright GPL applies. * No warranties XGuest[05.02.2016/09:48:26] nominal[ver.2.0.1.0] * #guid {A645E9CA-BE33-4642-AF0F-B4EF046D31E7} * * @description       *        *  -28884-90,  63 63 * * @param {Number} [a]   -  , *   -  a >= (-1 * b) * undefined -     b * * @param {Number} [b]     * E3, E6, E12, E24, E48, E96, E192. * undefined -     a * * @return {Number|Object}  (a || b) = undefined - Object  *       */ /*eslint complexity: [2, 13]*/ function nominal(a, b) { function lg(a, b) { //    10 return parseInt(Math.log(a) / Math.LN10 * (b || 1), 10); //   } function pg(a, c) { //    10 var d = 25 > b ? 1 : 2; //   /*eslint no-unused-expressions: [2, { allowShortCircuit: true, allowTernary: true }]*/ 0 > a && (d -= a); //   return Number((Math.pow(10, a) * (c || 1)) // c =  .toFixed(0 < d ? d : undefined)); //  } /*eslint no-caller: 0*/ var c, d = {}; // c = tmp_var; d = out_var; if (!b) { //     for (b = 0; 7 > b; b++) { //    c = 3 * Math.pow(2, b); //    d[c] = arguments.callee(a, c); //  } return d; //   } if (!a) { //    for (a = 1; a < b + 1; a++) { //     d[a] = arguments.callee(-1 * a, b); //  } return d; //   } a = 0 > a ? // a < 0   (c = 25 > b ? 0 : 2, -1 * a - 1) : // (c = lg(a), d = lg(a / pg(c), b), d < 0 ? b + d : d); //   for (d = 0; 7 > d; d++) { //   if (b === (3 * Math.pow(2, d))) {d = 8;break;} //    } if (d !== 8 || Math.abs(a) > b) return; //    a = pg(a / b); //    return pg(c, //  {'2.6': 2.7, '2.9': 3, '3.2': 3.3, '3.5': 3.6, '3.8': 3.9, //  '4.2': 4.3, '4.6': 4.7, '8.3': 8.2, '9.19': 9.2}[a] || a); } module.exports = nominal; 
To check the values ​​of the resistors, they asked to find a program, looked at what was on the Internet and decided to write it myself. From the text of the GOST I made a small sample, and according to it, a script. Please express your comments, maybe you missed something or is there a better way?

From GOST

The nominal rows according to GOST-28884-90 are an exponentially increasing sequence of values.
')
They contain 7 rows, with a different tolerance of deviation from the nominal value:
E3> ± 20%, E6 ± 20%, E12 ± 10%, E24 ± 5%, E48 ± 2%, E96 ± 1%, E192 ± 0.5%
The row number determines the total number of elements of the nominal row and the maximum value of the sequence number of the element.
For example, E3 - 3 elements from 1 to 3 ... E192 - 192 elements from 1 to 192.

The value of the formula: c = 10 ^ ((a - 1) / b)
a is the ordinal number of the element
b is the nominal range (3 * 2 ^ n), n is a number from 0 to 6,
c - face value.

To obtain the nominal value, the value of the table is multiplied by 10 to the power n:
n is any positive or negative number.

Exceptions:
For the series from E3 to E24, the calculated values ​​of 2.6, 2.9, 3.2, 3.5, 3.8, 4.2, 4.6 are less by 0.10, the value of 8.3 is more by 0.10 of the row nominal.
For the E192 row, the calculated value of 9.19 is less by 0.01 of the row nominal.

Values ​​in decimal, for rows:
- from 3 to 24: 9.10 - 1 degree,
- from 48 to 192: 988.00 - 3 degree

The inverse index formula by value: a = lg (s) * b + 1
a is the ordinal number of the element
b is the nominal row
c - face value.

The rule of transition of the logarithm to a new base.
log_a (b) = log_d (b) / log_d (a)
 function log(a, b) {return Math.log(b) / Math.log(a);}; 

Well, that seems to be all.
Good luck to all.
Xguest

Source: https://habr.com/ru/post/277221/


All Articles