I created a script (below) using the Waveforms SDK to use an Analog Discovery 3 to sweep gate and drain voltages over a mosfet and generate IV curves. The plots look right but they seem to be limited by current and aren't showing the full plot. I was wondering if anyone knows why this is?
The plots:
This is the script I am runing:
from WF_SDK import device, scope, wavegen # import instrumentsimport matplotlib.pyplot as plt # needed for plottingimport csv #needed for generating CSV files for graphing later"""-----------------------------------------------------------------------"""#resistance = float(input("Enter the resistance in Ohms of the resistor in series with the mosfet: ")) TODO user inputs later
resistance =100
gate_voltages =[0,1,2,3,4,5]#gate voltages to sweep across# name of csv files
filename_currents ="chip_currents.csv"
filename_voltages ="chip_voltages.csv"# connect to the device
device_data = device.open()#TODO open again to get second device"""-----------------------------------"""# writing to csv file for filename in[filename_currents, filename_voltages]:with open(filename,'w')as csvfile:# opens csv files
csvwriter = csv.writer(csvfile)# creating a csv writer object
csvwriter.writerow(gate_voltages)# writes header row (gate voltages)# initialize the scope with default settings
scope.open(device_data, sampling_frequency=10e5)# generate a 10KHz sine signal with 2V amplitude on channel 1
current_dict ={}
volt_dict ={}for VG in gate_voltages:
wavegen.generate(device_data, channel=2, function=wavegen.function.dc, offset=VG, frequency=10e2, amplitude=1)#generate dc signal to gate voltage at voltage i
wavegen.generate(device_data, channel=1, function=wavegen.function.sine, offset=2.5, frequency=10e2, amplitude=2.5)#generation sine waveform to drain[mosfet_voltages, resistor_voltages]= scope.record2(device_data)# get data with AD3 oscilloscope
mosfet_currents =[]for v in resistor_voltages:
mosfet_currents.append(v/resistance)# calculate current with ohms lawfor filename in[filename_currents, filename_voltages]:#outputs currents and voltages to csvwith open(filename,'a')as csvfile:
writer = csv.writer(csvfile)if"current"in filename:
writer.writerow(mosfet_currents)elif"voltage"in filename:
writer.writerow(mosfet_voltages)
plt.plot(mosfet_voltages, mosfet_currents)#plot curve of mosfet voltages vs. mosfet currrents #plot labels and show
plt.xlabel("Voltage (V_DS) [V]")
plt.ylabel("Current (I_D) [A]")
plt.show()# reset the scope
scope.close(device_data)# reset the wavegen
wavegen.close(device_data)# close the connection
device.close(device_data)
In case anyone asks, record2 which I use to record data from the oscilloscope is just a modified scope.record function in order to get data from both channels at the same time. Even if I use record, I still see current limiting graphs but they are also just wrong because of the time offset so I don't think that is the problem. Regardless, the code for record2 in scope.py looks like this:
def record2(device_data):"""
record an analog signal
parameters: - device data
- the selected oscilloscope channel (1-2, or 1-4)
returns: - a list with the recorded voltages
"""# set up the instrumentif dwf.FDwfAnalogInConfigure(device_data.handle, ctypes.c_bool(False), ctypes.c_bool(True))==0:
check_error()# read data to an internal bufferwhileTrue:
status = ctypes.c_byte()# variable to store buffer statusif dwf.FDwfAnalogInStatus(device_data.handle, ctypes.c_bool(True), ctypes.byref(status))==0:
check_error()# check internal buffer statusif status.value == constants.DwfStateDone.value:# exit loop when readybreak# copy buffer
buffer =(ctypes.c_double * data.buffer_size)()# create an empty buffer
buffer2 =(ctypes.c_double * data.buffer_size)()# create an empty bufferif dwf.FDwfAnalogInStatusData(device_data.handle, ctypes.c_int(0), buffer, ctypes.c_int(data.buffer_size))==0:
check_error()if dwf.FDwfAnalogInStatusData(device_data.handle, ctypes.c_int(1), buffer2, ctypes.c_int(data.buffer_size))==0:
check_error()# convert into list
buffer =[float(element)for element in buffer]
buffer2 =[float(element)for element in buffer2]return[buffer, buffer2]
Question
joshna
Hi all,
I created a script (below) using the Waveforms SDK to use an Analog Discovery 3 to sweep gate and drain voltages over a mosfet and generate IV curves. The plots look right but they seem to be limited by current and aren't showing the full plot. I was wondering if anyone knows why this is?
The plots:
This is the script I am runing:
In case anyone asks, record2 which I use to record data from the oscilloscope is just a modified scope.record function in order to get data from both channels at the same time. Even if I use record, I still see current limiting graphs but they are also just wrong because of the time offset so I don't think that is the problem. Regardless, the code for record2 in scope.py looks like this:
Thank you so much!
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now