LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

writing values to measurement file

Solved!
Go to solution

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?

read_write-to-arduino.png

0 Kudos
Message 1 of 9
(6,011 Views)

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.

0 Kudos
Message 2 of 9
(3,881 Views)

  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

0 Kudos
Message 3 of 9
(3,881 Views)
Solution
Accepted by topic author TomPap

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 !!

0 Kudos
Message 4 of 9
(3,881 Views)

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

csv_image.png

0 Kudos
Message 5 of 9
(3,881 Views)

In write to spreadsheet.vi, I have connected string constant with value ','

Try removing that value (just simple blank string).

0 Kudos
Message 6 of 9
(3,881 Views)

I removed the value (just simple blank string) and I ' m getting something like this.

csv_image.png

0 Kudos
Message 7 of 9
(3,881 Views)

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.

0 Kudos
Message 8 of 9
(3,881 Views)

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.

0 Kudos
Message 9 of 9
(3,881 Views)