Exemple #1
0
    def __init__(self, xString="COM5", yString="COM6", zString="COM3"):
        #Init stuff
        visa.log_to_screen(0)
        try:
            self.rm = visa.ResourceManager('@ni')
        except:
            pass

        try:
            self.xDev = self.rm.open_resource(
                xString,
                baud_rate=921600,
                data_bits=8,
                stop_bits=visa.constants.StopBits.one)
            self.xDev.clear()
            self.xST = self.xDev.query("1TS?")
            xst = self.xST[-4:-2]
            if xst[0] == "3" and xst[1] != "C" and xst[1] != "D" and xst[
                    1] != "E" and xst[1] != "F":
                self.xPOS = float(self.xDev.query("1TP?")[3:])
                self.xOK = True
            else:
                self.xhoming = True
        except:
            pass
        try:
            self.yDev = self.rm.open_resource(
                yString,
                baud_rate=921600,
                data_bits=8,
                stop_bits=visa.constants.StopBits.one)
            self.yDev.clear()
            self.yST = self.yDev.query("1TS?")
            yst = self.yST[-4:-2]
            if yst[0] == "3" and yst[1] != "C" and yst[1] != "D" and yst[
                    1] != "E" and yst[1] != "F":
                self.yPOS = float(self.yDev.query("1TP?")[3:])
                self.yOK = True
            else:
                self.yhoming = True
        except:
            pass
        try:
            self.zDev = self.rm.open_resource(
                zString,
                baud_rate=57600,
                data_bits=8,
                stop_bits=visa.constants.StopBits.one)
            self.zDev.clear()
            self.zST = self.xDev.query("1TS?")
            zst = self.zST[-4:-2]
            if zst[0] == "3" and zst[1] != "C" and zst[1] != "D" and zst[
                    1] != "E" and zst[1] != "F":
                self.zPOS = float(self.zDev.query("1TP?")[3:])
                self.zOK = True
            else:
                self.zhoming = True
        except:
            pass
Exemple #2
0
 def __init__(self):
     ''' 
     this function open the USB port 
     '''
     if DEBUGG > 0:
         visa.log_to_screen()
     self.rm = visa.ResourceManager('@py')
     self.x = self.rm.open_resource(u'ASRL/dev/ttyUSB0::INSTR',
                                    timeout=2000)
     print('usb port connected')
Exemple #3
0
import visa
import pyvisascope
import logging

visa.log_to_screen('INFO')
logger = logging.getLogger('pyvisa')
log2file = logging.FileHandler('experiment.log')
logger.addHandler(log2file)


def main():
    # list the connected devices
    print("Devices connected to your computer:")
    print(pyvisascope.get_resources())


if __name__ == '__main__':
    main()
Exemple #4
0
        string1 = ':PADD1:POSITION ' + str(leftPaddles)
        string2 = ':PADD2:POSITION ' + str(leftPaddles)
        controller.write(string1)
        controller.write(string2)
    if keyboard.is_pressed('e'):
        rightPaddles = rightPaddles + 1
        string1 = ':PADD3:POSITION ' + str(rightPaddles)
        string2 = ':PADD4:POSITION ' + str(rightPaddles)
        controller.write(string1)
        controller.write(string2)
        print(rightPaddles)
    if keyboard.is_pressed('s'):
        leftPaddles = leftPaddles - 1
        string1 = ':PADD1:POSITION ' + str(leftPaddles)
        string2 = ':PADD2:POSITION ' + str(leftPaddles)
        controller.write(string1)
        controller.write(string2)
    if keyboard.is_pressed('d'):
        rightPaddles = rightPaddles - 1
        string1 = ':PADD3:POSITION ' + str(rightPaddles)
        string2 = ':PADD4:POSITION ' + str(rightPaddles)
        controller.write(string1)
        controller.write(string2)
    time.sleep(.1)

#controller.write(':PADD1:POSITION 500')
#controller.write(':PADD2:POSITION 500')
#controller.write(':PADD3:POSITION 500')
#controller.write(':PADD4:POSITION 500')
visa.log_to_screen()
Exemple #5
0
        return self._returnValue(self.query('IOUT1?'), by_value)


if __name__ == '__main__':
    from os import path, sys
    from time import strftime

    logging.basicConfig(
        format='%(module)-12s.%(funcName)-12s:%(levelname)s - %(message)s',
        stream=sys.stdout,
        level=logging.DEBUG)
    logging.debug('start')

    import visa
    psu = TenmaPSU()
    visa.log_to_screen(logging.INFO)
    rm = visa.ResourceManager()
    psu.connect(rm)
    logging.debug('connected')
    # not clear how to test without an actual device set 28v and 0.123mA
    # current threshold then flip on read I and V and flip off
    pause = 0.1
    psu.off()
    psu.setVoltage(28.)
    psu.setCurrent(0.123)
    psu.on()
    vv = psu.getVoltage(True)
    assert vv == 28.00
    print('voltage set', vv)
    ii = psu.getCurrent()
    print('current limit', ii)