IntelSen Posted October 16, 2014 Share Posted October 16, 2014 I am working on a demo program that will have two analog inputs (AIN0 & AIN1) on a T7 my initial objective would be to stream in the data. The current program is graphing the individual channels on one page and averaging (boxcar) the two channels on another page, thus far everything works well. I will soon need to stream the data in and I cannot find any examples for data streaming for the T7? Please excuse me if I missed the T7 stream example. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 16, 2014 Share Posted October 16, 2014 The T7 is an evolving product (though very quickly reaching maturity) and so the examples are limited. Streaming is also a little more crude than streaming on the UD devices (U3, UE9, etc). In the UD streaming, data is automatically streamed into channels. In the LJM (T7) version, you have to script reading the streaming data and putting it into channels. This also means you can get the data and do something else with it if you want. I expect we'll add streaming direct to channels at some point soon. In the meantime, I've attached a sample. The StartStream sequence is where all the work is. Line 3 actually starts the streaming, then the rest of the sequence takes care of continuously reading the stream data and putting it into our AIN0 channel (which could be named something else of course). StopStream simply stops the startStream sequence and sends the command to the T7 to stop streaming. Link to comment Share on other sites More sharing options...
Ian Posted October 17, 2014 Share Posted October 17, 2014 I'm so new here I don't see where to download samples. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 17, 2014 Share Posted October 17, 2014 No, its me. I always forget that in this forum after selecting the file, you have to click "Attach this file" to actually upload it to the post. Hopefully its attached to this post instead... ljmStreamTest.ctl Link to comment Share on other sites More sharing options...
IntelSen Posted October 17, 2014 Author Share Posted October 17, 2014 Downloaded the sample program I added two buttons one to start stream and one to stop stream. When I click on the start stream I get "C1000 Channel or function not found: startStream Line 13 - Uncaught error in sequence startStream". Also I attempted to add a variable value component to display the channel value, for the expression I tried to use the expression ain0, seems as though there is an error trying to use this as an expression? Link to comment Share on other sites More sharing options...
AzeoTech Posted October 17, 2014 Share Posted October 17, 2014 There's nothing wrong with the expression, you just don't have data in your AIN0 channel yet because of the error in the startStream sequence. As to the error, I am unsure. The script works perfectly for me. Can you post your version of the script? Link to comment Share on other sites More sharing options...
IntelSen Posted October 17, 2014 Author Share Posted October 17, 2014 private scansPerRead = 500private scanRate = 10000device.labjackM.LJM_eStreamStart("ANY", "AIN0", scanRate, scansPerRead, 1)private dataInprivate dataprivate st = systime()private sglobal backlogglobal dtprivate s = 0while(1) dataIn = device.labjackM.LJM_eStreamRead("ANY") data = insertTime(dataIn.data.AIN0, st, 1 / scanRate) st += scansPerRead / scanRate ain0.AddValue(data) backlog = dataIn.ljmscanBacklog// delay(0.1)// ? "" + data.deviceScanBacklog + " : " + data.LJMScanBacklog + " : " + data.data.ain0endwhile Link to comment Share on other sites More sharing options...
AzeoTech Posted October 19, 2014 Share Posted October 19, 2014 Update: worked directly with IntelSen. The issue was old firmware and kipling on the T7. Lesson of the day: if hardware doesn't work the way you think it should, especially LabJack hardware (because they are constantly adding new cool stuff), make sure you have the latest firmware and drivers from the manufacturer. Link to comment Share on other sites More sharing options...
Ian Posted October 21, 2014 Share Posted October 21, 2014 Running the sample unchanged I get: C1000 Channel or function not found: startStream Line 13 - Uncaught error in sequence startStream This line fails: data = insertTime(dataIn.data.AIN0, st, 1 / scanRate) if I change: dataIn.data.AIN0 to something else like AIN0 or some number then it runs, but its useless data of coarse. This also fails: backlog = dataIn.ljmscanBacklog so I just // comment it out to run. What do I need to check and or fix to make "dataIn.data" function? Thanks Link to comment Share on other sites More sharing options...
Ian Posted October 21, 2014 Share Posted October 21, 2014 I forgot to mention I'm running firmware version 1.0126 Link to comment Share on other sites More sharing options...
AzeoTech Posted October 22, 2014 Share Posted October 22, 2014 Streaming a T7 requires DAQFactory 5.91 which will be released this week, probably later today. Link to comment Share on other sites More sharing options...
IntelSen Posted October 23, 2014 Author Share Posted October 23, 2014 In DAQFactory is there somewhere that tells you what the parameters are for various LJM functions? For example, this is how LJM_eStreamStart(int Handle, int ScansPerRead, const int *aScanList, double * ScanRate) is defined by labjack, the signature of the function appears to be completely different in DAQFactory or at least the signature in your streaming example is different. I can't find any documentation in DAQFactory that describes your LJM interface. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 23, 2014 Share Posted October 23, 2014 Stream support is added in 5.91, which has not be officially released (though will be in the next day or two). You received a prerelease version that did not have the documentation complete. Once the release is available, you will find the proper documentation on the parameters in the help. Link to comment Share on other sites More sharing options...
IntelSen Posted October 28, 2014 Author Share Posted October 28, 2014 Installed version 5.91 went through help content including searching various stream types I could not find one reference to the stream command or it's parameters? Please excuse if I am not looking in the correct area. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 29, 2014 Share Posted October 29, 2014 It is in section 17.8 of the user's guide. Link to comment Share on other sites More sharing options...
IntelSen Posted November 5, 2014 Author Share Posted November 5, 2014 When I start the streaming script I get the yellow triangle on the bottom of the screen. I am receiving a C1000 error message, I looked up the error code which states: "The name provided was not found:1) Check your spelling, check for typos.2) If you are not specifying the connection, make sure the default connection is correct." I have checked my spelling for the device name and it appears to be correct. I am using the sample script provided in the latest release of the user guide. I do not see a reference to specifying the connection? Could you please assist with item 2 as it relates to the example script in user guide. I have attached a copy of my ctl program and a copy of the startStream script. streamStart Script.txt Rexam Stream New Script.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted November 5, 2014 Share Posted November 5, 2014 Ok, first, watch your indentation. You should indent all block structures, meaning indent after while(), if(), for(), switch(), try(), etc. and then outdent when you get to the end of the block. This is programming 101. Next, I don't know what you are doing in StreamRate. The 3rd line is not DAQFactory script, but rather part C++ header code, and part DAQFactory script. I don't see where you actually run this sequence, but I thought I'd mention it. Finally, your application runs fine for me. The exception is that I get a "STREAM_IS_ACTIVE" error once I start the streaming. This is because the Average channel has a Timing of 1. You probably want that to be 0. At 1, that means it reads that analog input every second, but once you start streaming, you can't read analog inputs on the LabJack because they are busy streaming. As to the error you saw, I'd need at least a line number to examine. Link to comment Share on other sites More sharing options...
IntelSen Posted November 5, 2014 Author Share Posted November 5, 2014 Ok, good input, here is what I found the problem actually resides in the StreamRate sequence. The objective of the StreamRate sequence is to read the data rate from the T7. Here is the entire StreamRate sequence: "while(1)global scanrate = 0LJ_ERROR _stdcall eGet("ANY",LJ_ioSTART_STREAM,0,@scanrate,0)endwhile" Link to comment Share on other sites More sharing options...
AzeoTech Posted November 10, 2014 Share Posted November 10, 2014 eGet isn't implemented in the LJM. In the DAQFactory form of LJM_eStreamStart, the actual scanrate is returned. So, all you need to do is change this line: device.labjackM.LJM_eStreamStart("ANY", {"AIN0", "AIN1"}, scanRate, scansPerRead, 1) in your StartStream sequence to: global actualScanRate = device.labjackM.LJM_eStreamStart("ANY", {"AIN0", "AIN1"}, scanRate, scansPerRead, 1) Then you can access the variable actualScanRate from anywhere. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.