+ Reply to Thread
Page 1 of 3
1 2 3 Last
Results 1 to 15 of 44

Thread: Some of the E24 values are wrong!

  1. #1
    Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent
    Join Date
    Apr 2006
    Location
    England
    Posts
    11,826

    Some of the E24 values are wrong!

    I've being trying to write a program that calculates the nearest set of parallel or series resistors to a specified value.

    One thing that's made it more difficult is that the some E24 values deviate from the geometric sequence.

    Correct rounded geometric sequance:
    10
    11
    12
    13
    15
    16
    18
    20
    22
    24
    26
    29
    32
    35
    38
    42
    46

    51
    56
    62
    68
    75
    83
    91

    E24 values
    10
    11
    12
    13
    15
    16
    18
    20
    22
    24
    27
    30
    33
    36
    39
    43
    47

    51
    62
    68
    75
    82
    91

    Why couldn't they have just stuck to the rounded geometric sequence?

    The E192 values also differs too but it's not too bad, 920 instead of 919. I don't know why it's not like they're rounding to the nearest decade when they have 301.

    I don't suppose anyone cares, just letting off steam.

    I do not answer private messages asking for help because no one else can: benefit from advice I may give or correct me if I'm wrong.

    Please ask on the open forum if you have a question and I'll be happy to help,
    if I know the answer.


  2. #2
    Krumlink Excellent Krumlink Excellent Krumlink Excellent Krumlink Excellent Krumlink Excellent
    Join Date
    Aug 2007
    Location
    Michigan, USA
    Posts
    2,093
    Blog Entries
    1

    Probably so they could still use some of the E12 values. Imagine how many 2.7k and 330 ohm resistors are out there!
    IF YOU WANT TO HELP FINE IF NOT PLEASE DON"T PEE IN MY CHEERO'S

  3. #3
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Why would not been in an exact geometric sequence make any difference to your program?.

    As suggested, it's probably because it's an extension of E12.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  4. #4
    Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent
    Join Date
    Apr 2006
    Location
    England
    Posts
    11,826

    Even if it's an extension of the E12 series, it's still wrong because the E12 series was wrong: 27, 33, 39, 47, 82 are all wrong.

    It does make a difference for the program: the formula R(i,b) = 10^{\frac{i}{b}} generates incorrect values.

    The first part of the program just gets the nearest E24 value, it works but because of the errors, I've had to fiddle it so it generates the right values.

    I do not answer private messages asking for help because no one else can: benefit from advice I may give or correct me if I'm wrong.

    Please ask on the open forum if you have a question and I'll be happy to help,
    if I know the answer.

  5. #5
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Quote Originally Posted by Hero999 View Post
    It does make a difference for the program: the formula R(i,b) = 10^{\frac{i}{b}} generates incorrect values.
    Why on earth would you be using some weird formula? - use a lookup table for exact values - it's only 24 entries!.

    I think I mentioned before, years back (pre-Windows) I wrote a program for parallel resistors. Just give it a value, and it displayed the most accurate results using two resistors in parallel - plus the percentage of error for each combination.

    Unfortunately it was on a long defunkt DOS 386 laptop, but it wasn't a very long program, and was written in Turbo Pascal.
    Last edited by Nigel Goodwin; 23rd May 2009 at 07:26 PM.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  6. #6
    Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent Hero999 Excellent
    Join Date
    Apr 2006
    Location
    England
    Posts
    11,826

    It's not just E24 values I'm doing it for the E192 values too. In the end I want to make it so you can choose between E3, E6, E12, E24, E48, E96 and E192 values.

    There's nothing weird about that formula, it's just a standard geometric sequence, i is the index and b is the base. For example to calculate the 21th E48 value R = 10^(21/48) = 2.74.

    To get the index from the value, transpose the formula. i = 48*log10(2.74) = 21.

    If the value is not an exact E value then all we need to do is round the result to the nearest integer and it gives the index of nearest E value.

    i = 48*log10(2.7) = 20.7 = 21.

    I am using look up tables. The formula creates all the values and the above transposition of the formula indexes the tables. I could have used a search to find the value but that would probably have proven slow on the E192 values.

    First the arrays are filled with E24 and E192 values and which are fiddled so they equal the standard EA values.

    The program requests the desired value from the user.

    The transposition of the origional formula is used to index the array to get the nearest value.

    This is compared with the mantissa, if it's too big the next smallest value is used, if it's too bit the next largest value is used.

    I'm using old QBasic because it's the only language I know. You can still download it from the MS website and there's an open-source clone FreeBasic which is 95% QB compatible.

    Here's the program:
    Code:
    DEFINT A-Z ' Set default variable type to integer.
    DIM SHARED values(1 TO 216)' An array for the E24 values and E192 values.
    DIM SHARED lgb10 AS DOUBLE ' Define log10 so we don't have to recalculate it.
    lgb10 = LOG(10)
     
    CLS
     
    FOR n = 1 TO 24 ' Calculate the E24 values.
     values(n) = 10 ^ (1 + n / 24)
     IF n >= 10 AND n <= 16 THEN values(n) = values(n) + 1 'Fiddle to fit E24
     values(n) = values(n) * 10
    NEXT
    values(22) = 820' Fiddle to fit E24
     
    FOR n = 1 TO 192
     values(n + 24) = 10 ^ (2 + n / 192)
    NEXT
    values(209) = 920' Fiddle to fit E192
     
    FOR n = 1 TO 24
     PRINT values(n)
    NEXT
     
    INPUT "Enter value"; value#
     
    lgval# = LOG(value#) / lgb10' Take log10 of the value.
     
    ex = INT(lgval#)' Exponent is the integer part of log 10 of the value.
     
    dec#= lgval# - ex' store the decimal part of log10.
     
    el = dec#* 24' Work out the nearest preferred number.
     
    mnt = 10 ^ (2 + dec#)' get the mantissa.
     
    ex = ex - 2' Preferred numbers in the array are multiplied by 100 so /100.
     
    IF el = 0 THEN ' If zero, wrap round to highest value and /10 to compensate.
     ex = ex - 1
     el = 24
     mnt = mnt * 10
    END IF
     
    
    ' A fiddle to align the result to the preferred number.
    dif = values(el) - mnt' The difference between the ideal and preferred value.
    IF el > 1 THEN IF dif > mnt - values(el - 1) THEN el = el - 1
    IF el < 24 THEN IF dif < mnt - values(el + 1) THEN el = el + 1
     
    PRINT "Index"; el
    PRINT "Mantissa"; mnt
    PRINT "Exponent:"; ex
    PRINT "Nearest E24 Value"; values(el) * 10 ^ ex
    
    Just for referance, here's a program which finds the nearest E96 value. E96 values are just a standard geometric sequance so no silly tweaking or look-up tables are required. Look at how much simpler the program is. I could have done it all in one line if I'd wanted to.

    Code:
    DIM lg10 AS DOUBLE
    DEFINT A-Z
    
    lg10 = LOG(10)
    INPUT "Enter value"; r#
    
    lg10r# = LOG(r#) / lg10
    
    ex = INT(lg10r#)
    
    PRINT ex
    
    E96 = CINT(10 ^ (2 + CINT(96 * LOG(10 ^ (lg10r# - ex)) / lg10) / 96)) * 10 ^ (ex - 2)
    PRINT E96
    
    For those who don't know QBasic.

    CINT rounds the number to an integer, i.e CINT(9.6) = 10 and INT converts the number an integer simply by removing all the decimal places, i.e INT(9.6) = 9.

    When a interger variable is set to a floating point value, it's just rounded to the nearest integer.

    LOG is the natural logarithm, there's no way to to Log to the base x in QB, you have to do LOG(n)/LOG(b).
    Last edited by Hero999; 24th May 2009 at 12:03 AM.

    I do not answer private messages asking for help because no one else can: benefit from advice I may give or correct me if I'm wrong.

    Please ask on the open forum if you have a question and I'll be happy to help,
    if I know the answer.

  7. #7
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Quote Originally Posted by Hero999 View Post
    I am using look up tables. The formula creates all the values and the above transposition of the formula indexes the tables. I could have used a search to find the value but that would probably have proven slow on the E192 values.
    Tables are incredibly fast, FAR faster than any maths you might be doing, I don't see any reason for a formula at all, which as you say, doesn't work anyway.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  8. #8
    Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent
    Join Date
    Oct 2006
    Location
    Rochester, NY U.S.
    Posts
    9,650
    Blog Entries
    1

    Why create the tables on the fly? Are you that short on eeprom or data flash space?
    "Because I be what I be. I would tell you what you want to know if I
    could, mum, but I be a cat, and no cat anywhere ever gave anyone a
    straight answer, har har."

  9. #9
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Quote Originally Posted by Sceadwian View Post
    Why create the tables on the fly? Are you that short on eeprom or data flash space?
    On a PC?
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  10. #10
    Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent Sceadwian Excellent
    Join Date
    Oct 2006
    Location
    Rochester, NY U.S.
    Posts
    9,650
    Blog Entries
    1

    Woah... I missed that he was doing this on a PC just kind of went in one eye and out the other typical for me.

    Yeah, no point in using a calculation when you can just drop in a static table for something like that.
    Last edited by Sceadwian; 25th May 2009 at 04:10 AM.
    "Because I be what I be. I would tell you what you want to know if I
    could, mum, but I be a cat, and no cat anywhere ever gave anyone a
    straight answer, har har."

  11. #11
    Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent
    Join Date
    Nov 2007
    Location
    Phetchabun,Thailand
    Posts
    3,302

    With QBasic you might put entire look-up tables in data lines to read on request.

    Still faster than Turbo-Pascal.

    Boncuk
    Proper Planning Prevents Piss Poor Performance

  12. #12
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Quote Originally Posted by Boncuk View Post
    With QBasic you might put entire look-up tables in data lines to read on request.

    Still faster than Turbo-Pascal.
    So you think interpreted QBasic is faster that compiled Turbo Pascal

    You've obviously never used Turbo Pascal, it compiles blindingly fast, and runs blindingly fast.

    The Borland Turbo range of compilers were named that for good reason, incredible speed from them, particularly the Pascal version.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  13. #13
    Mikebits Excellent Mikebits Excellent Mikebits Excellent Mikebits Excellent Mikebits Excellent Mikebits Excellent Mikebits Excellent
    Join Date
    May 2008
    Location
    San Diego, Ca
    Posts
    3,842
    Blog Entries
    2

    Will Qbasic programs even run on windows?
    Last edited by Mikebits; 25th May 2009 at 11:07 AM.
    Pay it forward.
    www.geoepicenter.com

  14. #14
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,371

    Quote Originally Posted by Mikebits View Post
    Will Qbasic programs even run on windows?
    Same applies to Turbo Pascal, both are DOS only - but may run in a DOS window. Anything compiled with Turbo Pascal may also need the EXE file patching, if it uses the delay() function - as faster processors mean the original code isn't capable of working, the delay loops exceed their maximum capacity - same for all the Borland Turbo series.

    But you can download a simple patch program, that rewrites the EXE file.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  15. #15
    Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent Boncuk Excellent
    Join Date
    Nov 2007
    Location
    Phetchabun,Thailand
    Posts
    3,302

    Quote Originally Posted by Nigel Goodwin View Post
    So you think interpreted QBasic is faster that compiled Turbo Pascal
    Sorry Sir, I don't think it. I know it.

    We made a speed test simply using a stop watch for the same math problem to be executed using Turbo Pascal and QBasic.

    There were some complicated formulas involved to calculate a certain retirement payment for a certain time and how many years someone would have to save a certain amount of money in monthly deposits to have the money "consumed" after the time period calculated for.

    QBasic was the winner - almost double speed.
    Proper Planning Prevents Piss Poor Performance

+ Reply to Thread
Page 1 of 3
1 2 3 Last

Similar Threads

  1. Resistor Values
    By MrDEB in forum Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 21st May 2008, 03:49 AM
  2. A/D Values
    By Omar.M in forum Micro Controllers
    Replies: 0
    Latest: 16th April 2007, 10:56 PM
  3. Resistor values......
    By madmikejt12 in forum General Electronics Chat
    Replies: 12
    Latest: 11th October 2005, 04:12 PM
  4. need a circuti with values
    By samratyuvi in forum General Electronics Chat
    Replies: 15
    Latest: 23rd September 2005, 11:06 PM
  5. How to compare values?
    By Lac in forum Micro Controllers
    Replies: 7
    Latest: 26th January 2005, 03:45 PM

Tags for this Thread