LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from Excel

You VI was written in 6.1. Unfortunatetly I don't have 6.1. I have 6i (i.e. 6.0) and 7.0. When I ran your code under 7.0 it correctly acquired the values from the cells. It also appears that you are using an older version of Office since you are using the "Value" property node. I believe Office 2000 was the last version that used that, and subsequent versions used "Value2". Regardless, I cannot replicate your problem, so I can't say what's wrong.

 

P.S. 

  • You're still wiring a populated array constant to the Variant To Data. This is not necessary. Just wire an empty array.
  • Filepaths should not be specified using string controls. Use the File Path Control - that's what it's for. Use the Path To String function to wire the value for the "Open" method. 
Message 11 of 21
(1,382 Views)

Thanks Smercurio...

 

I was able to get it working!

 

If it's not too much to ask, I'd like to move onto the next phase. The entire project is based upon a communication using GPIB with a HP8648A signal generator. If you look to my first post, the overall specs are listed. I have an updated file including both the excel data extraction as well as the GPIB; partially setup. It's just a matter of linking them in a way so as to fulfill the steps needed.

 

You'll notice that I have two inputs associated with the Format Into String function. How does the string distinguish between the two data inputs?

 

Much obliged...

Download All
0 Kudos
Message 12 of 21
(1,331 Views)

You need to drive a for-loop (not a while loop) from the data that you read from Excel. I'm assuming that column 1 is your frequency and column 2 is your power.

 

What else do you need to do after setting the frequency and power? Are you taking any readings, or is this just for show?

 

Aside: I don't understand why you're using an Excel file. A tab-delimited text file would be much easier to deal with. 

0 Kudos
Message 13 of 21
(1,323 Views)

Yes, you are correct in assuming that column 1 is the frequency but column 2 is an antenna factor that I haven't filled in properly as of yet to be in dBm. The readings are to be done on a spectrum analyser so LabVIEW is not needed for that stage unless I develop it further in the future. I have done what you suggested in using a for-loop with n = 93 but am having an issue at the output side of the for-loop. For instance, the error output won't connect as it says the source and sink are different because of a 1D array of cluster of 3 elements at the source and a cluster of 3 elements at the sink (see figure). The same is said about the VISA resource name. Do I need some form of conversion link? Do these need to remain inside the for-loop?

 

Also, I have saved the file as a tab-delimited. Would the next step involve the use of read-from-spreadsheet-file.vi or is there a more suitable method?

0 Kudos
Message 14 of 21
(1,305 Views)

After hours spent on this today, I finally put together a solution. There's always room for improvement so are there any better ways of producing the same outcome? How do I produce a folder icon to open the file instead of manually typing in the file location each time it runs? Also, the cluster conversion at the outputs... is there a way around this? The array extracts the values from the file properly but it seems quite cumbersome; is there a more efficient way of doing this?

 

Thanks

Download All
0 Kudos
Message 15 of 21
(1,288 Views)

No, that's not right at all. The intention of using the for-loop was so that you don't have to hard-wire the iteration count - you simply use auto-indexing. You should be using a shift register to pass the error around the loop. If you need to have a VISA resource indicator then you just need to wire that to the control directly. You can also use a shift register for the VISA resource if you wish. (You can wire it directly through without a shift register by disabling auto-indexing at the output, but you must be aware that if the loop does not run then the output will be empty.)


How do I produce a folder icon to open the file instead of manually typing in the file location each time it runs?

Right-click on the control and select Visible Items->Browse Button.

 

Please see attached.

Message 16 of 21
(1,272 Views)

Thanks,

 

I modified my input file to cycle through, using 1MHz steps which accounts for approximately 1000 rows. The duration of this test was 2:03 mins. Is there a way to increase the speed of the for loop's operation?

Download All
0 Kudos
Message 17 of 21
(1,245 Views)

The only way you can speed up the For loop is to pull everything out but the VISA Write.

 

Do your array manipulation and format into string outside the loop to create a 1-D array of strings which you then pass into the loop through auto-indexing.  I don't know if this would actually speed things up very much.

0 Kudos
Message 18 of 21
(1,241 Views)

I discovered that it was the equipment that was limited in receiving SCPI commands. I further altered my design whereupon I have established a continuous loop that restarts the process once it is complete. Please let me know if there can be any improvements or if I have missed out something vital.

 

Thanks again

Download All
0 Kudos
Message 19 of 21
(1,230 Views)
I would move the Read from Spreadsheet File out of the While loop.  Unless you expect the file to change between iterations of the While loop, it doesn't make sense to continually re-read the file.
0 Kudos
Message 20 of 21
(1,225 Views)