bbosse

Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About bbosse

  • Rank
    Newbie
  1. Hi there! I'm using a Lua script to control the output of my LabJack T7 to set DAC0 to 5V and DAC1 to 5V using: MB.W(1002, 3, 5) -- this turns the LED light off by turning the DAC1 to 5V MB.W(1000, 3, 5) -- TURN DAC0 to 5 V which is used as a reference for the BuckPuck Reference channel This works just fine. Now what I want to do is to send a trigger from Kipling to DAQFactory to tell it to start recording data. What is the best way to send a trigger signal from Kipling (Lua script) to DAQFactory sequence script? The approach I'm attempting is to set FIO0 channel to 1 using: MB.W(2000, 0, 1) -- set FIO0 to 1 to trigger DAQFactory to run its save script -- do other stuff here MB.W(2000, 0, 0) -- set FIO0 to back to 0 to after the trigger happens but, it isn't working. When I read channel FIO0 in DAQFactory using: // Set scans/second. private scanRate = 2000 // Set scans/read. This is how many scans are retrieved per call to the stream read // function, and thus controls the iteration rate of the loop below. private scansPerRead = scanRate / 2000 // Start the stream with a scan list of AIN0, AIN1, etc. These are streamable Names from the LabJack Modbus Map, not DF Channel names. LJM_eStreamStart(identifier, {"AIN0", "AIN1", "AIN2", "AIN3", "AIN4", "AIN5", "AIN6", "AIN7", "FIO0"}, scanRate, scansPerRead, 1) dataIn = LJM_eStreamRead(identifier) FIOvalue = dataIn.data.FIO0 FIOvalue just stays 1. Even if I try to set it back to 0 in Lua with MB.W(2000, 0, 0) it just stays 1 when I read it in DAQFactory. Perhaps I'm not using the MB.W function properly? I have searched for the documentation for the mbWrite function to know what each of the 3 parameters are, but haven't found the documentation yet. Or perhaps there is a better way to communicate from Kipling Lua script to DAQFactory sequence to trigger events? Thank you! B
  2. Hmm, okay well it worked in the sense that I can adjust the number of decimal places saved (e.g. I tried format("%.1f", Channel0.Time)  and got 1 decimal place). But when I tried format("%.6f", Channel0.Time) I still only got 3 decimal places, which leads me to believe that the Channel0 is only generating 3 decimal places so there's nothing to show beyond 3. I looked into the Channel settings to see if I could specify the number of decimals, but didn't see anything. Is there a way I can specify that Channel0 saves up to 4 decimal places? Thank you!
  3. Now that I'm saving data directly to file, I'm trying to figure out how to save the time points with microsecond precision. I see from the manual the the data logging (which I was previously using) has the option to change the Sig Figs: " Time Sig Figs: Determines how many significant figures are used to write time values. A value of 9 yields timeprecise to the second, 12 to the millisecond and 15 to the microsecond. The maximum value is 15. " But now that I'm using the File.WriteDelim function to save my data, how do I specify that I want the time to be saved with 14 sig figs? Thank you!
  4. Cool. Thanks. I have switched to using the direct File writing. Code pasted below in case it helps someone else. Let me know what you think // Loop to read stream data and append it to the DF Channels. while(1) dataIn = LJM_eStreamRead(identifier) if (systime() <= timestamp + 10) // If the first 10 seconds of every 10 minutes, log the data - otherwise don't read the data data = insertTime(dataIn.data.AIN0, st, 1 / scanRate) Channel0.AddValue(data) // Needs to match channel defined in "Channels". data = insertTime(dataIn.data.AIN1, st, 1 / scanRate) Channel1.addValue(data) data = insertTime(dataIn.data.AIN2, st, 1 / scanRate) Channel2.addValue(data) data = insertTime(dataIn.data.AIN3, st, 1 / scanRate) Channel3.addValue(data) data = insertTime(dataIn.data.AIN4, st, 1 / scanRate) Channel4.addValue(data) data = insertTime(dataIn.data.AIN5, st, 1 / scanRate) Channel5.addValue(data) data = insertTime(dataIn.data.AIN6, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel6.addValue(data) data = insertTime(dataIn.data.AIN7, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel7.addValue(data) endif if (systime() > timestamp + 10 && notsavedyet == 1) // Open File and get handlePrivate Private.handle = File.Open("D:\ALT DAQFactory Saves\ALTfile_" + formatDateTime("%y%m%d_%H%M%S", systime()) + ".csv",0,1,1,1) // Put all the channel data into one array myArray[][0] = Channel0.Time myArray[][1] = floor(Channel0 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][2] = floor(Channel1 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][3] = floor(Channel2 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][4] = floor(Channel3 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][5] = floor(Channel4 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][6] = floor(Channel5 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][7] = floor(Channel6 * 1000 + 0.5) / 1000 // rounds to 3 decimals myArray[][8] = floor(Channel7 * 1000 + 0.5) / 1000 // rounds to 3 decimals // Write the array to the file File.WriteDelim(Private.handle, myArray, ",", chr(10)) // once saved, dont repeat until next read notsavedyet = 0 // close the file after it has been written File.Close(Private.handle) endif if (systime() >= timestamp + 600) // dont log data for next 10 minutes (600 seconds) timestamp = systime() // 10 minutes complete - reset timestamp to current system time saveCount += 1 // 10 minutes completed! - update saveCount notsavedyet = 1 endif st += scansPerRead / scanRate backlog = dataIn.ljmscanBacklog timeLeft = 600 - (systime() - timestamp) endwhile
  5. bbosse

    Custom Time Formatting for Milliseconds

    Thanks this worked
  6. Hello there! I'm trying to log data for 10 seconds every 10 minutes - each 10 seconds of data saved to its own separate file. So I have 2 problems with my script pasted below: 1) For some reason the file will have the first 6 or 7 seconds of data and not the entire 10 seconds 2) but even more annoying is that when the 10 minutes is up and it is supposed to switch to a new file, for some strange reason it records the first second or two in the previous file before finally making the switch to a new file. It's like it starts logging in the file from 10 minutes ago for a second or two before finally opening a new file to begin logging. I've tried troubleshooting this in a variety of ways but still have been unable to get 10 seconds of data to save in its own file every 10 minutes. Any help is appreciated, thank you. Logging.DataLog.FileName = "D:\ALT DAQFactory Saves\ALT_" + formatDateTime("%y%m%d_%H%M%S", systime()) + ".csv" beginlogging(DataLog) // Loop to read stream data and append it to the DF Channels. while(1) dataIn = LJM_eStreamRead(identifier) if (systime() <= timestamp + 10) // If the first 10 seconds of every 10 minutes, log the data - otherwise don't read the data data = insertTime(dataIn.data.AIN0, st, 1 / scanRate) Channel0.AddValue(data) // Needs to match channel defined in "Channels". data = insertTime(dataIn.data.AIN1, st, 1 / scanRate) Channel1.addValue(data) data = insertTime(dataIn.data.AIN2, st, 1 / scanRate) Channel2.addValue(data) data = insertTime(dataIn.data.AIN3, st, 1 / scanRate) Channel3.addValue(data) data = insertTime(dataIn.data.AIN4, st, 1 / scanRate) Channel4.addValue(data) data = insertTime(dataIn.data.AIN5, st, 1 / scanRate) Channel5.addValue(data) data = insertTime(dataIn.data.AIN6, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel6.addValue(data) data = insertTime(dataIn.data.AIN7, st, 1 / scanRate) data = data*55.45 - 17.78 // Convert channel voltage from mV to degrees C Channel7.addValue(data) endif if (systime() >= timestamp + 600) // dont log data for next 10 minutes (600 seconds) // From the DAQFactory Manual: "changing the file name while the logging or export set is running will close the current file and open the new file" // We change the filename for each new 10 minute interval of data Logging.DataLog.FileName = "D:\ALT DAQFactory Saves\ALT_" + formatDateTime("%y%m%d_%H%M%S", systime()) + ".csv" timestamp = systime() // 10 minutes complete - reset timestamp to current system time saveCount += 1 // 10 minutes completed! - update saveCount endif st += scansPerRead / scanRate backlog = dataIn.ljmscanBacklog timeLeft = 600 - (systime() - timestamp) endwhile
  7. I am using custom time formatting on my data logging and it works great! Here's what I've been using %m/%d/%y %H:%M:%S But if I also wanted to include the milliseconds what is the % for that? I checked the help, manual, and forum but didn't find anything. Thanks!