LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

store data in excel file in multiple columns

Hi,

 

I am working on a data logger type of project. I have to store data received from serial port into excel file. I have attached images of data I am getting at serial port  ,image of  how I want to store data in excel worksheet and image of VI i tried.

 

please note that I know VI   I  built is incomplete. I have mentioned in image, In which part exactly I need help...

 

If anyone can suggest more efficient ways to do this that will be very helpful.

 

0 Kudos
Message 1 of 12
(3,835 Views)

Hi pardhimegha,

 

when you receive those strings ("Xcount=, depth=, ycount=") then you could parse them with ScanFromString. Using StringToByteArray followed by ToDBL seems completely wrong here…

 

And please forget about BytesAtPort - you have the TermChar enabled so use it!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(3,819 Views)

Hi GerdW,

 

as per your suggestion I tried to put ScanFromString. Its showing error. I have attached image showing error. 

 

And sure I will remove Bytes at port block.

0 Kudos
Message 3 of 12
(3,810 Views)

You are not writing to an Excel file -- you are writing a "spreadsheet", which is entirely different.

 

It is usually a good idea to write yourself some documentation, as it can help decide how to structure your program.  For example, do you collect all of the data, and then write it all at once?  That suggests three sub-VIs, "Acquire Data from VISA", "Extract Data from Serial String", and "Output Data to Excel".  The output from the first VI could be an array of Strings that look like "XCount: 123   Depth: 456  YCount: 789", the output from the second could be a 2D array whose columns are the XCount, Depth, and YCount values, and the third sub-VI would take this 2D array and use the Report Generation Toolkit to write a true Excel file (.xlsx) with headers XCount, Depth, and YCount and containing the values from the 2D array.  Each of these tasks is relatively simple to do "stand-alone", and it will be much easier to maintain/modify your top-level design if you only have 3 sub-VIs (with maybe some "bookkeeping functions" like getting file names) to worry about.

 

On the other hand, if you need to acquire/parse/output a point at a time, this can still be done, but now you have to mix everything together.  Still, conceptualizing it as three sequential tasks (and maybe making three sub-VIs that do "one piece" of each task) might help you develop your algorithm.

 

Bob Schor

0 Kudos
Message 4 of 12
(3,757 Views)

Hi Bob schor,

 

Your answer gave me algorithm ..Its well structured and helpful but I am already using same approach.

You mentioned 3 steps:

  1. Acquire data from VISA
  2. Extract Data from serial string
  3. Output data to excel

 

I have succesfully implemented 1st step. Now I am encoutering problem with 2nd and 3rd step. I have tried few VIs But they aren't  working.

 

I have explained problem in my 1st post with images of sample data. You can refer it .Please suggest sum solution if possible.

0 Kudos
Message 5 of 12
(3,744 Views)
Your scan from during is obviously wrong since you only have a single output. You have it covered up so we don't know what you actually have but it's not close to what Gerd suggested. When you fix that, take the three values and wire them to a build array.
0 Kudos
Message 6 of 12
(3,740 Views)

Hello sir,

 

I dont know if i understood you properly. But i think you are unable to see which block I connected .

this is screenshot without error message.

scanFromString.png

0 Kudos
Message 7 of 12
(3,733 Views)

and yes I am removing BytesAtPort.. Smiley Very Happy

0 Kudos
Message 8 of 12
(3,731 Views)
You need to provide the correct format string. You aren't providing anything. Did you read what Gerd said? Did you read the help for Scan From String? You need the %f formatter after the = in the given string.
0 Kudos
Message 9 of 12
(3,713 Views)

I am reading each reply and trying out every solution provided.. But frankly Half of them are slipping over my mind. Any pictorial representation of what you are suggesting will be very helpful... Because reading "Help" and understanding every I/O needed for a block is not so helpful. And also I am not much experienced LabVIEW programmer to understand lot of things mentioned in Help. I have tried lot of things in past 24 hours and everything i jumbling now.

Smiley Sad  Smiley Sad  Smiley Sad  Smiley Sad

 

 

0 Kudos
Message 10 of 12
(3,704 Views)