Monday, October 15, 2012

Creating an Arbitrary Waveform Remotely on a 33500 Series Waveform Generator

In this post we will look at how to send an arbitrary waveform to a 33500A/B series waveform generator using a remote connection. We will use Standard Commands for Programmable Instruments (SCPI) to communicate and send the waveform data to the waveform generator. We will look at two different ways to send the waveform data first the easier but less efficient method of just using ASCII or string characters for the waveform points. The second method, which is more complex but more efficient, is using binary blocks of the waveform data. Finally we will present information on where you can download a MATLAB function that connects and sends arbitrary waveform data to a 33500A/B series waveform generator using a LAN connection.

The following SCPI command examples will work on the following waveform generators: 33521A, 33522A, 33521B, 33522B, 33511B, 33512B. The SCPI commands are in green and the comments describing them are in blue.

SCPI Commands to Configure and Send Waveform to 33500
//Reset the 33500 to power up state
//Clear volatile memory (not needed, just used for completeness)
//Nine waveform points sent to waveform memory, normalized between 1 and -1 (binary block example //discussed later
DATA:ARB myArb, .75, 1, .50, .25, 0, -.25, -.50,-1, -.75
//Wait for command to finish (optional, do not need on waveforms that do not have a lot of points)
//Select the waveform (chan 1) we just sent to volatile memory
//Select Arb waveform mode on the generator
//Store waveform in non-volatile memory if you want to use it again otherwise it will be erased when //generator is turned off
MMEM:STOR:DATA1 "INT:\myArb.arb"
//Set the sample rate of the waveform generator
//Set the amplitude
//Set the amplitude offset
//Turn off filter for step / staircase response. Other filter settings include "Normal" and "Step" (default)
//Set output Z to 50 Ohms
//Turn on the output

Note that depending on the programming language and drivers being used you may have to add a newline character "\n" at the end of each command. The above SCPI commands resulted in the below waveform:

In the above example the waveform data was sent using data points in ASCII or string form. This method works fine for small to medium sized waveforms, but not large waveforms made up of hundred of thousands or millions of points. The two main reasons are long strings take up large amounts of memory and could cause a program to run out of RAM space and the long string causes to large latencies over the remote IO that often lead to connection timeouts. The answer is to send the data in binary blocks. The command for sending a waveform as a binary block of data is: DATA:ARB myArb, #236[36 bytes of your_binary_data];[PMT]. Notice the first part of the command is the same "DATA:ARB arbname," The number immediately after the pound sign tells the generator how long the byte length number is so in the example '2' means that the byte length number is two digits XX. The next numbers (2 digits) is 36, which tells the generator that there are 36 bytes of waveform data. The "PMT" portion of the example is the endline character.

What makes sending binary block waveform data a little more complex compared to the string example is the waveform data has to be converted into binary data. The details for converting double or float values to binary data differs from programming language to programming language. The following example is done in MATLAB. In this example only the command for sending the waveform data will be shown, the same setup and configuration commands used in the first example would be used here as well.

Sending Waveform using Binary Block Data in MATLAB
%Store waveform in array called wPoints
wPoints = [ .75 1 .50 .25 0 -.25 -.50 -1 -.75];
%Since default is double convert wPoint to single precision and convert to column vector
wPoints = single(wPoints');
%Tells generator that least-significant byte (LSB) of each data point is first. Most computers use this
fprintf(fgen, 'FORM:BORD SWAP');  

%get the length of the waveform data in points in bytes (each points 4 bytes)
iBytes=num2str(length(I) * 4);
%create string header of SCPI command
header= ['SOUR1:DATA:ARB myArb, #' num2str(length(iBytes)) iBytes];
%Convert waveform datapoints to a block of binary data
binblockBytes = typecast(wPoints, 'uint8');  
%combine header and datapoints then send to waveform generator
fwrite(fgen, [header binblockBytes], 'uint8'); 

I created a MATLAB function that connects to a 33500A/B waveform generator via LAN and sends it a waveform from a vector variable. The function is free to download at MATLAB Central using the link provided below or just search on its name "33500 Arbitrary Waveform Function" to find it.

In this post we looked at how to create an arbitrary waveform on the 33500A/B series of waveform generators. We looked at how to send waveform data in string form and binary block form. If you have any questions from this posts please email me and if you have anything to add to this post use the comments section below.

Download MATLAB function to send waveform data to 33500

Click here to download the 33500 series user guide / programming reference

Click here for more information on the 33500B series of waveform generators


  1. افضل شركة تنظيف خزانات بالاحساء و بالدمام

    تنظيف الخزانات من الامور الهامة فشركة الاول شركة تنظيف خزانات بالاحساء لديها افضل خدمات تنظيف خزانات بالدمام من التطهير والتعقيم والتنظيف على اكمل وجة فشركة الاول لخدمات تنظيف خزانات بالاحساء لديها امكانيه التنظيف وغسيل جميع انواع الحزانات من خزان العلوى والارضى والخرسانيه بطريقة احترافية تساعد على ازالة كل الترسوبات والمتواجدة فى الخزان والاهتمام باعمال التعقيم من خلال افضل مواد متواجدة ومتعارف عليها ذات جودة عالمية دون ان ثؤثر على مياه الشرب فالاول افضل شركة تنظيف خزانات بالدمام و تتميز باسعارها التى تناسب الجميع وانظباط المواعيد وتتميز بعمالة مدربة على جميع انواع الخزانات


    افضل شركة تنظيف خزانات بالرياض

    تنظيف الخزانات من الامور الهامة فشركة الاول شركة تنظيف خزانات بالرياض لديها افضل خدمات الخاصة بعمليات تنظيف خزانات بالرياض من التطهير والتعقيم والتنظيف على اكمل وجة فشركة الاول لتنظيف خزانات لديها امكانيه التنظيف و غسيل خزانات بالرياض
    جميع انواع الحزانات من خزان العلوى والارضى والخرسانيه بطريقة احترافية تساعد على ازالة كل الترسوبات والمتواجدة فى الخزان والاهتمام باعمال التعقيم من خلال افضل مواد متواجدة ومتعارف عليها ذات جودة عالمية دون ان ثؤثر على مياه الشرب

  2. بادروا الآن بالتواصل مع أهم شركة تسليك مجارى بالدمام و بجميع
    أنحاء المملكة و هي شركة أبراج دبي التي تقدم لكم مستوي رائع
    من الخدمات فتخلصكم من جميع مشاكل تسربات المياه التي تنتج
    من مواسير الصرف كما تعتبر
    شركتنا أكبر شركة كشف تسربات المياه بالدمام و توفر
    لكم أحدث الأجهزة .

    للتواصل الآن عبر :-

  3. Really nice information you had posted. Its very informative and definitely it will be useful for many people

    cong ty lam phim 3d du an

  4. This comment has been removed by the author.

  5. This comment has been removed by the author.

  6. It has been quite a while since i came across this kind of a post, a page that provides the readers with very impressive details that are very relevant and informative. With the most quality copy-reading & headline writing help, be sure that sharing more information in a more accurate manner will be very possible. We do provide the best kind of services, assistance that is always delivered by experts.

  7. This is a superb article, Given such a great amount of data in it, These sort of articles keeps the clients enthusiasm for the site, and continue sharing more ... good fortunes.

    seo package

  8. chronic pain treatment
    A decent blog dependably thinks of new and energizing data and keeping in mind that understanding I have feel that this blog is truly have each one of those quality that qualify a blog to be an one.I needed to leave a little remark to help you and wish you a decent continuation. Wishing you the good luck for all your blogging endeavors.

  9. This is a magnificent article, Given such an incredible measure of information in it, These kind of articles keeps the customers eagerness for the site, and keep sharing more ... favorable circumstances.

    iPhone x case

  10. Magnificent design and great utilization of fluctuated media.

    samsung galaxy cases

  11. Accountants Hove
    i get solution of a problem after reading this artical thanksssss