ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect Read From Spreadsheet File.vi to VISA Write?

Need alittle help from all the experts here 😄

I am trying to connect Read From Spreadsheet File.vi All Row function(String output) to VISA Write and it does not work because the source is a 2-D Array, while the sink is a String, Assuming that the Error in/error out and all necessary line are already wired, except the read from spreadsheet...  is there a way to make it work?


0 Kudos
Message 1 of 16
(5,614 Views)

What is the content of the file? Is each element of the array a command or do you need to format the data you are reading? Provide an example of the data and details on what exactly has to be written to the device you are trying to write the data to.

p.s. Your image shows you reading an .xls file. You cannot read a native Excel file with the Read From Spreadsheet function. Read From Spreadsheet means to read delimited text files. You can easily export a native Excel file with tabs or commas as delimitors.

0 Kudos
Message 2 of 16
(5,604 Views)
thank you for pointing out that i can't read from a native xls, i have saved it as a text tab(delimited) format, below is the data that it contain, the values inside are randomly generated by myself as a simulation i'm doing for my project. i would like the VISA WRITE to write the data line by line downwards, and my VISA READ should be able to pick it up line by line too.
 
 
0 Kudos
Message 3 of 16
(5,598 Views)

A couple of nested for loops is all that you would need. Note that I have not included any error checking. You could use the conditional terminal that 8.5 has with a for loop to stop in case of error.



Message Edited by Dennis Knutson on 05-08-2008 09:21 PM
0 Kudos
Message 4 of 16
(5,592 Views)
thank you sir, it is working now, but i noticed now i have another problem, it's on the VISA READ side... the data i received via VISA read is all in a single column, i want it to be like the same like how the data was sent.  how can i do that? thanks in advanced! i have attached my block diagram and the received file.
 
 
 
0 Kudos
Message 5 of 16
(5,583 Views)
Why don't you have a for loop with a VISA Write? The VISA Read should be inside the innermost for loop right after the Write. Wire the data read out of both for loops and you automatically have a 2D array.
 
The autoindexing feature of for loops is very basic LabVIEW. Have you discovered the resources for learning this sort of stuff at https://learn.ni.com/learn/article/labview-tutorial?
0 Kudos
Message 6 of 16
(5,580 Views)
thank you very much again for the help, but i'm still getting 1 single column of data, don't know what i am doing wrong though, sorry i have only used labview for around 2 weeks, everything was self taught myself, and facing some problem where i can't find solution... i attached my block diagram of the visa read and the received file.
 
0 Kudos
Message 7 of 16
(5,572 Views)

I still don't know what you did with the VISA Write.Smiley Surprised Your code is not to read what was just written.

Assuming that you are doing some sort of loopback test, do something like what is shown below.



Message Edited by Dennis Knutson on 05-08-2008 10:11 PM
0 Kudos
Message 8 of 16
(5,563 Views)

i am not doing a loopback test, assuming i am using Computer A, i am actually receiving data from a spreadsheet file on Computer B via RS-232. Means to say, Computer B is using VISA WRITE, Computer A is using VISA READ to receive the data, and store it into a spreadsheet on C:\Received.txt... I am actually modifying the Advanced Read and Write.vi found in the example code to get this function, as this is a basic requirement of my project, but i am really lost on how to do that... sorry for the ton of questions.

0 Kudos
Message 9 of 16
(5,557 Views)

Okay, I think I understand now. Instead of sending out each element in each row with separate writes, concantanate each into a single string (i.e. x=n,y=n2) and use a single write for each row. On the receive side, the read would be in a while loop and your would parse a read into a 1D array.

Note: If you are still experimenting because you have no idea of the actual instrument you will be using, be aware that you will probably have to rewrite most of this code.



Message Edited by Dennis Knutson on 05-08-2008 10:44 PM
0 Kudos
Message 10 of 16
(5,552 Views)