01-04-2012 03:16 PM
Hello,
I have a simple task that I need some assistance with. To be brief, I am reading the angular values of 3 encoders and I am writing these values to a spreadsheet file at the press of a trigger. Everytime I press the trigger, the corresponding 3 angular values are written to the spreadsheet file. I press the trigger again, the next 3 angular values are appended to the same spreadsheet file, and so on.
My problem is, the values are being written all under one column in the following manner:
encoder1 (value1)
encoder2 (value1)
encoder3 (value1)
encoder1 (value2)
encoder2 (value2)
encoder3 (value2)
encoder1 (value3)
encoder2 (value3)
encoder3 (value3)
.....and so on.....
I would like to have these values written in a way that the values of each encoder are written to the corresponding column for that encoder (ie. 1 column per encoder) in the following manner:
encoder1 (value1) encoder2 (value1) encoder3 (value1)
encoder1 (value2) encoder2 (value2) encoder3 (value2)
encoder1 (value3) encoder2 (value3) encoder3 (value3)
......and so on.....
That is, I would like to have all the values of encoder1 written under the first column, values of encoder2 written under the second column and the values of encoder3 written under the third column.
I attached the part of my VI related to my task. Any help would be greatly appreciated.
Thank you,
r15
01-04-2012 03:47 PM
R15,
I would use the express VI write to measurement file. To get the same output just tell it not to put headers and empty the time column. This can be found in the under programming--->file I/O--->write to measurement file.
I've used that a couple of times for things like this for great results.
-Franklin
01-04-2012 05:18 PM
Thank for your response CTSFranklin.
I tried using the Write to Measurement File VI like you advised but I still cannot get each encoder to display its corresponding values on one seperate column, Instead the values for the 3 encoders are still under the same one column.
My aim is to have the values for each seperate encoder under a seperate column.
Thank you,
r15
01-04-2012 06:58 PM
Your VI works okay for me. Other than I had to had a True to the Transpose Array to the Spreadsheet file.
Since I don't have a DAQ device installed, I had to delete your DAQmx counter functions (which were broken anyway because of missing inputs.)
How are you running your VI? Right now it is only set up to run once than quit, and you have to hit the Trigger boolean before running the VI.
(Please don't tell me you are using the Run Continuously button.)
01-05-2012 12:25 AM
Instead, I tried building the array by selecting 'Concatanate inputs' and wired it to the 1D array input and not to the 2D array input. I assumed each counter output has only one array element.
I got the attached file
01-05-2012 04:29 AM
I may have been misunderstood since I only posted a snippet of my code. So please find attached my complete working VI.
I will be running a while loop and writing the data to a spreadsheet in that while loop everytime I press the trigger. In the end of my program, I will have multiple values for the encoders and not just one value for each encoder. Hence, in my spreadsheet I aim to have 3 columns (1 for each encoder) and a variable number of rows (between 10 to 20). So I want my spreadsheet to be a 2D array with 3 columns and n rows. (where 10<n<20).
I hope this makes it clearer as to what I am trying to accomplish and I apologize for not being clear earlier.
The problem I have is that all the values are being written to one column.
Thank you,
r15
01-05-2012 05:15 AM
Please ignore the above VI.
This is the correct VI that I have attached in this post.
01-06-2012 04:01 AM
Hi
As mentioned by 'Ravens Fan', you can try setting 'Transpose?' input to 'True' on the 'Write to Spreadsheet' vi. Else use an explicit 'Transpose Array' before you write to the file.
Either of them should solve your problem. If you still face a problem, please also post the text file generated by this vi.