mawright89 Posted May 10, 2013 Share Posted May 10, 2013 I am using callibration equations to set the zero-offset and span of the input for 8 pressure transducers and need to create a simple way to callibrate the channels for a party who isn't a DaqFactory user. I esentially need two variables per equation (16 in all) which are saved in a callibration text file as .csv formatt and are called and defined at the first stage of the startup script. My issue is that I'm not sure the easiest way to go about this and secondly what would be the script to assign the variable to the value in the .csv file ascociated with it. Cheers Link to comment Share on other sites More sharing options...
SteveMyres Posted May 10, 2013 Share Posted May 10, 2013 Have a look at the File.ReadDelim() and File.WriteDelim() functions. They're good for reading CSV or other character-delimited text files into DAQ Factory arrays vice-versa. Link to comment Share on other sites More sharing options...
AzeoTech Posted May 10, 2013 Share Posted May 10, 2013 Thanks Steve, that was my suggestion exactly. Just got interrupted before finishing the reply: The easiest way to do this is to create a 2D array to hold the values. In startup, you'll want to initialize the variable first: global scaling scaling[0][0] = 1 scaling[0][1] = 0 scaling[1][0] = 1 scaling[1][1] = 0 // etc. The first [0] corresponds to the transducer and goes from 0 to 7. The second is always [0] or [1], where [0] is the slope, and [1] the intercept. There are faster ways to initialize, but this way allows you to specify different default parameters for each transducer. After you set the defaults you can try to load the settings from a file: try private handle = file.open("c:\daqfactory\params.csv", 1, 0, 0, 1) scaling = file.readDelim(handle, -1, ",", chr(10), 0) file.close(handle) catch() ? strLastError endcatch If the load fails, it will just revert to the defaults. To save, it looks very similar: try private handle = file.open("c:\daqfactory\params.csv", 0,1, 0, 1) file.readDelim(handle, scaling, ",", chr(10)) file.close(handle) catch() ? strLastError endcatch Though in this case you probably want something else in the catch() to tell the operator when it failed. Note that I'm doing this script off the cuff, so it might need tweaking to work. Link to comment Share on other sites More sharing options...
mawright89 Posted June 7, 2013 Author Share Posted June 7, 2013 Thankyou so much for the input and apologies for the late reply, have been off sick for the last month. that looks great and have used arays instead of seperate variables. one thing tho, should the save function be: file.writeDelim(handle, scaling, ",", chr(10)) as aposed to: file.readDelim(handle, scaling, ",", chr(10)) Link to comment Share on other sites More sharing options...
mawright89 Posted June 7, 2013 Author Share Posted June 7, 2013 Got it working with the WriteDelim... superb thankyou so much for the help. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 7, 2013 Share Posted June 7, 2013 Yes, sorry. Sometimes I work too fast... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.