Ejemplo n.º 1
0
	def setDifferentAD7718(self):
		sel = self.deviceBox.currentText()
		if ( not ('ACM' in sel  or 'USB' in sel)):
			self.displayDialog('No devices Found')
			return
		from PSL import sciencelab
		self.ISPI = sciencelab.connect(port = sel,load_calibration=False)
		self.A.setADC(self.ISPI)
		self.displayDialog('Connected'+self.I.H.version_string.decode("utf-8"))
Ejemplo n.º 2
0
 def setDifferentAD7718(self):
     sel = self.deviceBox.currentText()
     if (not ('ACM' in sel or 'USB' in sel)):
         self.displayDialog('No devices Found')
         return
     from PSL import sciencelab
     self.ISPI = sciencelab.connect(port=sel, load_calibration=False)
     self.A.setADC(self.ISPI)
     self.displayDialog('Connected' +
                        self.I.H.version_string.decode("utf-8"))
Ejemplo n.º 3
0
    def __init__(self,I=None):
        self.CS=9
        if I:
            self.I = I
        else:
            from PSL import sciencelab
            self.I = sciencelab.connect()
        self.I.SPI.set_parameters(2,2,1,1,0)
        self.I.map_reference_clock(self.clockScaler,'WAVEGEN')
        print ('clock set to ',self.I.DDS_CLOCK )

        self.waveform_mode = self.DDS_TRIANGLE;
        self.write(1<<self.DDS_RESET)
        self.write((1<<self.DDS_B28) | self.waveform_mode )               #finished loading data
        self.active_channel = 0
        self.frequency  =  1000
Ejemplo n.º 4
0
    def __init__(self, I=None):
        self.CS = 9
        if I:
            self.I = I
        else:
            from PSL import sciencelab
            self.I = sciencelab.connect()
        self.I.SPI.set_parameters(2, 2, 1, 1, 0)
        self.I.map_reference_clock(self.clockScaler, 'WAVEGEN')
        print('clock set to ', self.I.DDS_CLOCK)

        self.waveform_mode = self.DDS_TRIANGLE
        self.write(1 << self.DDS_RESET)
        self.write(
            (1 << self.DDS_B28) | self.waveform_mode)  #finished loading data
        self.active_channel = 0
        self.frequency = 1000
            for b in lst[a]:
                cls_module = self.supported.get(b, None)
                if cls_module:
                    new = self.I.newRadioLink(address=a)
                    cls = cls_module.connect(new)
                    if cls:
                        if col == colLimit:
                            col = 0
                            row += 1
                        newSensor = self.sensorIcon(cls,
                                                    hint='Node: ' + hex(a))
                        self.ExperimentLayout.addWidget(newSensor, row, col)
                        self.sensorWidgets.append(newSensor)
                        col += 1

    def __del__(self):
        self.looptimer.stop()
        print('bye')

    def closeEvent(self, event):
        self.looptimer.stop()
        self.finished = True


if __name__ == "__main__":
    from PSL import sciencelab
    app = QtGui.QApplication(sys.argv)
    myapp = AppWindow(I=sciencelab.connect())
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 6
0
			self.updatepos+=1
			if self.updatepos>=self.POINTS:self.updatepos=0
		
			now = time.time()
			dt = now - self.lastTime
			self.lastTime = now
			if self.fps is None:
				self.fps = 1.0/dt
			else:
				s = np.clip(dt*3., 0, 1)
				self.fps = self.fps * (1-s) + (1.0/dt) * s
			self.plot.setTitle('%0.2f fps' % (self.fps) )

			
	def __del__(self):
		self.looptimer.stop()
		print ('bye')

	def closeEvent(self, event):
		self.looptimer.stop()
		self.finished=True
		

if __name__ == "__main__":
	from PSL import sciencelab
	import sys
	app = QtGui.QApplication(sys.argv)
	myapp = AppWindow(I=sciencelab.connect())
	myapp.show()
	sys.exit(app.exec_())
Ejemplo n.º 7
0
        # self.aboutArray.append(['Capacitance scaling']+scalers[:4])
        # self.aboutArray.append(['PCS slope,offset']+scalers[4:])
        else:
            self.displayDialog('Cap and PCS calibration invalid')

    def upload(self):
        vals = [self.socketCap]
        for a in range(7):
            item = self.table.item(a + 4, 2)
            vals.append(float(item.text()))
        cap_and_pcs = self.I.write_bulk_flash(
            self.I.CAP_AND_PCS,
            self.stoa('READY' +
                      struct.pack('8f', *vals)))  # READY+calibration_string

        self.I.SOCKET_CAPACITANCE = vals[0]
        self.I.__calibrate_ctmu__(vals[3:])
        self.I.DAC.CHANS['PCS'].load_calibration_twopoint(
            vals[1], vals[2])  # Slope and offset for current source
        self.I.resistanceScaling = vals[3]


if __name__ == "__main__":
    from PSL import sciencelab

    app = QtGui.QApplication(sys.argv)
    myapp = AppWindow(
        I=sciencelab.connect(load_calibration=False, verbose=True))
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 8
0

	def cal100(self): #Cap calibration
		CR=3
		cap = self.get_capacitance(CR)
		self.table.item(3,1).setText('%.3e'%cap)
		actual = float(self.table.item(3,0).text())
		self.table.item(6+CR,2).setText('%.3e'%(cap/actual) )

		CR=0
		cap = self.get_capacitance(CR)
		self.table.item(3,1).setText('%.3e'%cap)
		actual = float(self.table.item(3,0).text())
		self.table.item(6+CR,2).setText('%.3e'%(cap/actual) )



	def calPCS(self):
		v=self.I.set_pcs(1.0e-3)
		rv = self.I.get_average_voltage('CH3')
		print(v,rv)
		pass

				
if __name__ == "__main__":
    from PSL import sciencelab
    app = QtGui.QApplication(sys.argv)
    myapp = AppWindow(I=sciencelab.connect(verbose=True))
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 9
0
		self.__writeCONFB__()
	
	def getVals(self,addr,bytes):
		vals = self.I2C.readBulk(self.ADDRESS,addr,bytes) 
		return vals
	
	def getRaw(self):
		vals=self.getVals(0x03,6)
		if vals:
			if len(vals)==6:
				return [int16(vals[a*2]<<8|vals[a*2+1])/self.scaling[self.gainValue] for a in range(3)]
			else:
				return False
		else:
			return False
		

if __name__ == "__main__":
 from PSL import sciencelab
 I= sciencelab.connect()
 I.set_sine1(.5)
 A = connect(I.I2C) 
 A.setGain(2)
 t,x,y,z = I.I2C.capture(A.ADDRESS,0x03,6,400,10000,'int') 
 #print (t,x,y,z)
 from pylab import *
 plot(t,x)
 plot(t,y)
 plot(t,z)
 show()
Ejemplo n.º 10
0
        if self.A.SECOND_DAC:
            final_fitstr += stoa(
                '>|%s|<' % self.DAC_CHAN2)  # len(DAC_CHAN)==3 . mandatory
            VToCode = self.I.DAC.CHANS[self.DAC_CHAN2].VToCode
            fitvals = np.polyfit(VToCode(np.array(self.A.ADC_DIRECT2)),
                                 VToCode(np.array(self.A.DAC_VALS2)), 2)
            fitstr = struct.pack('3f', *fitvals)
            final_fitstr += stoa(fitstr)

        final_fitstr += stoa('STOP')

        print('Writing adc slopes and offsets to Flash.....' +
              str(len(final_fitstr)))
        print(final_fitstr)
        self.I.write_bulk_flash(self.I.ADC_POLYNOMIALS_LOCATION, final_fitstr)


if __name__ == "__main__":
    from PSL import sciencelab

    app = QtGui.QApplication(sys.argv)

    app.setStyleSheet(
        " *{outline:none;} QMainWindow{background:#aabbcc;} QTabWidget#tabwidget{margin:0px; padding:0px; border:none;} QTabBar{font:20px;} QTabBar::tab{background: #3F51B5; padding:15px 50px; color:#C5CAE9;} QTabBar::tab:selected,QTabBar::tab:hover{color:white; background:#303F9F} QWidget#cont1{background:#E0E0E0; max-width:250px;}  QLabel{color:#424242; margin:10px 0px;} QLabel#intvalue,QLabel#smoothvalue{border:1px dotted #424242; padding: 8px;} QLabel#intvalue{min-width: 70px;} QLabel#smoothvalue{max-width: 70px;} .CustomSlider{outline:none; border:none;}  QSlider::groove:horizontal {margin:0px; padding:0px; border:none; background:#3F51B5; color:#FF4081; height: 3px;} QSlider::handle:horizontal {width:18px; height:18px; border-image:url(handle.png) 0 0 0 0 stretch stretch; border-width:0px; margin:-7px 0px;} QComboBox#plottype::drop-down{min-width:35px; background:#E0E0E0; border-left:1px;border-style: solid;} QComboBox#plottype::drop-down:hover{background:#3F51B5;} QComboBox#plottype::down-arrow{border-image:url(downarrow.png) 0 0 0 0 stretch stretch;margin:-3px;border:0px;} QComboBox#plottype:!editable {background:#E0E0E0; border:1px solid #424242;} QComboBox#plottype:!editable{background:#3F51B5; border-color:#303F9F;color:white; padding-left:5px;} QComboBox#plottype QAbstractItemView {background:#E0E0E0; border:1px solid #9E9E9E} QAbstractItemView::item {min-height: 35px;} QComboBox#plottype QListView::item:selected { color:white; background-color: #3F51B5;}  QPushButton:hover{background:#BDBDBD;} QToolTip{background:#FBE9E7;color:#757575; padding:4px; border:0px; margin:0px;} QPushButton{min-height: 24px;min-width:30px; border:1px solid #424242; padding:3px;color:#424242; background:#998897;}  "
    )

    myapp = AppWindow(I=sciencelab.connect(verbose=True))
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 11
0
import sys
from time import sleep, time

sys.path.append('./pslab-python/build/lib')

from PSL import sciencelab

I = sciencelab.connect()

motor_duty_cycle = 50
turns = 200
pulses_per_turn = 220

start_time = time()
try:
    I.sqr1(freq=10000, duty_cycle=motor_duty_cycle)
    I.countPulses(channel='SEN')
    count = 0
    while count < turns * pulses_per_turn:
        count = I.readPulseCount()
        sleep(0.02)
finally:
    I.set_state(SQR1=0)

stop_time = time()
print('Time: {:.1f}s, count {}'.format(time() - start_time, count))
Ejemplo n.º 12
0
                        FL.write('\t\t%s %d\n' %
                                 (w.SEN.__module__.split('.')[-1],
                                  w.dataOptions.currentIndex()))

            FL.write('STATIC\n')
            for a in self.statics:
                w = self.statics[a]
                if w.isChecked():
                    FL.write('\tSTANDARD\n')
                    FL.write('\t\t%s\n' % (w.text()))

            FL.close()

    def __del__(self):
        self.timer.stop()
        print('bye')

    def closeEvent(self, event):
        self.timer.stop()
        self.finished = True


if __name__ == "__main__":
    from PSL import sciencelab
    import sys
    app = QtGui.QApplication(sys.argv)
    #P=[{'name':'res','cmd':'CH1'}]  #An array of dictionaries defining custom functions
    myapp = AppWindow(I=sciencelab.connect())  #,preset = P)
    myapp.show()
    sys.exit(app.exec_())
Ejemplo n.º 13
0
			scalers = struct.unpack('8f',cap_and_pcs[5:])
			print(cap_and_pcs,scalers)
			#self.__calibrate_ctmu__(self,scalers[:4])
			#self.DAC.CHANS['PCS'].load_calibration_twopoint(scalers[4],scalers[5]) #Slope and offset for current source
			#self.aboutArray.append(['Capacitance scaling']+scalers[:4])
			#self.aboutArray.append(['PCS slope,offset']+scalers[4:])
		else:
			self.displayDialog('Cap and PCS calibration invalid')

	def upload(self):
		vals = [self.socketCap]
		for a in range(7):
			item = self.table.item(a+4,2)
			vals.append(float(item.text()))
		cap_and_pcs=self.I.write_bulk_flash(self.I.CAP_AND_PCS,self.stoa('READY'+struct.pack('8f',*vals)))  #READY+calibration_string

		self.I.SOCKET_CAPACITANCE = vals[0]
		self.I.__calibrate_ctmu__(vals[3:])
		self.I.DAC.CHANS['PCS'].load_calibration_twopoint(vals[1],vals[2]) #Slope and offset for current source
		self.I.resistanceScaling = vals[3]



if __name__ == "__main__":
    from PSL import sciencelab
    app = QtGui.QApplication(sys.argv)
    myapp = AppWindow(I=sciencelab.connect(load_calibration=False,verbose=True))
    myapp.show()
    sys.exit(app.exec_())

Ejemplo n.º 14
0
            np.pi * R / 10), np.sin(self.x +
                                    np.pi * R2 / 10), np.sin(self.x -
                                                             np.pi * R2 / 10)

    def get_voltage(self, chan):
        '''
		Returns a random value
		'''
        return self.r + random.random()

    def set_pv1(self, val):
        return val + self.r


# Try to import and create an instance of sciencelab, otherwise create an instance of the dummy class
try:
    from PSL import sciencelab
    I = sciencelab.connect(verbose=True)
    I.set_sine2(1000)
except Exception as e:
    print('using dummy class', str(e))
    I = dummy()

# Use the inspect module to prepare a list of methods available in the class.
#This is quite flexible, and in theory this framework should easily adapt to serve any hardware with a python communication library
functionList = {}
for a in dir(I):
    attr = getattr(I, a)
    if inspect.ismethod(attr) and a != '__init__':
        functionList[a] = attr
Ejemplo n.º 15
0
			for a in self.statics:
				w = self.statics[a]
				if w.isChecked():
					FL.write('\tSTANDARD\n')
					FL.write('\t\t%s\n'%(w.text()))



			FL.close()	



	
	def __del__(self):
		self.timer.stop()
		print ('bye')

	def closeEvent(self, event):
		self.timer.stop()
		self.finished=True
		

if __name__ == "__main__":
	from PSL import sciencelab
	import sys
	app = QtGui.QApplication(sys.argv)
	#P=[{'name':'res','cmd':'CH1'}]  #An array of dictionaries defining custom functions
	myapp = AppWindow(I=sciencelab.connect())#,preset = P)
	myapp.show()
	sys.exit(app.exec_())