Friday 15 2021

Diode 1N4148 I-V Plot Program - Part 2

Diode 1N4148 I-V Plot Program - Part 2

# vip3507.py tlfong01 2021jan15hkt1602


from datetime      import datetime

from time          import sleep

import dac3501 as dac

import adc3501 as adc


# *** Config ***


# *** DevDict ***


devDict = \

    {

        # *** DAC Devices ***

        'DacDev0'    : {    'DevName' : 'Mcp4725I2cBus1Module0', 'AnalogValName'  : '1.50V'},

        'DacDev1'    : {    'DevName' : 'Mcp4725I2cBus1Module1', 'AnalogValName'  : '1.50V'},

        'DacDev2'    : {    'DevName' : 'Mcp4725I2cBus3Module0', 'AnalogValName'  : '1.50V'},

        'DacDev3'    : {    'DevName' : 'Mcp4725I2cBus3Module1', 'AnalogValName'  : '1.50V'},

 

         # *** ADC Devices ***

        'AdcDev0'    : {    'DevName' : 'Mcp3201SpiPort0Module0'},

        'AdcDev1'    : {    'DevName' : 'Mcp3201SpiPort0Module1'},

        'AdcDev2'    : {    'DevName' : 'Mcp3201SpiPort1Module0'},

        'AdcDev3'    : {    'DevName' : 'Mcp3201SpiPort1Module1'},      

    }


# *** Dev Devices Name ***


dacDev0Name = devDict['DacDev0']['DevName']

dacDev1Name = devDict['DacDev1']['DevName']

dacDev2Name = devDict['DacDev2']['DevName']

dacDev3Name = devDict['DacDev3']['DevName']


adcDev0Name = devDict['AdcDev0']['DevName']

adcDev1Name = devDict['AdcDev1']['DevName']

adcDev2Name = devDict['AdcDev2']['DevName']

adcDev3Name = devDict['AdcDev3']['DevName']


# *** System Config/Functions ***


timeDict = {'OneSecond' : 1}


dateTimeNowLong  = str(datetime.now())

dateTimeNowShort = str(datetime.now())[0:16]


def pauseSeconds(secondsName):

    sleep(timeDict[secondsName])

    return


# *** Old Test Functions ***


# ...


# *** New Test Functions ***


dcvSweepListDict = \

    {        

        'DcvSweepList01' : [x * 512 for x in range(8)],

        'DcvSweepList09' : [x * 512 for x in range(8)],

    }


timeDict = \

    {

        'OneMilliSecond' : 0.001,

        'OneSecond'      : 1,

    }


countDict = \

    {

        'OneTime' : 1,

        'OneMillionTimes' : 1000000,

        #'OneMillionTimes' : 1,

    }


def dcvSweep09(dacModuleName0, adcModuleName0, adcModuleName1, adcModuleName2, dcvSweepList, pauseTime, totalCount):

    print('')

    print('  Vcc Analog  dacModuleName0   =', dacModuleName0)

    print('  Vcc Digital adcModuleName0   =', adcModuleName0)

    print('  Vr  AdcModuleName1           =', adcModuleName1)

    print('  Vd  AdcModuleName2           =', adcModuleName2)

    print('  dcvSweepList                 =', dcvSweepList)

    print('  pauseTime                    =', pauseTime)

    print('  totalCount                   =', totalCount)

    

    print('')

    print('  Begin sweep testing, ...')

    print('    ... <Ctrl>C to abort.')

    for count in range(totalCount):

        for sweepStep in range(len(dcvSweepList)):

            #print('\n  sweepStep             =', sweepStep)

            digiVal = dcvSweepList[sweepStep]

            #print('    digiVal   (Vcc)     =', digiVal)

            dac.setDigiValToAnalogValNoPrint(dacModuleName0, digiVal)

            

            adcDecimalResults = adc.getMcp3201DecimalResultsNoPrint(adcModuleName0)  

            #print('    digiVal 0 (Dv)      =', '{:.2f}'.format(adcDecimalResults), 'V')

 

            adcDecimalResults = adc.getMcp3201DecimalResultsNoPrint(adcModuleName1)  

            #print('    digiVal 1 (Rv)      =', '{:.2f}'.format(adcDecimalResults), 'V')

            

            adcDecimalResults = adc.getMcp3201DecimalResultsNoPrint(adcModuleName2)  

            #print('    digiVal 2 (Ri)      =', '{:.2f}'.format(adcDecimalResults), 'V')  

            

            sleep(pauseTime)

            #print('')

       

    print('  Begin sweep testing.')

       

    return


def diodeIvPlot09(diodeName, dcvSweepListName, stepPauseSecondsName, totalCountName):

    print('Begin diodePlot09(), ...', 'tlfong01', dateTimeNowShort, '\n')

    

    sweepList = dcvSweepListDict[dcvSweepListName]

    pauseTime = timeDict[stepPauseSecondsName]

    totalCount = countDict[totalCountName]

    

    print('  sweepList    =', sweepList)

    print('  pauseTime    =', pauseTime)

    print('  totalCount   =', totalCount)   

    

    dcvSweep09(dacDev0Name, adcDev0Name, adcDev1Name, adcDev2Name, sweepList, pauseTime, totalCount)    

    

    print('\nEnd   diodePlot09().')

          

    return


# *** Init/Main Function ***


def init():

    pass

    return


if __name__ == '__main__':

    #diodeIvPlot08('1N4148', 'DcvSweepList01', 'OneMilliSecond', 'OneTime')

    diodeIvPlot09('1N4148', 'DcvSweepList09', 'OneMilliSecond', 'OneMillionTimes')

     

# *** End of Program ********************************************************************


# *** Sample Outputs ***


'''

>>> %Run vip3506.py

Begin diodePlot09(), ... tlfong01 2021-01-15 16:00 


  sweepList    = [0, 512, 1024, 1536, 2048, 2560, 3072, 3584]

  pauseTime    = 0.001

  totalCount   = 1000000


  Vcc Analog  dacModuleName0   = Mcp4725I2cBus1Module0

  Vcc Digital adcModuleName0   = Mcp3201SpiPort0Module0

  Vr  AdcModuleName1           = Mcp3201SpiPort0Module1

  Vd  AdcModuleName2           = Mcp3201SpiPort1Module0

  dcvSweepList                 = [0, 512, 1024, 1536, 2048, 2560, 3072, 3584]

  pauseTime                    = 0.001

  totalCount                   = 1000000


  Begin sweep testing, ...

    ... <Ctrl>C to abort.


'''

# *** End of 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