def vdelta(self): if (self.state.get() == "ON"): x = self.voltage.get() / 60.84 + 4.9 if (x < 0): x = 0 if (x > 4.095): x = 4.095 DAQC.setDAC(0, 1, x) else: DAQC.setDAC(0, 1, 0) print "bias V:", DAQC.getDAC(0, 1)
def task(): global logFile, lfOpen, Logging, streamOpen, fName, SampleC, SampleT, logHeader global theta, dnum aChannelCount = 0 dChannelCount = 0 try: SampleT = float(SamplePeriod.get()) if (SampleT < SampleTmin): SampleT = SampleTmin except ValueError: SampleT = SampleTmin root.after(int(SampleT * 1000), task) logString = '' dTypes = '' j = 0 for i in range(0, 8): #for boards 0 through 8 a2dvals = range(8) dinvals = range(8) if (DAQCpresent[i] == 1): #Test Signal Generation if (DoutSignal.get() == 1): dnum[i] = (dnum[i] + 1) % 128 DAQC.setDOUTall(i, dnum[i]) if (AoutSignal.get() == 1): theta[i] = (theta[i] + 1) % 360 rad = math.radians(theta[i]) dacval = 2.048 * (1 + math.sin(rad)) dacval2 = 2.048 * (1 + math.sin(2 * rad)) DAQC.setDAC(i, 0, dacval) DAQC.setDAC(i, 1, dacval2) #Retrieve and plot values a2dvals = daqc[i].a2dupdate() dinvals = daqc[i].dinupdate() #Convert data to strings for log for k in range(8): if (a2dvals[k] != ''): logString = logString + str(a2dvals[k]) + ',' aChannelCount += 1 dTypes = dTypes + 'a,' for k in range(8): if (dinvals[k] != ''): logString = logString + str(dinvals[k]) + ',' dChannelCount += 1 dTypes = dTypes + 'd,' dtypes = dTypes[:-1] logString = logString[:-1] logString = time.strftime("%H:%M:%S", time.localtime()) + ',' + logString if (Logging and lfOpen): #logString = logString[:-1] #logString = time.strftime("%H:%M:%S",time.localtime())+','+logString logFile.write(logString) logFile.write('\n') if (Logging and streamOpen): headerList = logHeader.split(",") #logString = logString[:-1] dataList = logString.split(",") typeList = dTypes.split(",") #print aChannelCount, dChannelCount, aChannelCount+dChannelCount for i in range(0, aChannelCount + dChannelCount): k = i + 1 if (typeList[i] == 'a'): streamer.log(headerList[k], float(dataList[k])) #print i,typeList[i],headerList[k],float(dataList[k]) else: if (dataList[k] == '0'): streamer.log(headerList[k], "false") #print i,typeList[i],headerList[k], 'false' else: streamer.log(headerList[k], "true") #print i,typeList[i],headerList[k], 'true' if (Logging): SampleC -= 1 root.wm_title("DAQCplate Data Logger - LOGGING - " + str(SampleC) + " Samples and " + str(SampleT * SampleC) + " Seconds Remaining") if (SampleC == 0): StopLog() try: updateSheets() StartLog() #showinfo("Logging","Logging Complete") except: shutDown()
def setValues(self, address, values): caddress = self.corrected_address(address) value = self._unpack_float(values) self.log('writing {} to board {} output {}'.format( value, self._board_address, caddress)) dp.setDAC(self._board_address, caddress, value)
def vdelta(self, val): if (self.state.get() == "ON"): DAQC.setDAC(0, 0, self.voltage.get()) else: DAQC.setDAC(0, 0, 0) print "LED V:", DAQC.getDAC(0, 0)
np.savetxt(self.fname.get(), data, delimiter=",", fmt="%.3e") def clearData(self): global data data = np.empty(shape=[0, 3]) print "data cleared" root = Tk() #root.config(bg="black") #root.attributes("-fullscreen", True) #swidth=root.winfo_screenwidth() #sheight=root.winfo_screenheight() container = Frame(root, bg='white') container.pack() #container.place(relx=0.5, rely=0.5, anchor=CENTER) title = titleBLOCK(container, 0, 0) led = lightBLOCK(container, 1, 0) bias = biasBLOCK(container, 1, 1) temp = voltageDisplay(container, "Temperature", 0, 2, 0) temp2 = tempDisplay(container, 0, 3, 0) sum = voltageDisplay(container, "QAPD Sum", 1, 2, 1) log = dataLog(container, 0, 1, 3, 1) root.mainloop() #make sure output voltage is off DAQC.setDAC(0, 0, 0) DAQC.setDAC(0, 1, 0)
from __future__ import print_function import piplates.RELAYplate as RELAY import piplates.DAQCplate as DAQC import time ppADDR = 1 volt = 0.0 i = 0 while True: if volt >= 4.095: volt = 0.0 if i > 6: i = 0 DAQC.setDAC(1, 0, volt) DAQC.setDOUTbit(1, i) time.sleep(0.1) volt = volt + .01 i = i + 1