05-04-2012 11:02 AM
NathanB thanks for the help in my post "Read and write to arduino..." I modified a bit your VI putting the reading indicator in a case stracture and controlling through the OK boolean switch. I then use the function Write to Measurement file to save my readings. What I' trying to do here is for every value I' m writing to servo I want to get the corresponding value from the photocell by pushing the OK buton. The thing is that the TDMS file registers values continuously and not only the value for the specific servo's angle. Is it too much to ask you to take a look at this?
Solved! Go to Solution.
05-04-2012 11:19 AM
It will be continous as the way you wired it. Beacause as you press OK to true it will start writing the value continously and must have write much values before you press OK to false. You have not taken into the account 'servo angle'. You have to build logic to write file considering both servo angle and photocell output.
Now tell me, you want like excel file of servo angle vs photocell output.
Attach your vi. So that I can modify it for you.
05-04-2012 12:40 PM
Thanks for your time man. I'm attaching the VI. And yes what I actually want is to have servo angle vs photocell output in an excel file. I would appreciate it very much If you could show me how to have an X-Y graph (X beeing the servo angles 0 - 180 and Y the photocell values) in the front panel.
I tried to apload the vi but something is not working with the attach file service. So I aploaded in a safe web page here:
http://physics.teiath.gr/vi.html
Thanks again
05-04-2012 02:06 PM
Here is your modified vi. By default, your file is getting stored at C drive with name "data" in csv format. You can open it with excel directly.
This program will sense change in value of servo angle control as you manually input it, then will store servo angle and its corresponding photocell value to file. Along with plot them on chart.
Check out your results. As of now I don't have any arduino board.
Hope this helps !!
05-05-2012 09:40 AM
Thanks a lot man. I slightly modified your vi (instead of connecting the iterations # to event structure and to light intensity indicator, I connected the photocell read to them). Now I' m getting both values i.e servo angles and the values from the sensor in the data.csv file. The problem is that both values appear on the same column and not in separate colums as you can see from the image below. Any ideas? Thank you
05-05-2012 10:08 AM
In write to spreadsheet.vi, I have connected string constant with value ','
Try removing that value (just simple blank string).
05-05-2012 10:51 AM
I removed the value (just simple blank string) and I ' m getting something like this.
05-05-2012 11:56 AM
I got it (Put back comma). As the file is .csv i.e comma separated value.
Actually what happening is you are dealing with large values like 40,000 they are already having comma in it so while writing to file data.csv the vi confuses while seprating it.
Remove that. And your problem will be solved.
05-08-2012 03:04 AM
I would not recommend using a comma for the delimiter nor is it wise to use an empty string. You should be fine using the default (TAB aka \t).
The file does not need to have the .csv extension. When trying to get the data into Excel, you should "Import Data" into the spreadsheet. There will be a dialog to tell Excel how to interpret the file appropriately and it will show a preview of how it is going to do it with the current settings. Since comma will not work for your case, you should be able to select "tab" as the delimiter in the import data dialog (assuming you use the default delimiter on the Write To Spreadsheet File VI).
Also realize that the function to clear the file is not guaranteed to execute before the loop occurs. It might execute before, during or after the loop. You need to make execute first. You should use a sequence structure to force the clear file function to execute before the loop does.