08-07-2013 05:12 AM
Im using LV2012 and using a PXI6230 DAQ. If I have say 4 state machines is there a way to start acquiring data on an analog ch in state machine one, keep acquiring data thru state 2 and 3 then analyze it in state machine 4? Sorry for the crude dwg but I don't have LV on my machine at my desk.
So in SM 1 I setup the daq...AI parameters...ch number, max/min amp, etc, then timing parameters and finally I start the READ vi. ( forgot READ.vi in my dwg) I pass the task either thru a local variable or shift register from SM1 to SM2 to SM3. Finally in SM4 I use IS TASK DONE.vi then STOP.vi and finally CLEAR.vi and do my analysis. Is this correct? Not sure this will work and if the read.vi is in the correctSM. How do I ensure it is reading data the whole time and then how to I get to it??
Thanks..
08-07-2013 07:13 AM
You want to use DAQmx Start Task (has a green play arrow on the icon). That will make DAQmx run the specified task and let you do whatever else you need to. If it is a continuosly sampling task, be sure to read the buffer occaisonally and you will need to use the DAQmx Stop Task to stop it.
08-07-2013 08:10 AM
@crossrulz wrote:
You want to use DAQmx Start Task (has a green play arrow on the icon).
Using DAQmx Start Task.vi is always optional, If you do not use this VI, a measurement task starts automatically when the DAQmx Read VI runs.
@Clint_Eastwood1000 wrote:
I pass the task either thru a local variable or shift register from SM1 to SM2 to SM3. Finally in SM4 I use IS TASK DONE.vi then STOP.vi and finally CLEAR.vi and do my analysis. Is this correct? Not sure this will work and if the read.vi is in the correctSM. How do I ensure it is reading data the whole time and then how to I get to it??
Thanks..
Using shift register or LV2G is suggested for passing the TASK Reference to different subsequent states. Regarding, to be ensure that your VI is reading data, you should test the STATE MACHINE's functionality (specially the transition code in each state) and don't forget to include ERROR HANDLING.
08-07-2013 10:18 AM
So from the replies:
In State machine 1 I use DAQmx AO.vi, the daqmx timing vi( set to continuously sample and some sample rate) then the DAQmx start. I do my "stuff" in the other state machines passing the error cluster and the task using a shift register. Then in the SM I want to do the analysis I do a DAQmx read then the DAQmx Stop. Will the buffer fill up from the time I start (SM1) until the time I read ?? Its about 15-20 seconds. I need to analyze all that data because I want to make sure an event hasn't happened from SM1 to SM4.
Thanks..
08-19-2013 06:38 AM
Would you mind having a look?? I want to make sure I'm collecting data thru out the state machine.
Thanks !
08-19-2013 07:44 AM
You don't need the DAQmx Read in the start case. But you really should be reading the data somewhere inside of your state machine. Is that supposed to be in the end case? Since we are using continuous sampling, the task will never complete. So the Wait Until Task Complete makes no sense. I think that's where you want to put your read and then stop the task.
Other notes:
You don't need to have a shift register for the stop conditional. The loop will stop as soon as you get a TRUE, so there's no need to store it.
There is a Waveform Mean that you can use instead of making your own average routine.
08-19-2013 11:13 AM
Thank-you for your comments!!
08-22-2013 10:16 AM
OK, I did what you suggested moving my read to the end state machine and taking out the wait till task is done..put in stop. Now my AI.vi doesn't create a task. If I put a probe on it its blank or something like <FB2> or <1013> and the task doesn't run. I don't have LV on this machine but in my 1st or 2nd state machine I set up my AI...as in previous attachment. then in my next SM i loop a couple of times until a condition is met. If I loop less than 8 secs my SM works. 9 sec or more it doesn't. At 1st I thought that the DAQmx was timing out so I made it like 120 sec but it still fails if I loop on a later SM more than 8 sec. !!!
When is a task created??? At run time?? It would appear so. The loop is AFTER my AI daqmx is run. So how would a SM run later in the code affect the daqmx run 1st?? In other words my loop timing is run in say SM 4 or 5 and my AI daqmx task is run in SM 1 yet chging the time later in the seq affects my daqmx created earlier..
Thanks..
08-24-2013 03:02 PM
Hi Clint_Eastwood,
Could you post your most recent revision to your code so I can get a better understanding of what you are doing? And then I can see if I can recreate your buffering issue.
08-24-2013 05:22 PM
@Clint_Eastwood1000 wrote:
OK, I did what you suggested moving my read to the end state machine and taking out the wait till task is done..put in stop. Now my AI.vi doesn't create a task. If I put a probe on it its blank or something like <FB2> or <1013> and the task doesn't run. I don't have LV on this machine but in my 1st or 2nd state machine I set up my AI...as in previous attachment. then in my next SM i loop a couple of times until a condition is met. If I loop less than 8 secs my SM works. 9 sec or more it doesn't. At 1st I thought that the DAQmx was timing out so I made it like 120 sec but it still fails if I loop on a later SM more than 8 sec. !!!
When is a task created??? At run time?? It would appear so. The loop is AFTER my AI daqmx is run. So how would a SM run later in the code affect the daqmx run 1st?? In other words my loop timing is run in say SM 4 or 5 and my AI daqmx task is run in SM 1 yet chging the time later in the seq affects my daqmx created earlier..
Thanks..
It sounds like the DAQ buffer gets full, either read it and build a result array in the VI (e.g. once every second), or increase the buffer enough to store all 20 secs before retrieving the data.
/Y