10-02-2024 11:10 AM
Hi,
I am using a NI USB-5681 power sensor with python. I know you can use the ni568x_64.dll with ctypes and this works but this is a very clumsy method.
If I monitor the USB bus I noticed the USB-5681 acts as a serial device and you can talk to it through the serial link using pySerial.
The following python code reads the power measurement using the serial interface
import serial as s
from time import sleep
ser = s.Serial('COM10',timeout=None) # open serial port
ser.write(b"IDN?\n")
print( ser.read_until('\n'.encode('utf-8')).decode('utf-8'))
ser.write(b"RST\n")
print(ser.read_until('\n'.encode('utf-8')).decode('utf-8'))
ser.write(b"START\n")
print(ser.read_until('\n'.encode('utf-8')).decode('utf-8'))
try:
while True:
ser.write(b"TRGIMM\n")
print(ser.read_until('\n'.encode('utf-8')).decode('utf-8'))
except KeyboardInterrupt:
pass
ser.close()
Please can you give me a link to the user manual for the NI-5681 RF POWER METER serial commands. The NI website seems to avoid the subject.
MPC.
10-02-2024 11:24 PM
Reverse engineering is probably the only way to figure out the commands, as NI officially recommends using the 568x only through their NI-568x driver and not through VISA or serial.
If you are motivated enough, you can use the Soft Front Panel, monitor the commands, and create a map between the various SFP operations and commands.