Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx AI Volts in a loop

Labview 2012/Windows7

Can you loop on daqmxread using a state machine??  I need to continuously read a DAQ channel while looping for x seconds.  In the state1 of the statemachine I setup:

DAQmxAI_VOLT_IN then DAQmxsample clock then daqmx start task then daqmx read.  In state2 I do something and also daqmx read an analogin channel from my daq.  I've passed the task I created in state1 via a shift register.  In state 3 I again read the same daq channel.  I also loop on this state for 15 secs. while reading the daqmx channel.  Is this.."legal"??  Can you loop on a state while reading the daq channelonly passing the task via shift register????

0 Kudos
Message 1 of 5
(3,795 Views)

What I'm trying to do is constantly acquire data with my DAQ Card will stepping thru a state machine.   Is that best done in the SM or in two parallel loops??  One acquiring data the othe running the SM??

The purpose of this is to ensure while I'm doing something in the statemachine ( closing relays etc)  I'm NOT getting a voltage ( >1 volt) on my DAQ Channel 1.

 

Thanks..

0 Kudos
Message 2 of 5
(3,787 Views)

Hello,

 

In regards to your first post, yes it is possible to acquire data within a state machine while using shift registers.  I'm having a bit of trouble understanding what your program is doing as a whole, but I've linked to an example which might be helpful for you to get started.  Note that in the example, the DAQmx Create Channel functions are outside the state machine, but they could be moved into their own state as well.  You could also have more than one read state if you need.

 

https://decibel.ni.com/content/docs/DOC-10862

 

Could you share a few more details about your project as a whole?  Are you using one task or multiple tasks?  How is everything connected?  It's hard to say whether a state machine or two parallel while loops would be a better fit without knowing exactly what you'd like to do.

 

Thanks,

 

Myriam

Applications Engineer

National Instruments

0 Kudos
Message 3 of 5
(3,754 Views)

Hi Myriam,

My requirement is to "do something" ( open relays, check proxy sw's etc) while monitoring a channel on my daq (PXI6230) to make sure it doesn't go above a certain level.  I thought a statemachine (SM)  would be good for the do something part of it and a parallel process of monitoring the daq for the voltage.  At the end of the statemachine I could analyze the DAQ data to make sure it was less than my reqmnt.  I didn't know how to create the parallel processes.  I also use the daq in my statemachine to create DIO and other analog out/measurement signals.  I tried creating the analog channel then the timing in the "START" of my SM then READ when I wanted to collect data later on.  Two problems I found here.  1) if I did a read in one SM then a read in another, I didn't collect any data the 2nd time for some reason.  I did pass the TASK and error code via a shift reg.  2) if my voltage happened while transitioning from one SM to another I would miss it.  Any pointers would help.  i wil look at the link you sent..Thanks

0 Kudos
Message 4 of 5
(3,740 Views)

Hi,

 

I think the example I posted earlier should answer a lot of your questions.  When you're making your state machine, make sure that you are creating a separate task for each channel you're reading or writing to, and not passing the same task between states.  It might also be best to start, read, and stop each task inside each state as well, but note that these will all happen sequentially.  If you're trying to monitor each channel you're accessing in the state machine, one way to pass the information through to a parallel loop is by using a queue.  Take a look at producer-consumer architecture at the link below for more information about implementing parallel loops.

 

http://www.ni.com/white-paper/3023/en/

 

Feel free to let me know if you have any questions about that example I posted earlier as well.

 

Thanks,

 

Myriam

Applications Engineer

National Instruments

0 Kudos
Message 5 of 5
(3,709 Views)