LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sate machines and DAQ

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..

0 Kudos
Message 1 of 11
(4,088 Views)

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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 11
(4,066 Views)

@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.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 11
(4,049 Views)

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..

0 Kudos
Message 4 of 11
(4,033 Views)

Would you mind having a look??  I want to make sure I'm collecting data thru out the state machine.

 

Thanks !

0 Kudos
Message 5 of 11
(3,975 Views)

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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 11
(3,962 Views)

Thank-you for your comments!!

0 Kudos
Message 7 of 11
(3,947 Views)

 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..

 

0 Kudos
Message 8 of 11
(3,898 Views)

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.

Peter T
Applications Engineer
National Instruments
0 Kudos
Message 9 of 11
(3,868 Views)

@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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 11
(3,862 Views)