Author Topic: Controlling an ET5410A+ with SCPI from a Raspberry Pi  (Read 599 times)

0 Members and 1 Guest are viewing this topic.

Online HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: gb
Controlling an ET5410A+ with SCPI from a Raspberry Pi
« on: May 02, 2024, 08:21:13 am »
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: [Select]
*IDN?
ET5410A+ 09702312016 V1.01.2302.019 V1.06.2247.016
SYSTEM:VERSION?
V1.01.2302.019
SYSTEM:BEEP
Rexecu success

When 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. |O

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: [Select]
pi@raspberrypi:~ $ lsusb
Bus 001 Device 006: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 001 Device 004: ID 0a5c:bd1e Broadcom Corp. BCM43143 802.11bgn (1x1) Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@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 ttyUSB0
pi@raspberrypi:~ $ groups
pi adm dialout cdrom sudo audio video plugdev games users input render netdev gpio i2c spi

But 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 that does actually work is echoing a string directly to the serial port, for example: echo -e -n 'SYSTEM:BEEP\n' > /dev/ttyUSB0 causes 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?
 

Offline Kean

  • Supporter
  • ****
  • Posts: 2124
  • Country: au
  • Embedded systems & IT consultant
    • Kean Electronics
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #1 on: May 02, 2024, 01:56:37 pm »
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: [Select]
sleep 1000 </dev/ttyUSB0 &
stty -F /dev/ttyUSB0 9600
echo -e -n 'SYSTEM:BEEP\n' > /dev/ttyUSB0
echo -e -n '*IDN?\n' > /dev/ttyUSB0
cat < /dev/ttyUSB0

The 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: [Select]
import serial

#Serial Parameters
port = '/dev/ttyUSB0'
baud = 9600

def 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_id

def read_dmm(DMM):
    DMM.write(b'READ?\n')
    values = read_data(DMM)
    return values

def 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()
 

Online HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: gb
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #2 on: May 03, 2024, 05:34:34 am »
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's sending on 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! :palm:

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 --omap output-mapping option to translate all CR being sent to LFs - e.g.: picocom --omap crlf --baud 9600 --echo /dev/ttyUSB0

And now it works! :)

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: [Select]
sleep 1000 </dev/ttyUSB0 &
stty -F /dev/ttyUSB0 9600
echo -e -n 'SYSTEM:BEEP\n' > /dev/ttyUSB0
echo -e -n '*IDN?\n' > /dev/ttyUSB0
cat < /dev/ttyUSB0

Ah, 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.
 
The following users thanked this post: paf

Offline Kean

  • Supporter
  • ****
  • Posts: 2124
  • Country: au
  • Embedded systems & IT consultant
    • Kean Electronics
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #3 on: May 03, 2024, 09:43:13 am »
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.
 

Offline jCandlish

  • Newbie
  • Posts: 4
  • Country: ch
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #4 on: May 18, 2024, 07:10:03 am »
I have found that the 'tio' program is useful for coms with the linux usbACM device.

https://github.com/tio/tio

It 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?
 

Online HwAoRrDkTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: gb
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #5 on: May 18, 2024, 03:05:15 pm »
On topic, where is the documentation for the East Tester ET54 series SCPI command set?

Annoyingly, 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.
 

Offline Hydron

  • Frequent Contributor
  • **
  • Posts: 997
  • Country: gb
Re: Controlling an ET5410A+ with SCPI from a Raspberry Pi
« Reply #6 on: May 18, 2024, 08:57:21 pm »
Note that screen can be used to talk to serial devices, syntax is
Code: [Select]
screen <device> <baud rate> - I find it's easier than minicom. To exit use ctrl-a, k, y IIRC
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf