Tuesday 15 2020

Matplotlib Learning Notes - Part 7 (Writing a demo python program to plot test data)

Matplotlib Learning Notes - Part 7 (Writing a demo python program to plot test data)

Now I have started to write a very simple program to read the 33 pairs of tunnel diode current voltage values from a python dictionary, convert them to two lists and pass them for matplotlib to plot the I-V curve.

I am new to matplotlib and so it might take me some time to plot something pretty.  So far I have only run a demo program and have not even read a line of the manual.

# diodeplot08.py tlfong01 2020dec15hkt2133

# 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 Dictionary ***

diodeDictionary = {

  'Title'           : 'Didoe Dictionary', 

  'Version'         : 'v0.7',

  'Date'            : '2020dec15hkt2121',

  'Author'          : 'tlfong01',

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

  'Measurements'    :

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

                    'SampleNum'  : '1', 

    'I2cBusName' : 'I2cBus0',

                    'DvAddrName' : '0x20',

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

},

                          },

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

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

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

         }

    }

# *** Plotting Functions ***

def diodePlot():

    print('Begin diodePlot(), ...')

    # ... To write later ...

    print('End   diodePlot().')

# *** Main Fnction ***

diodePlot()

# *** 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 tunnel_diode_data_2020dec1508.py

Begin diodePlot(), ...

End   diodePlot().

>>> 

'''

# *** End  sample output ***

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


2 comments:

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