Marcus_tribscan Posted December 16, 2010 Share Posted December 16, 2010 Hello, I know this topic has been covered to some extent by other posts, but I can't seem to figure out how to implement it in my example. Here's the thing: I'm logging three virtual channels (we can call them A, B and C) using an export set called "my_export" that is triggered by a button and a quick sequence with the code: beginExport(my_export) if I look at the csv file created by the export in excel everything looks the way it should, but.... I'm more or less un-interested in the date and hour/minute time component via the default TheTime, it can still be there and doesn't cause any problems but... I would like to have a time component column in my exported .csv file with the number of seconds ranging from 0 to whatever the history lenght of my channels are with a time spacing equal to whatever the sampling rate is. If my sampling rate is 0.01 seconds and no averaging is being made the exported .csv file should look something like this (values for A,B and C are just example values and have nothing to do with my question): Time A B C 0.00 0 0 0 0.01 0.1 0.2 0.1 0.02 0.2 0.1 0.3 0.03 - - 1.21 0.5 0.67 0.82 - - and so on.... with the time component ranging from 0 to the history length of my channels, let's say 50 seconds, so the last two values would be 49.99 0.7 0.98 1.21 50.00 1.1 2.0 3.1 Whenever I press the export button the added time column in my .csv file should always start at 0.00 seconds I would highly appreciate some help with this! Marcus Link to comment Share on other sites More sharing options...
AzeoTech Posted December 17, 2010 Share Posted December 17, 2010 You'll need to set a variable equal to the time of the data points in your first row, and then have a column that is the data point time - that start time. So, if you are exporting V.myChan, it might be something like this in your button: global startTime = getTime(v.myChan[numrows(v.myChan-1)]) beginexport(myexport) and then have a column in the export set that is: getTime(v.myChan) - startTime Link to comment Share on other sites More sharing options...
Marcus_tribscan Posted December 17, 2010 Author Share Posted December 17, 2010 Hmm, doing that creates a totally empty dT column (I call the new column dT) when opening it in excel... Also, I seem have problems writing to the file more than once after adding the dT column. My export button is a quick sequence where I put the code you suggested: ____ global startTime = getTime(v.V_vertical_force[numrows(v.V_vertical_force-1)]) beginExport(FB_results) // this export works fine and overwrites the old file when not tampering with the added dT ____ (one of my two V-channels is called V_vertical_force and my export set is called "FB_results" - this is also the name of my .csv file: FB_results.csv, the file is set to excel time with 12 significant numbers and to overwrite) I placed this code in the new "dT" row in my export set: ____ getTime(v.V_vertical_force) - startTime ____ Any idea what I'm doing wrong? Marcus Link to comment Share on other sites More sharing options...
AzeoTech Posted December 17, 2010 Share Posted December 17, 2010 I can't say, but here's a sample document with it working (at least with real channels). exportSample.ctl Link to comment Share on other sites More sharing options...
Marcus_tribscan Posted December 17, 2010 Author Share Posted December 17, 2010 Well, after looking at your file and doing the same "magic" on my v_vertical_force channel (and not the copied virtual v.v_vertical_force channel) does produce the dT data in my .csv file so it seems like the problem is resolved now...! Thanks for your help, I really appreciate it! (and I appreciate the v. channels too even if they don't seem to work in this case since they really help me in other aspects!) Marcus Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.