Wednesday 16 2020

Matplotlib Learning Notes - Part 8 (Printing tunnel diode data dictionary)

Matplotlib Learning Notes - Part 8 (Printing tunnel diode data dictionary)

I have debugged the first python program to print out the data in the tunnel diode data dictionary.  The full listing is as below.

This is a raw listing.  A more documented version will be given in the next post.


# diodeplot12.py tlfong01 2020dec16hkt2041

# Description of program

#   Part A - Background

#     1. This Rpi4B Thonny python 3.7.3 program is used for matplotlib newbies to learn how to use the very basic

#        the baisc plotting functions.  

#     2. The tunnel diode I-V measurement dictionary is a list of 33 pairs of I-V numbers, each pair corresponding to

#        a point in the two dimenionl graph, where Y-axia is current fn X-axis voltage of the diode under test.

#     3. Version 1 of the experiment uses a simple manual adjustable voltage source to power the diode, and two

#        multi-meters are used by hand to take the current and voltage readings and input to an Excel worksheet

#        for subsequent data analysis and graph plotting.

#     4. Version 2 of the same experiment is trying to use Rpi4B python to control a digital 12-bit DAC and two

#        12-bit ADC's to measure current through the diode and also voltage across it.

#     5. The test data used for this program is the raw data of one set of 33 pairs of numbers, with each pair

#        represents one measuremnt current and associated voltage.

#     6. For this feasibility test program, the Excel worksheet of 33 rows of data has already been manually copied

#        and pasted to a python dictionary.

#   Part B - Description of the Tunnel Diode I-V Curv Plotting Function diodePlot()

#     1. Convert the python dictionary data into two lists, one containg 33 current values, the ohter 33 voltage

#        values.

#     2. Use the matplotlib module to plot the current values vs the voltage values. 

# Description of function diodePlot()

# *** Diode Dictionaries ***

diodeDictionary01 = {

  'Title'           : 'Diode Dictionary', 

  'Version'         : 'v0.8',

  'Date'            : '2020dec16hkt1602',

  'Author'          : 'tlfong01',

  'Description'     : 'Inputs a diode dictionary and plots the I-V curve',

  'Measurements'    :

  { '2BS4B-01'  : { 'DiodeName'      : '2SB4B',

                    'SampleNum'      : '1', 

    'I2cBusName'     : 'I2cBus0',

                    'DvBaseAddrName' : '0x20',

    'DataPoints' : {  '0'  : {'mV' :   0.10, 'mA': 0.02, 'Zone' : '1'},

          '1'  : {'mV' :   0.20, 'mA': 0.02, 'Zone' : '1'},

          '2'  : {'mV' :   0.30, 'mA': 0.03, 'Zone' : '1'},

          '3'  : {'mV' :   0.40, 'mA': 0.05, 'Zone' : '1'},

          '4'  : {'mV' :   0.50, 'mA': 0.06, 'Zone' : '1'},

          '5'  : {'mV' :   1.00, 'mA': 0.11, 'Zone' : '1'},

          '6'  : {'mV' :   2.00, 'mA': 0.24, 'Zone' : '1'},

          '7'  : {'mV' :   3.00, 'mA': 0.34, 'Zone' : '1'},

          '8'  : {'mV' :   4.00, 'mA': 0.46, 'Zone' : '1'},

          '9'  : {'mV' :   5.00, 'mA': 0.57, 'Zone' : '1'},

         '10'  : {'mV' :   6.00, 'mA': 0.80, 'Zone' : '1'},

         '11'  : {'mV' :   7.00, 'mA': 0.78, 'Zone' : '1'},

         '12'  : {'mV' :   9.00, 'mA': 1.01, 'Zone' : '1'},

         '13'  : {'mV' :  10.00, 'mA': 1.11, 'Zone' : '1'},

         '14'  : {'mV' :  11.00, 'mA': 1.21, 'Zone' : '1'},

         '15'  : {'mV' :  12.00, 'mA': 1.32, 'Zone' : '1'},

         '16'  : {'mV' :  13.00, 'mA': 1.41, 'Zone' : '1'},

         '17'  : {'mV' :  14.00, 'mA': 1.51, 'Zone' : '1'},

         '18'  : {'mV' :  15.00, 'mA': 1.60, 'Zone' : '1'},

         '19'  : {'mV' :  16.00, 'mA': 1.70, 'Zone' : '1'},

         '20'  : {'mV' : 194.00, 'mA': 1.88, 'Zone' : '2'},

         '21'  : {'mV' : 206.00, 'mA': 1.88, 'Zone' : '2'},

         '22'  : {'mV' : 221.00, 'mA': 1.88, 'Zone' : '2'},

         '23'  : {'mV' : 241.00, 'mA': 1.88, 'Zone' : '2'},

         '24'  : {'mV' : 250.00, 'mA': 1.88, 'Zone' : '2'},

         '25'  : {'mV' : 271.00, 'mA': 1.88, 'Zone' : '2'},

         '26'  : {'mV' : 486.00, 'mA': 1.88, 'Zone' : '3'},

         '27'  : {'mV' : 488.00, 'mA': 1.95, 'Zone' : '3'},

         '28'  : {'mV' : 490.00, 'mA': 2.06, 'Zone' : '3'},

         '29'  : {'mV' : 492.00, 'mA': 2.32, 'Zone' : '3'},

         '30'  : {'mV' : 495.00, 'mA': 2.32, 'Zone' : '3'}, 

         '31'  : {'mV' : 498.00, 'mA': 2.49, 'Zone' : '3'},

         '32'  : {'mV' : 500.00, 'mA': 2.63, 'Zone' : '3'},

},

                          },

           '2SB4B-02'  :  { 'DiodeName'  : '2SB4B'},

           '2SB4-01'   :  { 'DiodeName'  : '2SB4'},

           '2SB3-01'   :  { 'DiodeName'  : '2SB3'},

         }

    }

# *** Plotting Functions ***

def plotDiodeV01(diodeDictionary, diodeName): # Just printing out dictionary data for debugging - tlfong01  2020dec16hkt2040)

    print('Begin plotDiode(), ...')

    print('  Title           = ', diodeDictionary['Title'])

    print('  Diode Name      = ', diodeDictionary['Measurements'][diodeName]['DiodeName'])

    print('  I2cBusName      = ', diodeDictionary['Measurements'][diodeName]['I2cBusName'])

    print('  DvBaseAddrName  = ', diodeDictionary['Measurements'][diodeName]['DvBaseAddrName'])

    print('  DataPoints      =    Num       mV      mA')

    for dataPointNum in range(len(diodeDictionary['Measurements'][diodeName]['DataPoints'])):

        print('                      ', (str(dataPointNum)).rjust(3),  \

             ('{:.2f}'.format(diodeDictionary['Measurements'][diodeName]['DataPoints'][str(dataPointNum)]['mV'])).rjust(8), end = '')

        print(('{:.2f}'.format(diodeDictionary['Measurements'][diodeName]['DataPoints'][str(dataPointNum)]['mA'])).rjust(8), ' ')

    print('End   plotDiode().')

    return

# *** Main Fnction ***

plotDiodeV01(diodeDictionary01, '2BS4B-01')

# *** End of program ***

'''

# Appendix A - Tunnel Diode 2SB04 Raw Data

Plotting I-V Curve of Tunnel Diode 2BS4 Sample #1, v0.2 tlfong01  2020nov24hkt1346

Stp Vt(mV} It (mA} Zone

1 0.10 0.02 Before Negative Resistance Region

2 0.20 0.02

3 0.30 0.03

4 0.40 0.05

5 0.50 0.06

6 1.00 0.11

7 2.00 0.24

8 3.00 0.34

9 4.00 0.46

10 5.00 0.57

11 6.00 0.80

12 7.00 0.78

13 9.00 1.01

14 10.00 1.11

15 11.00 1.21

16 12.00 1.32

17 13.00 1.41

18 14.00 1.51

19 15.00 1.60

20 16.00 1.70

21 194.00 1.88 Negative Resistance Region

22 206.00 1.88

23 221.00 1.88

24 241.00 1.88

25 250.00 1.88

26 271.00 1.88

27 486.00 1.88 After Negative Resistance Region

28 488.00 1.95

29 490.00 2.06

30 492.00 2.15

31 495.00 2.32

32 498.00 2.49

33 500.00 2.63

'''

# Appendix B - Sample Output ***

# *** Begin sample output ***

'''

>>> %Run plotDiode11.py

Begin plotDiode(), ...

  Title           =  Diode Dictionary

  Diode Name      =  2SB4B

  I2cBusName      =  I2cBus0

  DvBaseAddrName  =  0x20

  DataPoints      =    Num       mV      mA

                         0     0.10    0.02  

                         1     0.20    0.02  

                         2     0.30    0.03  

                         3     0.40    0.05  

                         4     0.50    0.06  

                         5     1.00    0.11  

                         6     2.00    0.24  

                         7     3.00    0.34  

                         8     4.00    0.46  

                         9     5.00    0.57  

                        10     6.00    0.80  

                        11     7.00    0.78  

                        12     9.00    1.01  

                        13    10.00    1.11  

                        14    11.00    1.21  

                        15    12.00    1.32  

                        16    13.00    1.41  

                        17    14.00    1.51  

                        18    15.00    1.60  

                        19    16.00    1.70  

                        20   194.00    1.88  

                        21   206.00    1.88  

                        22   221.00    1.88  

                        23   241.00    1.88  

                        24   250.00    1.88  

                        25   271.00    1.88  

                        26   486.00    1.88  

                        27   488.00    1.95  

                        28   490.00    2.06  

                        29   492.00    2.32  

                        30   495.00    2.32  

                        31   498.00    2.49  

                        32   500.00    2.63  

End   plotDiode().

>>> 

'''

# *** End  sample output ***

# *** End of program, appendices, and sample output ***


No comments:

Post a Comment

Joe Biden

RCA Tunnel Diode Manual - RCA 1966

 RCA Tunnel Diode Manual - RCA 1966 https://www.yumpu.com/en/document/read/23901571/rca-tunnel-diode-manual