From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Reading excel file from desktop in real time project in labview

Solved!
Go to solution

I have PXI chassi 1042 with CAN , LIN and FPGA . I have a RT project in labview to control where im trying to automate CAN read/write messages. 

 

My requirement is basically to load the sequence from an excel file and perform the actions based on that. Since i have the RT project i need to deploy my system first. By doing so and running the simple spreadsheet read throws an erro saying File not found. I'm wondering this is because after deployment, the file is searched on the target and it doesnt look in windows at host. How to handle this situation. Is there a way to read the excel file after deploying the RT project? Or is there a way to deploy the project after reading the excel (in this case i need to have the contents of the excel in memory when i'm deploying). 

 

0 Kudos
Message 1 of 13
(4,337 Views)

Hi Ramjay,

 

your RT target only has access to files on its local drive!

 

So there are simple solutions:

- copy the "Excel" files (which probably is just a formatted "spreadsheet" text file) to your RT target while deploying

- copy the spreadsheetfile to your RT target using FTP (or WebAccess) later on…

- create a PC host application to communicate with your RT target and to send new CAN configuration data over network…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(4,330 Views)
A real excel file? No
A tab delimited text file that is compatible with Excel? Yes

Also, if there is going to be a host application running on a PC, it could read the excel file and pass the data to the RT system.

Mike ...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 13
(4,329 Views)

so i have a pc host application and im trying to read the excel from the host ie PC itself. But this is not before deploying. I have to deploy the project and then im trying to read the excel. In this case im unsure if i can read it directly from the host or should i copy the file to the target and try to read from target. If i need to read it from the target, can you tell me how to copy the file to the target (path,format etc to write on target), and also how to read it from the target as wll.

 

Regards

Jay

0 Kudos
Message 4 of 13
(4,311 Views)

Hi Jay,

 

so i have a pc host application and im trying to read the excel from the host ie PC itself.

The PC/host app can read the "Excel" file (I still hope you talk about formatted text files here!), which is located on your PC host.

 

I have to deploy the project and then im trying to read the excel.

That's fine, we all have to solve the same issue!

Read the file on your PC host app and send it to your RT target using network communication.

 

In this case im unsure if i can read it directly from the host

As said before: your RT target is NOT able to access your PC host harddrive!

 

or should i copy the file to the target and try to read from target.

This would be a solution too - as said before.

 

how to copy the file to the target (path,format etc to write on target), and also how to read it from the target as wll.

As said before: use FTP. Or use the web access through MAX…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 13
(4,297 Views)
...or VI Server, or a TCP/IP connection, or shared variables...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 13
(4,286 Views)

We do this all the time.  We "program" behavioral trials, each of which can last up to a few minutes.  There are a lot of "bells and whistles" possible during a trial (robotic arms move speakers around, sounds play at different times in different patterns, lights go on and off, laser spots are projected here and there, and sometimes moved around), with multiple "epochs" (I call them "pre-stimulus", when we are moving things around to prepare for the trial, "stimulus", where we play sounds, flash lights, move targets, and "post-stimulus", where we query the subject or ask her to "point to the target"), all taking place on a millisecond time base.  Each row on the Excel Worksheet represents a Trial, and each of about 100 columns is a parameter for the Trial (including a possible "Ignore me" value that indicates that particular stimulus isn't needed).

 

The reading (and occasional writing) of the Excel file is handled by the Host (because File I/O, as well as Microsoft Excel, is well-handled by the PC).  At the beginning of an Experiment, the Host reads the appropriate row from Excel, a process that takes only a few milliseconds.  It then passes all of the Excel Parameters to the PXI using a Network Stream.  The PXI routine, once it gets all of the Trial parameters, runs the Trial, as it now knows what to turn on when, for how long, and then what to do.

 

All of this, of course, takes place at Run Time.  On the Host side, the User is asked for the name of the Excel File "driving" the Experiment.  Once the Experiment is underway, the rows of Excel are read on a Trial-by-Trial basis (by the Host) and the data are sent to the RT side to control that particular Trial.

 

Another advantage of this is that the Host has controls that allow the Experiment to be paused, a Trial repeated, and even allows an Experiment to be finished (meaning that the data files are closed) and restarted, without needing to reboot the PXI.

 

Bob Schor

0 Kudos
Message 7 of 13
(4,281 Views)

Hi Bob,

    Thanks for responding. But can you explain little more details on how exactly did you read the excel file information and cascaded that to the RT target? Because seems like what i'm looking for is exactly what you've done. Mine is a simple text formatted sequence in the excel file, which im trying to read and put it into my structure in labview RT project. Once the sequence decoding is done i'll start executing them on the realtime target, but the dependency is that i'll have to compile and deploy the project first, then load the sequence from the excel and update it into my structure and finally start the execution based on the sequences. As suggested by some previous posts, i was trying to copy the excel file to the target using FTP, but for some reason it didnt work. When  tried to right click on the PXI on MAX and selected File transfer, it doesnt work. It just time's out and says

 

"Notification: FTP Service Unavailable

This Page Cannot Be Displayed


The system cannot communicate with the FTP server ( 192.168.0.2 ). The FTP server may be busy, may be permanently down, or may not provide this service.

Please confirm that this is a valid address. If it is correct, try this request later.

If you have questions, or feel this is an error, please contact your organization's network administrator and provide the codes shown below.


Notification codes: 

(1, FTP_SERVICE_UNAVAIL, 192.168.0.2)".

 

 

 

I tried using the PUT FTP file in labview, got error with some error code 7- file error or something. So if possible, please provide me steps, screenshots or any other sharable info about ths as to how i can copy the excel file to my target. Also, i dont have much experience on working with RT projects hence im not sure if im missing any RT project properties configuration. I have attached screenshots of it. Please suggest. Thanks in advance.

 

Regards

JAy

0 Kudos
Message 8 of 13
(4,272 Views)

Do you know about Network Streams?  It's a method for sending information in a queue-like manner from Host to Remote, and from Remote back to Host.  In my RT routine, I have four Network Streams running.  The top-level routine in both Host and Remote is a Queued Message Handler.  One Network Stream is a "Send Message to RT", which sends a Message to a Network Stream Reader Loop on the Remote that, in turn, puts this Message into the Remote's Message Queue.  There is also a complementary "Send Message to Host" Network Stream that allows the Remote to send Messages mean for the Host's Message Queue.  Two more Network Streams, Samples and Events, are used to stream Sampled data (N channels of data acquired at 1KHz, sent in "chunks" of 50 samples at a time, or 20 times/second) and "Events", "point-in-time" signals such as a digital line going High or Low that are packaged along with their time-of-occurence, from the Remote to the Host (which, in turn, displays them and streams them to disk).  

 

So here's an example of how it works.  The Host QMH functions as a variety of State Machine.  When you push the Front Panel "Do a Trial" button, it generates the "Start Trial" Message to the Host.  The Host reads the data from Excel, packages it up (I pack it into a huge cluster, each element of which corresponds to the name of one of the Excel columns -- such consistency between the Excel names and the LabVIEW names makes the code easier to read/understand) as a Start Trial Message (with the Excel cluster as the "data" part of the Message) and hand it to the "Send Message to RT".  When the Message is received by the Remote's Message Stream Reader, it is put on the Message Queue of the Remote.  The Remote QMH executes its Start Trial, gets the Excel cluster with all of the variables it needs for this trial, and executes the Trial.  When the Trial is finished, it creates a "Trial Done" Message, possibly with some Trial Data to be send to the Host via "Send Message to Host" Network Stream.  When the Host Network Stream Reader gets this Message, it (again) simply enqueues it to the QMH, which then executes the Trial Done state, doing whatever is appropriate with the accompanying Data.

 

Another important set of Messages go back and forth when the program ends.  The Host sends the Remote a message to Exit, the Remote starts its Shut Down Procedure, one step of which is to send back an Acknowledgement (so the Host "knows" that it is OK to shut down the Network Stream), the Remote shuts down its Network Stream, and reboots itself.

 

The last detail is how the process starts.  This system is a "modern" LabVIEW RT system, which means that the Remote, when it is turned on, runs the RT part of the program automatically as its Startup routine.  The first thing that it does is go into a "Listen" mode for the Network Stream connections to be made.  It may have to wait days for this, but it's patient (there are timeouts built in to the Listen process -- most of the time it spends in a "Wait" state).  When the Host starts, its first task is to reach out and establish the Network Streams.  I forgot the exact timing, but if it cannot connect within a minute or two, it sends a message saying "Remote not responding -- please reboot it" and exits.

 

Bob Schor

 

P.S. -- I apologize for the delay in responding.  I started this at 10 pm last night, fell asleep, and when I returned to the Forum, said "Didn't I start a response?".  Fortunately, the Forum "remembered" the beginning of this for me ...

0 Kudos
Message 9 of 13
(4,233 Views)
Hi Bob,
Again thanks a ton for explaining elaborately. If I understand it right you are using a queue handler between your host and rt. The queue has the information like a state machine to define the behavior and also store the data. The part that I'm still unsure is how to store and share this network stream. I tried with a shared variable yesterday, but unfortunately a shared variable doesn't support string and array of strings. Unfortunately the data that I need to share is an array of cluster. It has the info from the excel file with string and integer data.so if possible can you help me with a basic very simple example on this context if possible? I'll look into the network streams examples/ tutorials myself but if you can at least refer me to a link or material or if you can share a simple example code or screenshot that'll be of great help. Again I appreciate your help and thanks a ton again. This is a really critical part of my program that's why I'm trying to understand clearly, don't mind.

Regards
Jay
0 Kudos
Message 10 of 13
(4,229 Views)