07-31-2014 11:21 AM
I am writing a program for an Agilent E4421B signal generator to perform a list sweep between a specified range of frequencies (ramping up to the maximum frequency and then back down to the initial frequency). The signal generator only holds a list of 401 points, which is a problem when I want to sweep over a large range of frequencies. To get around this, I would like to perform multiple list sweeps in a row. However, I cannot figure out an efficient way to "tell" the program to wait until the previous sweep has finished before sending a new sweep command to the signal generator. Any ideas? For reference, I am using the Agilent ESG Series LabVIEW drivers.
Solved! Go to Solution.
07-31-2014 11:36 AM
I'd have to look at the drivers, but many instruments will use an OPC? command. So you send the OPC? command and then wait for the instrument to respond. The instrument isn't supposed to respond until it is done.
07-31-2014 11:46 AM - edited 07-31-2014 11:47 AM
If you were using standard VISA calls, I'd just say to send the sweep command but append ;*opc? (operation complete?) to it to make it a query. Then execute a VISA read to read what comes back. This instructs the equipment to send a 1 to the output buffer when it has completed the sweep (or just about any other operation, too). Since you are waiting for a response, your computer will wait for the timeout amount for it to see a response, so there's your efficient way to with the exact amount of time - no less, no more - than it actually needs to take.
A few caveats:
1) Make sure the timeout is longer than the time it takes for your slowest sweep.
2) There are some variations of the "1" being sent back. I've seen "1", "01" and even "1.00E+3" so allocate more than just one byte to read.
07-31-2014 11:54 AM
Somehow I didn't know about the OPC command. Thanks for leading me in the right direction!
07-31-2014 11:55 AM
As far as I can tell, it works perfectly now. What a simple solution. Thank you!