Format for programmatically building an Arbitrary Waveform for SDGs

February 26, 2018

The SDGs require UTF8 formatting for the words used to build an arbitrary waveform.

The code may report “UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x80 in position 77: ordinal not in range(128)”

This indicates that the arbitrary waveform data is coded as “ascii” which is not the expected data format “utf8”.

Here is the proper syntax for conversion using Python:

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import visa
import time
import binascii

import sys

#USB resource of Device
#device_resource = “USB0::0xF4EC::0x1101::#15::INSTR”
device_resource = ‘USB0::0xF4ED::0xEE3A::SDG2XBA3150062::INSTR’
#Little endian, 16-bit 2’s complement
#wave_points = [0x0010, 0x0020, 0x0030, 0x0040, 0x0050, 0x0060, 0x0070, 0xff7f]
wave_points = [0x0000, 0x0020, 0x0040, 0x0060, 0x0080, 0x00A0, 0x00C0, 0x00E0]
#wave_points = []