Author Topic: Siglent SDG1032X bug in user-defined waveforms  (Read 641 times)

0 Members and 1 Guest are viewing this topic.

Offline kvdTopic starter

  • Contributor
  • Posts: 34
  • Country: nl
Siglent SDG1032X bug in user-defined waveforms
« on: February 02, 2023, 08:09:17 pm »
I think I discovered a bug in the SDG1032X firmware (version 1.01.01.33R3) in the receiving of user-defined waveforms from a computer by SCPI over sockets. In short, any \x0a byte in the waveform data which is sent to the device is regarded as a termination character. It does not matter if this \x0a byte is the high or low byte. Importing a waveform with a \x0a byte in it will mark the end of the waveform and cause corrupt waveforms in the SDG.

The attached Python script shows the issue. It generates square waveforms 100 points long for high value of 2559/32767 and 2560/32767. The value 2560/32767 does have a \x0a high byte and shows the issue. For the 2559/32767 value it does not need correction. For the 2560/32767 value an uncorrected and a corrected waveform is generated. (Note that sometimes after uploading an incomplete waveform, the SDG hangs and needs to be restarted).

In the screenshots it can be seen that the 2560_uncorrected waveform is read incompletely. It only has 51 datapoints instead of 100.

The issue can be 'solved' by before sending the bytes to the SDG, scanning the bytes and replacing any \x0a with \x0b. This results in an error of 100*1/32767=0.3% if the \x0a is low byte, 100*256/32767=0.8% if \x0a is in the high byte.

This issue not only occurs with SCPI over sockets, but also using PyVISA. PyVISA seems to be aware of this issue and solves it in a different way, although with larger error.

I think the issue could have been solved if the LENGTH parameter in the WVDT command was supported for the SDG1032X. Then the SDG could read until the given number of bytes have been received, not until it encounters a termination character (which may be part of the waveform).

Anyone has also noticed the issue and maybe solved it in another/better way?

Koen




import socket
import time
import sys
import binascii
import matplotlib.pyplot as plt

def open_socket():
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('169.254.1.177', 5025))
        s.settimeout(0.5)
    except socket.error:
        print('Failed to connect')
        sys.exit()
    return s

def close_socket(s):
    s.close()
    time.sleep(.300)

def send_command(s, cmd):
    try:
        s.sendall(cmd)
        time.sleep(1)
    except socket.error:
        print('Command failed')
        sys.exit()
    try:
        response = s.recv(4096)
    except socket.timeout:
        response = b''
    return response


def corrected(signal):
    d = (signal*32767).astype(np.int16)
    return d.tobytes().replace(b'\n',b'\x0b')


def uncorrected(signal):
    d = (signal*32767).astype(np.int16)
    return d.tobytes()


s = open_socket()
qstr = send_command(s, b'*IDN?\n')
print(qstr.decode('utf-8'))

# create a signal of 100 times a value without problems
value_ok = 2559/32767
signal_ok = np.array([value_ok]*100)
data_ok_uncorrected = uncorrected(signal_ok)
qstr = send_command(s, b"C1:WVDT WVNM,2559_UNCORR,FREQ,1000.0,AMPL,1.0,OFST,0.0, PHASE,0.0,WAVEDATA," + data_ok_uncorrected + b'\n')

# create a signal of 100 times a value with the problem
value_not_ok = 2560/32767
signal_not_ok = np.array([value_not_ok]*100)

data_not_ok_corrected = corrected(signal_not_ok)
qstr = send_command(s, b"C1:WVDT WVNM,2560_CORR,FREQ,1000.0,AMPL,1.0,OFST,0.0, PHASE,0.0,WAVEDATA," + data_not_ok_corrected + b'\n')

data_not_ok_uncorrected = uncorrected(signal_not_ok)
qstr = send_command(s, b"C1:WVDT WVNM,2560_UNCORR,FREQ,1000.0,AMPL,1.0,OFST,0.0, PHASE,0.0,WAVEDATA," + data_not_ok_uncorrected + b'\n')

close_socket(s)

plt.plot(signal_ok)
plt.plot(signal_not_ok)
 

Offline kvdTopic starter

  • Contributor
  • Posts: 34
  • Country: nl
Re: Siglent SDG1032X bug in user-defined waveforms
« Reply #1 on: February 05, 2023, 07:13:44 pm »
Another way to get a user-defined waveform from the computer into the SDG is by writing it into a .csv file, putting it on a usb-stick and recalling it on the SDG.

This works, no errors there, only needs some usb-stick swapping.


 

Offline kvdTopic starter

  • Contributor
  • Posts: 34
  • Country: nl
Re: Siglent SDG1032X bug in user-defined waveforms
« Reply #2 on: February 05, 2023, 07:24:38 pm »
This code generates an FM stereo multiplexed signal, left 1kHz and right 2kHz with the 19kHz pilot tone, and writes it into a csv file which can be read by the SDG. This same signal could not be read by the SDG over SCPI and sockets because of the \x0a character in the waveform data.

==============

# Using HavesineExampleFile.csv from https://siglentna.com/wp-content/uploads/2017/12/EasyWaveCSV.zip as an example.

import matplotlib.pyplot as plt
import numpy as np
import csv

SAMPLES = 16384

# time axis
t = np.linspace(0,1,SAMPLES,endpoint=False)

f1 = 1
f2 = 2
f19 = 19
f38 = 38

s1 = np.sin(f1*2*np.pi*t)
s2 = np.sin(f2*2*np.pi*t)
s19 = np.sin(f19*2*np.pi*t)
s38 = np.sin(f38*2*np.pi*t)

# FM signal
ratio = .9
left = s1
right = s2
tone = s19
mono = (left + right) / 2
stereo = s38 * (left - right) / 2
signal = ratio * (mono + stereo) + (1 - ratio) * tone

with open('L1_R2.csv','w') as f:
    writer = csv.writer(f)
    writer.writerow(['data length', f'{SAMPLES}'])
    writer.writerow(['frequency','1000'])
    writer.writerow(['amp','2.5'])
    writer.writerow(['offset','0'])
    writer.writerow(['phase','0'])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['',''])
    writer.writerow(['xpos','value'])
   
    for i in range(SAMPLES):
        writer.writerow([t,signal])
       
plt.plot(signal)
 
The following users thanked this post: Cauf, Hexley


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf