Author Topic: Serial data generator tool for Siglent SDG1000X/2000X/6000X AWGs  (Read 1219 times)

0 Members and 1 Guest are viewing this topic.

Offline HexleyTopic starter

  • Regular Contributor
  • *
  • Posts: 204
  • Country: us
I recently needed to create serial data strings in order to test a system, and did not want to dedicate a PC for the purpose. So I used the TrueArb function of my Siglent SDG1000X AWG to generate the serial data as a set of waveform points in the ARB memory.

This was done with a Python script that reads an input text file, expands each character into the proper bit sequence, then uploads the result to the AWG. The script can handle the usual serial parameters: baud rate, data length, parity, and stop bit count. It also can generate either a logic signal (swings from a positive voltage to ground and idles high), or an "EIA" signal (swings from a negative to a positive voltage and idles low).

The scope image attached shows the AWG delivering logic level data at 19200,8,N,1 from channel 1 (upper trace), and EIA level data at 9600,8,N,1 from channel 2 (lower trace). The scope is decoding the EIA data, just to confirm that things work as expected.

The script is named psag1.py. If invoked with no parameters, it returns this prompt:

usage: psag1.py [-h] [--name NAME_WAVE_FILE] [--chan CHANNEL] [--output OUTPUTFILE] [--baud BAUD] [--len CHR_LEN]
                [--par CHR_PARITY] [--stop CHR_STOP] [--mode MODE] [--vmax VMAX]
                inputfile



The trace at the top of the scope photo was generated by the command below, where "foo1.txt" is the 5-character input file. Note that many parameters are not specified, as their default values are used.

py psag1.py --chan 1 --name wave1 --mode TTL --baud 19200 foo1.txt
Converting 5 characters into 5.000V TTL serial format: 19200,8,NONE,1
Data conversion complete. Results stored in ./awg.dat.
Sent to AWG as wave1 on channel C1.
Script complete.


This version of the script uses a hard-coded IP address for the AWG, and it does not do any error checking on file names. There are a few other things that could be improved if anyone feels motivated, but it works well enough for my present purposes.

Although it has only been tested with an SDG1000X, it should run on the family mates SDG2000X and SDG6000X.

I hope others find this as useful as I have.
 
The following users thanked this post: egonotto, jjoonathan, Mortymore, derree, w1wra

Offline bicycleguy

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: us
Re: Serial data generator tool for Siglent SDG1000X/2000X/6000X AWGs
« Reply #1 on: July 25, 2022, 12:44:27 am »
Nice,
had to add  '@py' into line 28 as below or crashed python3 with 'Abort trap: 6'

rm = pyvisa.ResourceManager('@py')

Iv'e had this happen before and is really hard to debug because python crashes.  That and IP address were only changes.  Don't know why yours runs ok?

thanks

« Last Edit: July 27, 2022, 07:52:29 pm by bicycleguy »
 

Offline HexleyTopic starter

  • Regular Contributor
  • *
  • Posts: 204
  • Country: us
Re: Serial data generator tool for Siglent SDG1000X/2000X/6000X AWGs
« Reply #2 on: July 26, 2022, 06:18:37 pm »
Nice,
had to add  '@py' into line 28 as below or crashed python3 with 'Abort trap: 6'

rm = pyvisa.ResourceManager('@py')
Glad you got things working.
Which model of SDG are you using, btw?
« Last Edit: July 27, 2022, 08:39:20 pm by Hexley »
 
The following users thanked this post: w1wra

Offline bicycleguy

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: us
Re: Serial data generator tool for Siglent SDG1000X/2000X/6000X AWGs
« Reply #3 on: July 26, 2022, 08:48:21 pm »
SDG2042x and python 3.10.5 with pyvisa 1.12 on a Mac with 10.15.7
« Last Edit: July 26, 2022, 09:05:45 pm by bicycleguy »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf