joshna
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Gallery
Posts posted by 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:
from WF_SDK import device, scope, wavegen # import instruments import matplotlib.pyplot as plt # needed for plotting import 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 law for filename in [filename_currents, filename_voltages]: #outputs currents and voltages to csv with 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 instrument if dwf.FDwfAnalogInConfigure(device_data.handle, ctypes.c_bool(False), ctypes.c_bool(True)) == 0: check_error() # read data to an internal buffer while True: status = ctypes.c_byte() # variable to store buffer status if dwf.FDwfAnalogInStatus(device_data.handle, ctypes.c_bool(True), ctypes.byref(status)) == 0: check_error() # check internal buffer status if status.value == constants.DwfStateDone.value: # exit loop when ready break # copy buffer buffer = (ctypes.c_double * data.buffer_size)() # create an empty buffer buffer2 = (ctypes.c_double * data.buffer_size)() # create an empty buffer if 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]
Thank you so much!
Current Limiting IV Curves
in Test and Measurement
Posted
@attila Thank you so much! This helped me a lot with increasing the input voltage.
However, I now see 2 other problems so I was wondering if you would be able to help me with that?
One problem is that the voltages I get now go up to 30 Volts, by the input waveform should only go from 0 to 10 volts so the channel should not be getting and plotting 30 Volts.
For reference, this is the new graph:
And this is the updated code:
The other problem I have, is that when I don't start off with a gate voltage of 1 V, I get really strange looking graphs. For example,
Vg = 1, 2, 3, 4, 5 on 50V vs 5V analog input:
Vg = 2, 3, 4, 5 on 50V vs 5V analog input:
Vg = 2, 3, 4 on 50V vs 5V analog input:
Vg = 3, 4, 5 on 50V vs 5V analog input: