Vdd---<1k>---<ADC1>---<3k3>---<ADC2>---<1k>---<GND> ''' # Locate slab in the parent folder import sys sys.path.append('..') sys.path.append('.') import slab # Set prefix to locate calibrations slab.setFilePrefix("../") slab.connect() # (A) Calculate voltage on 3k3 resistor vd = slab.readVoltage(1, 2) print "Voltage at 3k3 resistor is " + str(vd) + " V" # (B) Calculate current on 3k3 resistor i = slab.rCurrent(3.3, 1, 2) print "Current at 3k3 resistor is " + str(i) + " mA" i1 = slab.rCurrent(1.0, 2, 0) print "Current at grounded 1k resistor is " + str(i) + " mA" print slab.disconnect() slab.pause()
import matplotlib.pyplot as plt # Open serial communication with autodetection of COM port sl.connect() print print "This script checks the low level commands that the" print "SLab module can issue to the hardware board" print "A functional compliant hardware board should give" print "Ok results in all checks" print print "In order to continue you must set the following connections:" print " Each DAC connected to the ADC with the same number" print " The rest of ADCs connected to DAC 1" print sl.pause() print print "[ ] Command M checked if board is connected" # Show capabilities sl.printBoardInfo() print "[ ] Command F checked if board name is ok" print "[ ] Command I checked if board information is ok" print "[ ] Command L checked if pin list is ok" print print "[ ] Commands A and D ok if next four curves are" print " all lines with equal X and Y axis values" print
print('Plot commands') print('You should see a plot with two curves') print('Close the window to continue') slab.plotnn([data1,data3],[data2,data4],"Two curve plot","Angle (rad)","Value",["Sin","Cos"]) print(); ''' Connection to the board ''' slab.connect() print('You should be now connected to the board') print('If you had performed the calibration, it should load') if pause_after_connect: slab.pause('(Press return)') print() slab.printBoardInfo() print() print('You should see information about the board') print('Now connect DAC1 to ADC1,3,4 and DAC2 to ADC2') if pause_after_info: slab.pause('(Press return)') print() #DC voltage commands print('DC voltage commands') slab.setVoltage(1,1.5) slab.setVoltage(2,2.0) v1=slab.readVoltage(1)
SLab Example Example_19.py Gain at a tone frequency ''' # Locate slab in the parent folder import sys sys.path.append('..') sys.path.append('.') import slab import slab_ac as ac # Set prefix to locate calibrations slab.setFilePrefix("../") slab.connect() print "Response at 72Hz" gain = ac.sineGain(1.0, 2.0, 72.0) print " Gain = " + str(gain) m, p = ac.magnitudePhase(gain) print " Magnitude = " + str(m) print " Phase = " + str(p) + " deg" slab.disconnect() print slab.pause("Hit RETURN to end the script")