01-04-2017 05:35 AM - edited 01-04-2017 05:36 AM
Hi,
I am trying to get data from a csv file into string arrays.
The csv file includes columns tag, module and channel, where a number of tags (item names) correspond to a module number (1-5) and channel count (0-31) (for indexing).
e.g. See simplified table below:
Each module requires its own array, which will contain the tag names.
For now I have just tried to create one array for the first module. This is where I am up to so far..
When I try the above VI the array plots the last tag name of module 1 32 times.
I tried using shift registers, but I can't quite figure out how to use it to keep the value of each row and to plot it in the array.
How can I plot the tag name of each row into an array? From there I would replicate the code inside the case structure with the condition equal to module 2 etc.. I know this is probably not a very efficient way of doing it so if anyone has any tips - it would be very helpful.
Thanks.
Lisa
01-04-2017 05:43 AM - edited 01-04-2017 05:44 AM
Can you provide the sample CSV file so that i can update you the solution
Also your requirement in points (1., 2. etc..)
01-04-2017 05:47 AM
Hi Lisa,
When I try the above VI the array plots the last tag name of module 1 32 times.
You have it programmed this way! There's a FOR loop iterating 32 times and in each iteration you index the very same string…
I tried using shift registers, but I can't quite figure out how to use it to keep the value of each row and to plot it in the array.
Then you need to learn this very basic LabVIEW element!
When you need help for your VI you should attach the VI instead of some JPGs…
01-04-2017 06:05 AM
Hi there,
attached is the vi and csv file.
The requirements are as follows:
01-04-2017 06:25 AM - edited 01-04-2017 06:35 AM
Attached is the revised version, see previous comment for csv file.
Changes made to VI:
This now works and it plots all 32 tags of module 1. This code will require repetition of code for modules 2-5. Is there a better way of doing this?
01-04-2017 07:09 AM - edited 01-04-2017 07:09 AM
I would do something like this.
Use an array of clusters for your modules. Each cluster element should have a name (for the module), an array of tags, and an array of channels. I used a seperate array to make it easier to keep track of the names. So if the module has been defined already, you just add the tags and channels to that cluster's arrays. If the module has not been found yet, create a module cluster and add it to the array of modules.
Also note that I set the module names to be all caps and trimmed the white space to avoid stupid capitalization and space issues.
01-04-2017 08:56 AM
Thanks very much for your help and suggestions, I really appreciate your time. I need to clarify some things with my manager to check the required formatting, but hopefully it is suitable. Thanks for your time!
01-05-2017 07:27 AM
There's a single function (in LabVIEW 2016 -- I don't currently have access to earlier versions, but think it's been around for a while) called SpreadSheet String to Array (found on the String Palette). Tell it the separator is a comma, configure the rest of it, and stand back while it does all the work within a 32x32 pixel area of your Block Diagram!
Bob Schor
01-05-2017 10:25 AM
Thanks for your comment Bob,
I am familiar with the spreadsheet string to array function. However, the csv is already in array form when it is read in. Is there a way to import the csv in string format?
Lisa
01-05-2017 11:24 AM