03-28-2015 07:27 AM
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.
03-28-2015 08:32 AM
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!
03-28-2015 09:14 AM
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.
03-28-2015 03:09 PM
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
03-28-2015 04:45 PM
Hi Bob schor,
Your answer gave me algorithm ..Its well structured and helpful but I am already using same approach.
You mentioned 3 steps:
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.
03-28-2015 04:52 PM
03-28-2015 05:06 PM
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.
03-28-2015 05:07 PM
and yes I am removing BytesAtPort..
03-28-2015 05:21 PM
03-28-2015 05:45 PM
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.