• RE: AFG31022 downloading waveforms

    Thanks Andrea!  I see a few things that are different than the examples in the manual, and what I captured with the USB analyzer from ARBExpress.  In general, do extra letters and upper/lower case matter as much as the manual suggests?  Line 128 in your code would be "SOUR1:FUNC EMEM1" if it were treated strictly. If the device doesn't care...

    The money line that transfers the data is line 145.  ARBExpress sends a command that looks like "TRACE:DATA EMEM1,#3200", where there's no leading colon, the hash tag is present, then the 3200 means there are 200 bytes that follow and there are 3 characters in the number 200.  Your example doesn't send a length. Does AFG.write_binary_values format that line for you? The PyVisa doesn't mention it and I'd think it's critical, no?

    It's frustrating since each of these sources seems to document something different than ARBExpress does, yet if I have my program emulate ARBExpress I can't get that to work either. Then if I switch back to 3022 commands and send them to the 3022, that works fine.  This is really weird.  I need to get arbitrary waveforms working first and then I can try out the really useful looking sequence code you shared.  I installed the trial option and our purchasing people are working on buying up a whole boatload of licences for all of our new 31022s.

    Howard
  • RE: AFG31022 downloading waveforms

    Maybe as an attachment?
  • RE: AFG31022 downloading waveforms

    No joy. I can't figure out a way to do this without it expanding to HTML and showing the HTML formatting...  Browser dependent maybe?  I'm using Chrome.....
  • RE: AFG31022 downloading waveforms

    I can't seem to find a way of pasting a screen of text without it converting to HTML.  :(  

    Since I can't easily share my C program for downloading waveforms, does anyone have a sample, tested program that works?  (any language is fine).  I tried replicating the BASIC program in the manual but so far I've found 3 different versions of the manual that have different programs and the command sequences don't seem to work.

    Thanks!
  • RE: AFG31000 Series - Sample Code for using optional SEQuencer

    Thank you Andrea!  That's really helpful, and I'll check to see if we licensed that feature. We wanted this specific unit because of the ability to send large waveforms but didn't know they had to be sequenced. We probably didn't buy that option because you know how purchasing people are - they see an extra cost and skip it to save money.

    Is it the case that a sequenced waveform has to go to channel 1 and you can't have two of them going to channels 1 and 2 at the same time? I think there's a lot of questions we should have asked before choosing this instrument that we didn't ask first.

    Howard

  • RE: AFG31022 downloading waveforms

    Yesterday I started exploring this sequencing thing, and now it appears that I'm unable to send ARB data at all.&nbsp; When I asked about the programming example a few months ago we puzzled over why the program in the manual only sent out one byte per data point. That didn't make any sense.&nbsp; I though the manual I had might have been buggy (early printing) and I found two other versions on the web that appear to be newer. In the latest one the BASIC example does indeed show two bytes per point, the high byte of a word before the low byte.&nbsp; So that made more sense.<br> <br> I'm working in LabWindows/CVI and I had a working test program that did a great job downloading waveforms to a 3022.&nbsp; I'm trying to update it for the 31022 and it looks something like this:&nbsp; (the functions are essentially wrappers around the VISA functions provided by NI)<br> <br> &nbsp;&nbsp; &nbsp;error = AFG_Init();<br> &nbsp;&nbsp; &nbsp;if (error &lt; 0)<br> &nbsp;&nbsp; &nbsp;{<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sprintf(strtemp, "I can't init the AFG. Error = %d. Should I try again?\n", error);<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;userchoice = ConfirmPopup("Can't init the AFG!", strtemp); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 1 = yes, 0 = no &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (0 == userchoice)<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;goto Error;<br> &nbsp;&nbsp; &nbsp;}<br> &nbsp;&nbsp; &nbsp;error = AFG_Command("*RST\r");<br> &nbsp;&nbsp; &nbsp;// squirt out a waveform<br> &nbsp;&nbsp; &nbsp;unsigned short wave1[128*1024]; &nbsp;// 128K points<br> &nbsp;&nbsp; &nbsp;<br> &nbsp;&nbsp; &nbsp;// call a function that opens a data file of numbers between 0 and 16382, writes<br> &nbsp;&nbsp; &nbsp;// each value into the array 'wave1' and returns the number of lines it read<br> &nbsp;&nbsp; &nbsp;// (the number of values) into 'linesread'<br> &nbsp;&nbsp; &nbsp;error = ReadWFMfile("mytestfile.dat", &amp;linesread, &amp;wave1);<br> <br> &nbsp;&nbsp; &nbsp;// Format a string so it looks something like "DATA:DATA EMEM1,#6128000" without a terminator<br> &nbsp;&nbsp; &nbsp;sprintf(str1,"%d", linesread);<br> &nbsp;&nbsp; &nbsp;sprintf(ourcommand, "TRACE:DATA EMEMORY1,#%d%s", strlen(str1), str1);<br> &nbsp;&nbsp; &nbsp;// Send that part of a command<br> &nbsp;&nbsp; &nbsp;error = AFG_Command(ourcommand);<br> <br> &nbsp;&nbsp; &nbsp;for (i=0; i&lt;linesread; i++)<br> &nbsp;&nbsp; &nbsp;{<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// Send each of the integer values as two bytes, high endian<br> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;error = AFG_Word(wave1[i]);<br> &nbsp;&nbsp; &nbsp;}<br> &nbsp;&nbsp; &nbsp;// Send a terminator for the DATA:DATA command<br> &nbsp;&nbsp; &nbsp;error = AFG_Command("\r");<br> <br> &nbsp;&nbsp; &nbsp;error = AFG_Command("FUNCTION EMEM1\r");<br> &nbsp; &nbsp; error = AFG_Command("FREQUENCY 8K\r");<br> &nbsp;&nbsp; &nbsp;error = AFG_Command("OUTPUT ON\r");<br> <br> ------------------------------------------------<br> <br> The AFG resets and changes states just fine but no variation of the TRACE command seems to make a difference. I wondered if there could have been firmware updates so that maybe my device doesn't properly interpret these commands?&nbsp; The manual shows words like EMEMory in upper and lower case where the lower case characters are for clarity and can be eliminated - yet the example shows the commands spelled out fully.&nbsp; I have firmware 1.6.1 installed if that matters.<br> <br> Any suggestions?&nbsp; Is that code above (which worked well on the 3022 with slightly different commands) fundamentally wrong somehow?<br> <br> Thanks!
  • RE: AFG31022 downloading waveforms

    Thanks!  That's exactly the leg up I was looking for. There other things to consider as well, like what kind of sync signal we'll get out of the unit but I'd like to experiment and see what we can do.   Yes, the delay as the waveform chunks switch from one to another might be a problem.  We'll see.

    Thanks again!

    Howard

  • RE: AFG31022 downloading waveforms

    Alfonso, we're well into our implementation now and I'd like to explore the sequencing to get in larger waveforms. Can you direct me towards a block diagram, an implementation of some sort or just a description of what commands I might send and in what order?

    I assume it's using TRAC to send sections to EMEM, then I have to transfer those to files in drive M:?  or P:?  Then use the SEQ comnmand somehow?  The documentation isn't as clear as I'd like it to be.

    Thanks in advance!

    Howard
  • RE: AFG31022 downloading waveforms

    Thanks. I was puzzled then by the example in the manual where a BASIC program computed a sine wave and sent it as one byte per point. I converted that to C and it generated a nice sine wave.

    Dim num_points = 3000
    Dim base = 9000
    Dim offset = 6000
    Dim SinePoint As Integer
    Dim SineWaveData(num_points) As Byte
    For i = 0 To num_points 'Build sine wave
       SinePoint = Int(base + offset * Math.Sin(i / 120))
       SineWaveData(i) = SinePoint / 256
    Next i

    Tvc1.SendEndEnabled = False
    Tvc1.FormattedIO.WriteLine("TRACE:DATA EMEM1, #43000")
    Tvc1.SendEndEnabled = True
    Tvc1.RawIO.Write(SineWaveData)

    It's been a while since I've written BASIC, but by my read this would send out 3000 bytes for 3000 points. I can believe the 31022 is the same as the 3022 was, but then this shouldn't work but it seems to?  

    Anyway, thank you a ton for the help. I feel like I'm reverse engineering this puppy.
  • RE: AFG31022 downloading waveforms

    Thank you for confirming my experiment, the quick reply and the update.  Can you also confirm that the older 3022 was like 11 or 12-bit data (two bytes per point) and the 31022 is 8-bit or one byte per point?  The documentation for the 31022 is quite sparse in comparison to that of the 3022.