Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Write from File

I have some commonds saved in a file. Those commonds need to be send to the device by serial communication as one command every 5 minites. I use "serial communication.vi" and replaced "VISA Write" function by "VISA Write From File" function. It works well when I send one commond. Then I use a "While Loop" and put thr modified "serial communication.vi" inside the "While Loop" in order that I can run the modified "serial communication.vi" every 5 minutes. The problem is that the vi always send first commands to the device at each loop. What I want is that it sends first command at first loop, second commond at second loop and so on. How can I write a commond to serial port from a file and take a commond from the file at current position, not from t
he beginning of the file. I appreciate if anyone can help.
0 Kudos
Message 1 of 5
(4,546 Views)
I don't know if there is anyway to do this simply using the VISA write file VI. But there are a couple of ways you can do the same thing using other VIs. One, you could read the entire file at the beginning of your VI and store the commands in an array, one command at each index of the array. Then in your while loop, using the normal VISA write VI and not the VISA write file VI, and write out array[0] during loop index 0, array[1] at loop index 1, etc. Or Two, you could use a read file VI in conjunction with the VISA write. You could manipulate the file position using the file vi's, get the data you want, and then write it with the normal VISA write.

I hope this helps!
Message 2 of 5
(4,546 Views)
Hi, thank you so much. I did it as you suggested and it works.
0 Kudos
Message 3 of 5
(4,546 Views)

Hi guys,

 

What's the maximum size the the array that I can use to store all the text lines of the file?

 

Thanks,

SB 

0 Kudos
Message 4 of 5
(4,087 Views)
This only depends on how much memory is available and the 32 or 64 bit version also differ in adressability, but you probably have too little memory to find this difference
greetings from the Netherlands
Message 5 of 5
(4,081 Views)