Olaf Posted May 9, 2019 Share Posted May 9, 2019 Hello! I am more or less new to DAQFactory (have done some simple data acquisition, but nothing complex yet). After reading through many threads in this forum as well as spending some time with the user's guide, I still couldn't figure out how to do the following: I want to read two channels from a Labjack UE9 with a frequency of 1000 Hz, so I think I should use the stream mode. So far, so good - acquiring the data at 1000 Hz works fine. Now I would like to copy the values from one of these channels to one of two new channels (for this, I have created two V channels called "T_Pre" and "T_Post"), but only if the signal from the other UE9 channel is between two specific values (variables set by scrollbars). This must work during the ongoing stream acquisition. Only the values from the V channels have to be stored; the stream data can be discarded afterwards. Here's what I came up with (and what does not work): //initialization using ("device.labjack") include ("C:\Program Files (x86)\LabJack\Drivers\LabJackUD.h") //setup stream, set scan rate AddRequest(0, LJ_ioPUT_CONFIG, LJ_chSTREAM_SCAN_FREQUENCY, Var.scanrt, 0, 0) var.streamtext="running..." //clear channel history UE9_12.ClearHistory() UE9_11.ClearHistory(1) //setup channels to stream AddRequest(0, LJ_ioCLEAR_STREAM_CHANNELS, 0, 0, 0, 0) AddRequest(0, LJ_ioADD_STREAM_CHANNEL, 12, 0, 0, 0) AddRequest(0, LJ_ioADD_STREAM_CHANNEL, 11, 0, 0, 0) //start the stream GoOne(0) var.streaming=1 //set variable "scanrate" to actual scanrate global scanrate = 0 eGet (0, LJ_ioSTART_STREAM, 0, @scanrate, 0) while(var.stop==0) //write data to VChannels, if input UE9_11 is between certain values if (UE9_11>var.kw1min) if (UE9_11<var.kw1max) T_Pre=UE9_12 endif endif if (UE9_11>var.kw2min) if (UE9_11<var.kw2max) T_Post=UE9_12 endif endif endwhile ePut(0, LJ_ioSTOP_STREAM, 0, 0, 0) var.streaming=0 var.stop=0 The sequence is started by a button. Another Button changes "var.stop" to 1 if pressed, which stops the sequence as intended. The problem is probably somewhere in the "while" loop. I'm quite sure that I made a simple beginner's mistake, so it would be very kind if anyone could point me in the right direction. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.