Is there a way I could collect 2W measurements from channel 101 and 102 in parallel, keep channel 101 closed and then get readings again from chanel 101 and 103?
here's the code i currently have. I was thinking if i should close channel 101 and keep it closed until all the readings are done but im not sure how to implement this :
instrument_write(s, "ROUT:SCAN:COUN:SCAN {0}".format(scan_count)) # Set the number of times the scan is repeated
instrument_write(s, 'TRAC:POIN {}, "defbuffer1"'.format(buffer_size)) # Set buffer size
instrument_write(s, 'SENS:FUNC "RES", (@101:103)') # specify the channels here for the 2W function
instrument_write(s, 'RES:RANG:AUTO ON, (@101:103)') # Set Auto Range on
instrument_write(s, 'SENS:RES:NPLC 0.1, (@101:103)') #Set NLPC value (the higher the better but more time taken then)
instrument_write(s, "ROUT:SCAN:CRE (@101:103)") # specify which channels to scan
instrument_write(s,"TRAC:CLE") #clear the buffer
instrument_write(s, "INIT") # Initiate the scan
start_index = 1
end_index = channel_count
accumulated_readings = 0
columns1= ['TimeStamp']+ ['Channel_{}'.format(i) for i in range(1,channel_count)]
df= pd.DataFrame(columns=columns1)
data_dict= defaultdict(list)
while accumulated_readings < buffer_size:
time.sleep(0.5)
readings_count = int(instrument_query(s, "TRACe:ACTual?", 16).rstrip())
if readings_count >= end_index:
tempbuf=instrument_query(s, "TRACe:DATA? {0}, {1}, \"defbuffer1\", READ".format(start_index, end_index), 128)
now= datetime.datetime.now()
now2 = now.strftime('%Y-%m-%d %H:%M:%S.%f')
final_data= tempbuf.strip().split(',')
data_dict['TimeStamp']= now2[:-4]
for i, value in enumerate(final_data,1):
data_dict[f"Channel_{i}"] = value
df_dictionary= pd.DataFrame([data_dict])
df= pd.concat([df, df_dictionary],ignore_index=True)
start_index += channel_count
end_index += channel_count
accumulated_readings += channel_count
# Close the socket connection
instrument_disconnect(s)
t2 = time.time()