ja1yaz’s diary

感動したいおやじの備忘録的ブログ 

RaspberryPiにオシロスコープEDUX1052GをUSB接続してみた。

RaspberryPiにオシロを接続してみる

RaspberryPiのPythonは、Ver3.7.3なので、

pip3 install pyusb
pip3 install pyvisa
pip3 install pyvisa-py

 

を実行してPyvisaに必要なプログラムをインストールしました。

下記のアプリケーションノートが参考になりました。

 

Save Lab Space and Cost: Controlling Serial and Ethernet Test Instruments with a Raspberry Pi 3 Model B

https://download.tek.com/document/1KW-61463-0__Raspberry_Pi_3_Save_Lab_Space_%20Cost_Application_Note_090718.pdf

 

早速下記を実行してみました。

 

import pyvisa
r = pyvisa.ResourceManager('@py')
print(r.list_resources())

 

なんで?

実行してみると

('ASRL/dev/ttyAMA0::INSTR',)

しか返ってこない。

これって、シリアルインターフェースなんじゃない。

USBはどうしちゃったの?同じような悩みの方はいないかとググってみるとあった。

 

python3 -m visa info

 

を実行してみろとのこと。

 

/home/pi/.local/lib/python3.7/site-packages/visa.py:23: FutureWarning: The visa module provided by PyVISA is being deprecated. You can replace `import visa` by `import pyvisa as visa` to achieve the same effect.

The reason for the deprecation is the possible conflict with the visa package provided by the https://github.com/visa-sdk/visa-python which can result in hard to debug situations.
FutureWarning,
Machine Details:
Platform ID: Linux-4.19.97-v7+-armv7l-with-debian-10.3
Processor:

Python:
Implementation: CPython
Executable: /usr/bin/python3
Version: 3.7.3
Compiler: GCC 8.3.0
Bits: 32bit
Build: Dec 20 2019 18:57:59 (#default)
Unicode: UCS4

PyVISA Version: 1.11.3

Backends:
ivi:
Version: 1.11.3 (bundled with PyVISA)
Binary library: Not found
py:
Version: 0.5.1
ASRL INSTR: Available via PySerial (3.4)
USB INSTR: Available via PyUSB (1.1.1). Backend: libusb1
USB RAW: Available via PyUSB (1.1.1). Backend: libusb1
TCPIP INSTR: Available
TCPIP SOCKET: Available
GPIB INSTR:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of funcionality.
No module named 'gpib'

 

これを見ると、

USB INSTR: Available via PyUSB (1.1.1). Backend: libusb1

 

となっているので、USBのデバイスは認識できるはず。

 

lsusb

 

を実行してみると、

Bus 001 Device 011: ID 2a8d:039b
Bus 001 Device 004: ID 054c:0243 Sony Corp. MicroVault Flash Drive
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

 

SONYUSBメモリはきちんと認識しているのが確認できる。

でもUSBTMCであるKeysightのオシロは認識されていない。

 

それではと、

他のPCには、TekVISAが入っているので、同じUSBケーブルを使用して接続してみると、きちんと認識するのを確認できた。

f:id:ja1yaz:20210213190412p:plain

EDUX1052_TekVISA

ということは、USBケーブルが悪いわけじゃないということを意味している。

そうすると、原因はRaspberrypiの方か?

 

では、Ethernetではどうなのか?

import pyvisa               
rm = pyvisa.ResourceManager('@py')
visaRsrcAddr = "TCPIP::192.168.1.1::inst0::INSTR"
scope = rm.open_resource(visaRsrcAddr)

print(scope.query('*IDN?'))
scope.close()
rm.close()

 

Ethernetのアドレスと打ち込んで試してみるとID(IPアドレス、機器名、シリアル他)が返ってきた。

Ethernetであれば、通信ができることを確認できた。

 

今後の課題 

上記の事から、RaspberryPi自体に問題があるのではないかという事が考えられる。

今後試してみるべきは、RaspberryPiOSのBUG情報の参照と新しいRaspberryPiOSのインストールといったところか。