I have been writing python automating scripts for an O-scope and an AWG. I am having issues sending Arbitrary waveforms to the AWG, the model is Siglent SDG2042X. I have the manual and it has an example using USB and the WVDT command. I am using ehternet and I am simply trying to use the example in the manual just to get things moving. The SCPI command has no effect on the AWG.
from Ethernet_Comm import Eth_Comm
from SCPI_Instruments import ScpiSDG2042X
import SDG2042X_Obj as sdg
import time
import binascii
import random
wave_data = [0xe000, 0xe000, 0xf000, 0xf000, 0x0000, 0x0000, 0x1000, 0x1000, 0x2000, 0x2000]
wave_points = []
for i in range(0,1):
wave_points += wave_data
count=1
print(wave_points)
print(len(wave_points))
def create_wave_file():
"""create a file"""
f = open("wave4.bin", "wb")
for a in wave_points:
b = hex(a)
b = b[2:]
len_b = len(b)
if (0 == len_b):
b = '0000'
elif (1 == len_b):
b = '000' + b
elif (2 == len_b):
b = '00' + b
elif (3 == len_b):
b = '0' + b
b = b[2:4] + b[:2] #change big-endian to little-endian
c = binascii.unhexlify(b) #Hexadecimal integer to ASCii encoded string
f.write(c)
print(c)
f.close()
# Set the Scope IP address and Port number
AWG_IP_ADDR = "192.168.1.230"
AWG_IP_PORT = 5024
awg = sdg.SDG2042X_Object(AWG_IP_ADDR, AWG_IP_PORT)
awg.open_connection()
awg.reset_inst()
#print(sc.get_id())
time.sleep(3)
create_wave_file()
f = open("wave4.bin", "rb") #wave4.bin is the waveform to be sent
data = f.read().decode("latin1")
print('write class:', type(data))
print('write bytes:',len(data))
print(data, type(data))
data.encode("latin1")
print(data, type(data))
awg.set_user_wave_params(channel_list[0], 'wave4', 2000.0, 4.0, 0.0, 0.0, data)
awg.set_user_wave(channel_list[0], 'wave4')
f.close()
The first object "SDG2042_Obj" where the functions are sent
def set_user_wave_params(self, source, name, freq, amp, offset, phase, data):
self.si.set_user_wave_params(source, name, freq, amp, offset, phase, data)
def set_user_wave(self, source, name):
self.si.set_user_wave(source, name)
The next object "SCPI_INstruments"
def set_user_wave_params(self, source, name, freq, amp, offset, phase, data):
self._send_qry(f"{source}:WVDT USER,{name}")
def set_user_wave(self, source, name):
self._send_qry(f"{source}:ARWV NAME,{name}")
Totally lost here. I ultimately want to send my own waves that I create with a python script, but I need to get over this obstacle first. Here is the link to the manual
awg
object. \$\endgroup\$