Project 1 Part E2 Programming PicoScope ---Defining Functions---

Similar presentations


Presentation on theme: "Project 1 Part E2 Programming PicoScope ---Defining Functions---"— Presentation transcript:

1 Project 1 Part E2 Programming PicoScope ---Defining Functions---

2

3

4

5

6 # -*- coding: utf-8 -*- """ Created on Wed Apr 26 11:37: @author: Husain import subprocess def getMeasurements(): #read oscilloscope output = subprocess.check_output(['picoscope','/a','Measurements.CSV?']) #split the lines of the measurements output = output.split('\n') #define space space = " " #taking the index, and splitting according to comma channelA = output[1].split(",") channelB = output[2].split(",") #taking index, and splitting according to "space" channelA = channelA[2].split(space) channelB = channelB[2].split(space) #check the unit and apply if channelA[1]=="mV": channelA=float(channelA[0])*1E-3 elif channelA[1]=="V": channelA=float(channelA[0])*1 else: channelA=float(channelA[0])*1E-6 if channelB[1]=="mV": channelB=float(channelB[0])*1E-3 elif channelB[1]=="V": channelB=float(channelB[0])*1 channelB=float(channelB[0])*1E-6 return [channelA,channelB] def signalGenerator(amp,freq): #define input strings to input to cmd line amp_string = "picoscope /a Siggen.Amplitude.Value="+str(amp) freq_string = "picoscope /a Siggen.Frequency.Value="+str(freq) subprocess.call(amp_string,stdout=False) subprocess.call(freq_string,stdout=False) def timeBase(freq): #find ideal timebase time_base=1/float(freq)*5/10 #define time_index corellations time_index = [200E-9,500E-9,1E-6,2E-6,5E-6,10E-6,20E-6,50E-6,100E-6,200E-6,500E-6,1E-3,2E-3,5E-3,10E-3,20E-3,50E-3,100E-3] #find time index for command line for n in range(0,len(time_index)): if time_base<time_index[n]: break #write string to command line to change timebase time_base_string = "picoscope /a CollectionTime.SelectedIndex="+str(n-1) subprocess.call(time_base_string,stdout=False) signalGenerator(0.2,80222) timeBase(80222) #print getMeasurements() #signalGenerator(1.32,50E3)

7


Download ppt "Project 1 Part E2 Programming PicoScope ---Defining Functions---"

Similar presentations


Ads by Google