JJdasWIESEL
JJdasWIESEL

Reputation: 43

pyserial: how to receive rs232 answers from power supply correctly

I'm currently trying to set up a communication with a power supply (RND 320-KA3005P) through RS232 with pyserial. The Problem is that after sending "*DIN?", which should return manufacturer, model name and software version, the connection seems to receive nothing. Also no other command was successful. Using the included software, after connecting, a LabView program opens and the device is remote controllable, so I think the problem is in my code.

Code Example: Connection parameters as described in the manual. As end-of-line characters I tried "\r\n","\r","\n" which seems to solve many other problems, but here with no success.

import io
import serial
import time
import sys

ser = serial.Serial('COM4',
                baudrate = 9600,
                bytesize=8,
                timeout=1,
                stopbits = serial.STOPBITS_ONE,
                parity = serial.PARITY_NONE,
                xonxoff = False)

eol_char = '\r\n'
sio = io.TextIOWrapper(io.BufferedReader(ser),newline=eol_char)

while True:
    sending = input("type:\n")
    ser.write((sending + eol_char).encode('utf-8'))
    time.sleep(0.2)
    ans = sio.read()
    sys.stdout.write('received: ' + str(ans))
    print('\ntry again\n')

Which after entering the command gives:

type:
*DIN?
received: 
try again

type:

Also when I run the script on the loopback

ser = serial.serial_for_url('loop://',timeout=1)
...

output:

type:
*DIN?
received: *DIN?

try again

type:

it seems to work fine. I'm using Windows 10 and a USB to RS232 converter. Does anyone have an idea about what I'm missing here?

Thanks in advance.

Upvotes: 2

Views: 1700

Answers (2)

Heneer
Heneer

Reputation: 313

I believe the *DIN? command, found under "Functionality check" which should return: "Manufacturer, model name, software version.", is actually a typo. When all commands are later listed in the manual, number 11 says *IDN? and should return the KA3005P identification.

It is also ironic that the example they give under number 11 says: "* IDN?"...

Upvotes: 0

JJdasWIESEL
JJdasWIESEL

Reputation: 43

The solution I figured out is rather disappointing. Turns out that with a USB to RS232 converter cable, instead of the USB connection I used before, the commands to set and get values work as expected. The command '*DIN?', which I tried initially, which I got from the manual:), still gives no reaction - probably just not supported.

Upvotes: 0

Related Questions