PythonからTCP/IPでDMM 34410Aを制御
IoTで使うPython入門Step3-計測 (1) DMM 34461A-①
こちらの記事を参考にやってみた
#!/usr/bin/python3 """ Function Test Program Measuring instrument control Python3 OS:Windows or Linux DATE VER NAME COMMENT 2020/02/21 0.00 garyo NEW """ import socket import time #ipAddr = "K-34461A-16054.local" ipAddr = "133.100.30.202" ports = 5025 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ipAddr, ports)) s.send(b"*IDN?\n") print('ID: ' + str(s.recv(256))) s.send(b'CONF:VOLT:AC 100,0.001\n') s.send(b'VOLT:AC:BAND 20\n') s.send(b'READ?\n') print( 'AC: ' + str(s.recv(64))) s.send(b'CONF:VOLT:DC 10,0.001\n') s.send(b'READ?\n') print( 'DC: ' + str(s.recv(64))) s.send(b'READ?\n') a1 = float(str(s.recv(64),encoding='utf-8')) print(a1) s.send(b'READ?\n') a2 = float(str(s.recv(64),encoding='utf-8')) s.send(b'READ?\n') a3 = float(str(s.recv(64),encoding='utf-8')) print((a1 + a2 + a3)/3) s.send(b'ROUT:TERM?\n') ret = str(s.recv(64),encoding='utf-8') if ret == 'FRON\n': print("FRONT\n") elif ret == 'REAR\n': print("REAR\n") else: print("?[" + ret + "]") s.send(b'SYST:BEEP\n') time.sleep(.3) s.send(b'SYST:BEEP\n') time.sleep(.3) s.send(b'SYST:BEEP\n') s.close()
コメント
コメントを投稿