Controlling an ET5410A+ with SCPI from a Raspberry Pi - Page 1
Forum section: electronics / testgear

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 02, 2024, 08:21:13 am
content: I'm trying to control my East Tester ET5410A+ electronic load remotely with SCPI over its USB connection from a Raspberry Pi. But I'm not having any luck, and I can't figure out what is wrong.I know the remote control works, because I can plug the USB cable into my PC and successfully issue commands using Tera Term (once the settings are configured for baud, local echo, LF-only, etc.).Code:*IDN?ET5410A+ 09702312016 V1.01.2302.019 V1.06.2247.016SYSTEM:VERSION?V1.01.2302.019SYSTEM:BEEPRexecu successWhen I do this, the small 'lock' icon also appears in the corner of the ET5410A+'s screen to show it is in remote mode.But I'll be damned if I can communicate with the thing on a Raspberry Pi. Nothing I try seems to work.It's recognised by the system when I plug in the USB, so no issue there - the unit's CH340 USB-UART interface is listed by lsusb and there are no errors logged in dmesg. My user is also definitely in the 'dialout' group too.Code:pi@raspberrypi:~ $ lsusbBus 001 Device 006: ID 1a86:7523 QinHeng Electronics CH340 serial converterBus 001 Device 004: ID 0a5c:bd1e Broadcom Corp. BCM43143 802.11bgn (1x1) Wireless AdapterBus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet AdapterBus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 HubBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubpi@raspberrypi:~ $ dmesg...[ 8661.032917] usb 1-1.5: new full-speed USB device number 6 using dwc_otg[ 8661.166494] usb 1-1.5: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=80.31[ 8661.166563] usb 1-1.5: New USB device strings: Mfr=0, Product=2, SerialNumber=0[ 8661.166594] usb 1-1.5: Product: USB Serial[ 8661.184262] ch341 1-1.5:1.0: ch341-uart converter detected[ 8661.187661] usb 1-1.5: ch341-uart converter now attached to ttyUSB0pi@raspberrypi:~ $ groupspi adm dialout cdrom sudo audio video plugdev games users input render netdev gpio i2c spiBut nothing seems to be able to communicate. I've tried minicom, picocom, tio. All either don't seem to actually send anything, or whatever it is they're sending isn't in the right format.One thing I did from the Pi thatdoesactually work is echoing a string directly to the serial port, for example:echo -e -n 'SYSTEM:BEEP\n' > /dev/ttyUSB0causes the unit to beep. Of course, this isn't much use to query information, as I can't read anything back. With this method I'm also not sure how the serial port knows the correct baud rate (9600); perhaps it retains the setting from previous efforts with other programs?Any suggestions?

author: Kean
author_rank: Unknown
timestamp: May 02, 2024, 01:56:37 pm
content: I can't help with the particular setup with an ET5410 you describe, but regarding your question regarding how the port knows the correct speed you could try something like this:Code:sleep 1000 </dev/ttyUSB0 &stty -F /dev/ttyUSB0 9600echo -e -n 'SYSTEM:BEEP\n' > /dev/ttyUSB0echo -e -n '*IDN?\n' > /dev/ttyUSB0cat < /dev/ttyUSB0The sleep command keeps the port open, which I found is sometimes needed else the communications settings get reset to defaults.You could try some simple Python code. This is really quick and dirty and untested. Copypasta from some old DMM code I used.Code:import serial#Serial Parametersport = '/dev/ttyUSB0'baud = 9600def read_data(DMM):data = b''data = DMM.readline()return data.decode('ascii').strip()def ID(DMM):DMM.write(b'*IDN?\n')instr_id = read_data(DMM)return instr_iddef read_dmm(DMM):DMM.write(b'READ?\n')values = read_data(DMM)return valuesdef main():DMM = serial.Serial(port, baud, timeout=10)data = ID(DMM)print(data)data = read_dmm(DMM)print(data)DMM.close()if __name__ == "__main__":main()

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 03, 2024, 05:34:34 am
content: I figured out what was wrong. Or, at least, what was going wrong when using picocom. Still no idea about the other programs, if it's even possible to get them to work properly. Minicom is a nightmare, and the version of tio available on Raspbian repositories is ancient and out-of-date.After reading the man page for picocom, I found that it has an option to log communication to a file. And if you use the local-echo option, it will also log exactly what it'ssendingon the serial port. After using this, and then inspecting the log file in a hex editor, what do I find? The fricking thing is using CR (0x0D) as a line termination!I was operating under the assumption that because *nix uses LF for file line termination, that the same applies for serial terminals. But no, CR was being sent instead of the needed LF, so no wonder the ET5410A+ was not responding to anything, because it never saw a command termination.Luckily picocom has options to rectify this situation. You just need to use the--omapoutput-mapping option to translate all CR being sent to LFs - e.g.:picocom --omap crlf --baud 9600 --echo /dev/ttyUSB0And now it works!Quote from: Kean on May 02, 2024, 01:56:37 pmAh, of course, you can read from the device file to get received data - that didn't occur to me. Thanks for the hint.I guess it's buffered and stores received data until you read it. And it seems from looking at the stty man page, you can configure the tty there to translate CR to LF using the 'ocrnl' setting.

author: Kean
author_rank: Unknown
timestamp: May 03, 2024, 09:43:13 am
content: Well the enter/return key would typically only ever send a CR in any ASCII based terminal I know of.CTRL-J will send a LF aka NL.Glad to hear you sorted it out. It can be quite frustrating not knowing if it is a hardware, software, protocol, or PEBKAC issue.

author: jCandlish
author_rank: Newbie
timestamp: May 18, 2024, 07:10:03 am
content: I have found that the 'tio' program is useful for coms with the linux usbACM device.https://github.com/tio/tioIt is also a gateway to bridge linux usb devices to tcp-ip for use with lxi.On topic, where is the documentation for the East Tester ET54 series SCPI command set?

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 18, 2024, 03:05:15 pm
content: Quote from: jCandlish on May 18, 2024, 07:10:03 amAnnoyingly, it's not linked on their website. I don't remember where I got it from - I think maybe I found a link in a post here - but I can't find it again now.Here is the PDF attached for future.

author: Hydron
author_rank: Super Contributor
timestamp: May 18, 2024, 08:57:21 pm
content: Note that screen can be used to talk to serial devices, syntax isCode:screen <device> <baud rate>- I find it's easier than minicom. To exit use ctrl-a, k, y IIRC