From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic Cycling Through Frequencies with VISA Control

Solved!
Go to solution

Hey all,

 

Apologies if there is a post with this type of topic, I couldn't find one. However I am trying to make my Function Generator completely automatic and able to cycle through various differing frequencies that I can specify, i.e. 599-600-601 MHZ. I originally thought of doing this with a for loop and an array however I cannot find any information that lets me use the array in this fashion. My goal for it is to be able to set the desired frequencies that I would like it to filter, run the LabVIEW code and have it automatically cycle through these frequencies. I have already programmed a way to use the function generator into LabVIEW with the code that is provided using the VISA function and a function generator I have. It makes sense for this issue to be involving the "write" part of the case structure, however past this point I require help. Obviously some issues also arise in the sense for the frequency to change, I must manually type "FREQ #MHZ" into the write command bar and manually click the button, however this issue is secondary to getting the automatic cycling to work first.

 

Any help would be great and thank you for all assistance!

0 Kudos
Message 1 of 7
(1,156 Views)
Solution
Accepted by topic author Poly99

You can just send a VISA write with "FREQ #MHZ" in your connect case if you always want to use MHZ range.

I do not know what your function generator command set so lets assume to set a frequency you use a command "SET_FREQ <frequency>", you can then use a format into string to put your frequency into that command.  Put that inside a loop with an array input and you can have all of the frequencies you want.

 

randoghsp_0-1651242359221.png

 

Message 2 of 7
(1,139 Views)

The Format String is one of my favorite functions.  It is extremely powerful, especially if you are dealing with SCPI commands.  Learn it well.

 

To really give some advice on using that function, I would need to know the model of your Function Generator and make sure I knew the commands.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(1,128 Views)

Thanks for the advice!

 

I have attached my attempts at it, does this look right? I wasn't able to get the format into string function to work with auto indexing on into the VISA Write however, but I tried to make it work. The actual command to alter the frequency on the function generator (which is a RIGOL DSG800 series) is "FREQ #MHZ" where # is the desired frequency number such as 500 to get 500MHz. I will always be using MHz like you said but I still want to be able to cycle through frequencies, hence why I need an array. Because of this, will I need to put FREQ %d MHZ into the format string or should i just have FREQ MHZ? 

 

Thanks!

0 Kudos
Message 4 of 7
(1,093 Views)

Move your VISA Write into the the FOR loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(1,073 Views)

I am still having some troubles. Mainly it is not cycling after the array is finished. I have added a wait timer so that it doesnt happen all at once, however once 900MHz is reached, it just stops and doesnt restart the loop.

0 Kudos
Message 6 of 7
(1,057 Views)

Make an outer For loop around what you have, wire the number of times you want the whole frequency sequence to repeat to the outer loop's count terminal, move the VISA open/close outside both loops and wire the error wire through all of the loops so that VISA open is called, then the loops run, when they finish, VISA close will be called.

Message 7 of 7
(1,042 Views)