** Electronic Failure Rate FITS and eTCL Slot Calculator Demo Example  **
This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply understeasondably without some background of the correspondent on his WIKI bio page. Thanks,[gold]
----

<<TOC>>
----
**Introduction**

[gold]  Here is some eTCL starter code for calculating the failure rate of electronic devices in failures per billion device-hours or Failures In Time (FIT). This report will use less strict definitions and not consider confidence levels for FIT, since the main interest is developing a simple and quick calculator. The impetus for these calculations was reported failure rates in some light emitting diode (LED) lightbulbs. Most of the testcases involve replicas or models, using assumptions and rules of thumb. 

In planning any software, it is advisable to gather a number of testcases to check the results of the program. The results of the testcases were estimated using the hand calculator and then checked in the eTCL calculator. Additional significant figures are used to check the eTCL calculator, not to infer the accuracy of inputs and product reports. For the 3 testcases, there were sets of trials lasting up to 1000 hours. If the device lasted 1000 hours, a new device was switched in. The first testcase was 592, 642, 595, 1000, and 1000 hours. The hand calculator returned an average failure rate  of 3 failures /(592+ 642+595+ 1000+ 1000) hours, 3/3829, or 0.0007834 failures per hour. Converting,  the failure rate was  0.0007834*1E6, 783.4 failures per million hours and 0.0007834*1E9, 0.783 failures per billion hours (FIT) .  The eTCL calculator returned 0.7349 FITS.   The second testcase was 592, 642, 595, 1000, and 1000 hours. In the hand calculator, the average failure rate  was 3/(592+ 642+595+ 1000+ 1000),3/3737, 0.0008027 failures per hour. The conversion by 1E6 and 1E9 was 802.7 f/1E6 hours and 0.8027 FITS, respectively. On the second testcase, the eTCL calculator returned 0.802 FITS. The third testcase was 3/(644+ 604+650+ 1000+1000) or 0.0007696 failures per hour. The conversion by 1E9 was 0.77 FITS in the hand calculator. The eTCL calculator returned 0.769 FITS for the third testcase. 

The mean time between failures, abbreviated as MTBF, equals 10E9*(1/FIT). The analysis made some trial estimates for MTBF. For the first testcase,  the trial  MTBF is 10E9*(1/FIT),  10E9*(1/0.783), or 12.77E9 hours.  For the second testcase,  the trial  MTBF is 10E9*(1/FIT),  10E9*(1/0.8027), or 12.45E9 hours.  For the third testcase,  the trial  MTBF is 10E9*(1/FIT),  10E9*(1/0.769), or 13.00E9 hours. 

For comparison, the MTBF in the testcases was compared with the understanding of the mean time to failure, MTTF. The MTBF in the first testcase was 5*1000/3, 1666 hours per failure.  The MTTF was 5*1000/5, 1000 hours per failure.
For a disk drive used continuously, the MTBF was 15E5 hours. There were 365 days*24 hours, or 8760 hours in a year.  Converting, the drive MTBF was 15E5 hours/ 8760 hours per year, 171.23 years. The percent failure was (1/ MTBF years)*100., (1/171.23)*100, or 0.5840 percent. Meaning, 0.584 percent of the population or drives in service were expected to fail per the average year. 

For the push buttons in the eTCL calculator, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console.  For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. 
   
 
*** Pseudocode and Equations ***
====== 
  price? = raw materials + labor  +  profit
  price? = raw materials + heat process
  price? = raw materials + labor 
  average price per unit  = revenue  / units sold
====== 
----
***Testcases Section***

**** Testcase 1 ****
%|table 1|printed in| tcl wiki format|% 
&| quantity | value| comment, if any|& 
&| testcase number:|1 | |&
&|  t1 hours til failure:|592.0|   |&
&|  t2 hours til failure:|642.0| |& 
&|  t3 hours til failure:|595.0| |& 
&|  t4 hours til failure:|1000.0|  |&
&|  t5 hours til failure:|1000.0|  |&
&|  t6 hours til failure:|0.00078349|  |&
&|per million :| 783.49 |  |&
&|per billion (FIT):| 0.78349 |  |&

----
**** Testcase 2 ****
%|table 2|printed in| tcl wiki format|% 
&| quantity | value| comment, if any|& 
&| testcase number:|2 | |&
&|  t1 hours til failure:|655.0|   |&
&|  t2 hours til failure:|480.0| |& 
&|  t3 hours til failure:|602.0| |& 
&|  t4 hours til failure:|1000.0|  |&
&|  t5 hours til failure:|1000.0|  |&
&|  t6 hours til failure:|0.00080278|  |&
&|per million :| 802.78 |  |&
&|per billion (FIT):| 0.80278 |  |&

----
**** Testcase 3 ****
%|table 3|printed in| tcl wiki format|% 
&| quantity | value| comment, if any|& 
&| testcase number:|3 | |&
&|  t1 hours til failure:|644.0|   |&
&|  t2 hours til failure:|604.0| |& 
&|  t3 hours til failure:|650.0| |& 
&|  t4 hours til failure:|1000.0|  |&
&|  t5 hours til failure:|1000.0|  |&
&|  t6 hours til failure:|0.0007696|  |&
&|per million :| 769.62 |  |&
&|per billion (FIT):| 0.76962 |  |&

----
***Screenshots Section***
****figure 1.****

[Electronic Failure Rate FITS and eTCL Slot Calculator Demo Example screen.png]
----
***References:***
   
   * Failure rate ref.  Dr. A.K. Nema
   * NIST/SEMATECH e-Handbook of Statistical Methods [http://www.itl.nist.gov/div898/handbook]
----
**Appendix Code**

***appendix TCL programs and scripts ***

======         # TCL source code follows
        # pretty print from autoindent and ased editor        # Electronic failure rate FITS calculator
        # written on Windows XP on eTCL
        # working under TCL version 8.5.6 and eTCL 1.0.1
        # gold on TCL WIKIclub, 20o1dect20148
        package require Tk
        namespace path {::tcl::mathop ::tcl::mathfunc}
        frame .frame -relief flat -bg aquamarine4
        pack .frame -side top -fill y -anchor center
        set names {{} {t1 hours til failure :} }
        lappend names {t2 hours til failure :}
        lappend names {t3 hours til failure :}
        lappend names {t4 hours til failure :}
        lappend names {t5 hours til failure :}
        lappend names {answers: average failure per hour: }
        lappend names {failure per million hours: }
        lappend names {failure per billion hours, FIT:}
        foreach i {1 2 3 4 5 6 7 8} {
            label .frame.label$i -text [lindex $names $i] -anchor e
            entry .frame.entry$i -width 35 -textvariable side$i
            grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 }
        proc about {} {            set msg "Calculator for Electronic Failure Rate FITS V2
            from TCL,
            # gold on TCL club, 1Dec2018 "
            tk_messageBox -title "About" -message $msg }
        proc self_help {} {
            set msg "Electronic Failure Rate FIT V2
            from TCL WIKI,
            w# self help listing
            # problem is Electronic Failure Rate FITS
            # 5 givens follow.
            1) t1 hours til failure
            2) t2 hours til failure
            3) t3 hours til failure
            4) t4 hours til failure
            5) t5 hours til failure
            The  TCL calculator solution is kept in { TCL "precision 17 } to study
            tk_he  algorithms, not to imply accuracy beyond 3 decimal places
            or accuracy beyond the numbers on the textbooks.
            # This posting, screenshots, and TCL source code is
            # copyrighted under the TCL/TK license terms.
            # Editorial rights and disclaimers
            # retained under the TCL/TK license terms
            # and will be defended as necessary in court.
            # >>>>   Push Button Operation <<<<
            # Recommended procedure is push testcase and fill frame,
            # change first three entries etc, push solve,
            # and then push report. Report allows copy and paste
            # from console to conventional texteditor. -For testcases,
            # the testcase number is internal to the "calculator and
            # will not be printed until the report button is pushed
            # for the current result numbers.
            # Where the program defaults are recalled,
            # canvas colors/features/variables/globals/calculations/clear displays
            # are reset prior to calculation  ( in push button list) .
            # Buttons on the calculator are not limited to a single action procedure
            # or single shot. A button command may call mult"iple -statements and procs,
            # effectively a separate program or subprogram installed $as
            # a list of procedures in a button. Alternately, the list of procedures
            # need not be installed in a button, but in a separate procedure.
            Conventional text editor formulas or  grabbed from internet
            screens can be pasted into green console.
            Try copy and paste following into green screen console, rm 1st #
            # set answer [* 1. 2. 3. 4. 5. ] # answer returns 120
            # set factor2 [ expr {(1-1./3)* (1-1./3)} ] # answer 0.4444
            # set factor1 [ expr {(1+1./3)* (1+1./3)} ] # answer 1.7777
            # set factor3 [ expr {(1-1./5)**5} ]  # answer 0.32768
            # set factor4 [ expr {(1+1./5)**5} ]  # answer 4.21399
            # gold on  TCL Club, 1Dec2018 "
            tk_messageBox -title "Self_Help" -message $msg }
        proc calculate {     } {
            global answer2
            global side1 side2 side3 side4 side5
            global side6 side7 side8
            global testcase_number            incr testcase_number 
            set side1 [* $side1 1. ]
            set side2 [* $side2 1. ]
            set side3 [* $side3 1. ]
            set side4 [* $side4 1. ]
            set side5 [* $side5 1. ]
            set side6 [* $side6 1. ]
            set side7 [* $side7 1. ]
            set side8 [* $side8 1. ]            set average_rate [/ 3.  [+ $side1 $side2 $side3 $side4 $side5 ]  ] 
            set side6 $average_rate 
            set side7 [* $average_rate 1.E6 1. ]            set side8 [* $average_rate 1.E6 .001 1. ]                    
                  }
        proc fillup {aa bb cc dd ee ff gg hh} {
            .frame.entry1 insert 0 "$aa"
            .frame.entry2 insert 0 "$bb"
            .frame.entry3 insert 0 "$cc"
            .frame.entry4 insert 0 "$dd"
            .frame.entry5 insert 0 "$ee"            .frame.entry6 insert 0 "$ff" 
            .frame.entry7 insert 0 "$gg"            .frame.entry8 insert 0 "$hh" 
             }
        proc clearx {} {
            foreach i {1 2 3 4 5 6 7 8 } {
                .frame.entry$i delete 0 end } }
        proc reportx {} {
            global side1 side2 side3 side4 side5            global side6 side7 side8 
            global testcase_number
            console show;            console eval {.console config -bg palegreen}
            console eval {.console config -font {fixed 20 bold}}
            console eval {wm geometry . 40x20}
            console eval {wm title . "Electronic Failure Rate Report  , screen grab and paste from console 2 to texteditor"}
            console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
            puts "%|table $testcase_number|printed in| tcl wiki format|% "
            puts "&| quantity | value| comment, if any|& "
            puts "&| testcase number:|$testcase_number | |&"
            puts "&|  t1 hours til failure:|$side1|   |&"
            puts "&|  t2 hours til failure:|$side2| |& "
            puts "&|  t3 hours til failure:|$side3| |& "
            puts "&|  t4 hours til failure:|$side4|  |&"
            puts "&|  t5 hours til failure:|$side5|  |&"            puts "&|  t6 hours til failure:|$side6|  |&"  
            puts "&|per million :| $side7 |  |&"
            puts "&|per billion (FIT):| $side8 |  |&"         }
        frame .buttons -bg aquamarine4
        ::ttk::button .calculator -text "Solve" -command { calculate   }
        ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 592. 642.0 595.0 1000.   1000. .000783 783. .783}
        ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 655. 480.0 602.0 1000.   1000.  8.03E-4 802.78 .8028 }
        ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 644. 604.0 650.0 1000.   1000. 7.69E-4  769.6 0.769 }
        ::ttk::button .clearallx -text clear -command {clearx }        ::ttk::button .self_help -text self_help -command {self_help}
        ::ttk::button .about -text about -command about
        ::ttk::button .cons -text report -command { reportx }
        ::ttk::button .exit -text exit -command {exit}
        pack .calculator  -in .buttons -side top -padx 10 -pady 5        pack  .clearallx .cons .self_help .about .exit .test4 .test3 .test2   -side bottom -in .buttons
        grid .frame .buttons -sticky ns -pady {0 10}
        . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30        wm title . "Electronic Failure Rate FITS  Calculator "
        
        

======

----
----[gold] This page is copyrighted under the TCL/TK license terms, [http://tcl.tk/software/tcltk/license.html%|%this license]. 

**Comments Section**

<<discussion>>Please place any comments here with your wiki MONIKER and date, Thanks.

----                              
<<categories>> Numerical Analysis | Toys | Calculator | Mathematics| Example| Toys and Games | Games | Application | GUI
----
<<categories>> Development | Concept| Algorithm | Statistics