Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear an arbitrary waveform from an IVI frequency generator

I'm writing a simple app (in measurement studio 6, c++) to download arbitrary waveforms to my agilent 33220A function generator.

Unfortunately, this instrument ivi driver doesn't support the m_pFgen->Arbitrary.ClearMemory() function. So I want to clean up any waveforms I download after I've finished with them. TO do this, I'm trying to use
m_pFgen->Arbitrary.Waveform.Clear(waveform_handle);

However, even with the generation stopped (using m_pFgen->Abort();) it is still 'selected' in the instrument and it won't let me clear it. The NI spy error is:

> 409. IviFgen_ClearArbWaveform (afg, 10006) ...
> Status: 0xBFFA2008 (IVIFGEN_ERROR_WFM_IN_USE)

HOW CAN I DELETE THIS WAVEFORM?

Since some waveform is always selected when the instrument is in Arb mode, and I can't find any IVI functions to select something else, I have tried changing the function generator into sine mode, then clearing the waveform by:

m_pFgen->Output.Mode = CNiIviFgen:FunctionMode;
m_pFgen->StandardWaveform.Configure(m_channel, CNiIviFgen::SineWaveform, m_amplitude, m_offset, m_frequency, m_phase);
m_pFgen->Arbitrary.Waveform.Clear(waveform_handle);

This generates this error
> 520. IviFgen_SetAttributeViInt32 (afg, "",IVIFGEN_ATTR_OUTPUT_MODE, 0)
> Status: 0xBFFA0001 (IVI_ERROR_INSTRUMENT_STATUS)

If I run the above code again, it then all works fine, and the waveform gets deleted.PLEASE COULD SOMEONE EXPLAIN WHY THIS IS HAPPENING? If I swap the Output.Mode and StandardWaveform.Configure lines, I get a different error which I keep getting if I run the code again.

> 542. IviFgen_ConfigureStandardWaveform (afg, "1", 1, 1.000000E+001, 0.000000E+000, 5.000000E+002, 0.000000E+000)
> Status: 0xBFFA4002

THIS STILL SEEMS LIKE A SLOPPY WAY OF CLEANING UP. DOES ANYONE HAVE ANY BETTER IDEAS?

thanks
0 Kudos
Message 1 of 6
(3,332 Views)
Hello!
You said you stopped the generation using the m_pFgen->Abort function.  Most of the time, the abort function will instantly stop the program without exiting or clearing anything, so the program may still think the waveform is still being generated/acquired.  This may be why it says the waveform is stll in use.  Is there an alternate way to stop the generation without using abort that your instrument can understand?  Also, when you are changing the mode, you change to the "FunctionMode", but then try to clear the arbitrary waveform.  You may want to change it back to arbitrary mode before trying to clear the arbitrary waveform.  For example: output mode=sine mode, standard.waveform configure, output mode = arbitrary mode, arbitrary clear.  I am not sure how your instrument works, so I am not sure if this will help.  Since you can't use the ClearMemory function, you may have to use a round about method to clear the waveform, but you should be able to do it without any errors.  Let me know if this information doesn't help and I will look into it further for you.  Best of luck and have a great day!
 
Chris R.
Applications Engineer
National Instruments
Chris R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,309 Views)
Thanks for your reply.
I have tried with and without using the ABORT function - makes no difference.

ALternative ways to stop generation - all I can see is SetOutput.Enabled = false; again, makes no difference.

Clear memory (using the handle used to create it) DOES WORK, but only when it's been taken out of Arb mode. THe problem is the error when taking it into this other mode. THe first time I try to take it inot sine mode, I get an error. DOing exactly the same things again works fine.

I found and IVI-com driver on the agilent site, (thinking that there was a bug in the IVI-c driver I am using above) and naively thought I could just 'plug it in MAX'.After installing visa-com as the seconadry visa driver, I installed this ivi-com driver. MAX could see it. However, I try to use it in place of the IVI-c and the app doesn't work at all (error - file not found). I looked at the examples that came with the driver and the specific dll is imported into the code - this may be because it was written without max in mind, but I don't see how this is interchangeable. Rather it is hard coded in! IS IT POSSIBLE TO USE AN IVI-COM DRIVER in MAX the same way as IVI-c? IF not, what it interchangeable about it then!???

THanks
0 Kudos
Message 3 of 6
(3,304 Views)

Hi

I've reproduced an error similar to the one that you have by using the LabVIEW IVI driver available on IDNet.  I did so by adding a Clear Arb Waveform function call directly after configuring and outputing a user-defined arb.  An error returns stating that you can't clear the currently selected Arb from memory.  Based upon this, I decided to select one of the built-in arbs (sinc) before clearing my user-defined arb.  After making this change, the error disappeared.  So in summary, here is what to do once you are ready to clear your user-defined arb (at a high level):

1) Disable/Abort the output (optional)

2) Select a built in waveform, such as Sinc (according to LabVIEW, the handle for the sinc waveform is 10004). The 33220 has 5 built in arb waveforms to choose from, which are described on page 228 of the users manual. Link:

http://cp.literature.agilent.com/litweb/pdf/33220-90002.pdf

3) Call the Clear Arb Waveform function, using the handle for your user-defined waveform(s).

Hope this solves your original problem!

Message 4 of 6
(3,291 Views)
Many thanks for replying. Knowing the handle of a built in waveform would solve my specific problem. HOWEVER, my application is intended to allow ANY instrument to be used, so this would 'break it' since other AFGs would not necessarily have a built-in waveform with the same handle.

I've found an IVI-com driver in which clearmemory does work, but catering for ivi-com as well would give me more (unncessary IMHO) work. For solutoins to handling ivi-c and ivi-com, please see my other post if interested:
http://forums.ni.com/ni/board/message?board.id=140&message.id=14108

Unless the COM adapter classes mentioned in the above post work for me 'out-of-the-box', I think I'll stick to ivi-c and include a bit of instrument specific code as you suggested since it's the only ivi afg we have at the moment, and use the clearmemory for the general case, hoping other fgen drivers implement it!

BTW, any idea how to query the iviconfigstore to find the ivi driver type (c or com)? If so, please see
http://forums.ni.com/ni/board/message?board.id=231&message.id=3799

Thanks
0 Kudos
Message 5 of 6
(3,276 Views)
FOr completeness, here is a sequence which does allow the last uploaded waveform to be cleared, without choosing an inbuilt waveform (which would not necessarily be present on another instument)

m_pFgen->Utility.Reset();
m_pFgen->Output.Mode = CNiIviFgen:FunctionMode;//optional
m_pFgen->Arbitrary.Waveform.Clear(m_hwfm);

Thanks for all your advice.
0 Kudos
Message 6 of 6
(3,246 Views)