06-11-2019 09:45 AM
I'm very new to LabVIEW so I might have taken a completely wrong approach. I'm trying to acquire measurements from two different devices at approximately the same time every hour. It does that but it currently has to run continuously and I can't use any kind of loop because it creates an error from the DAQmx. However, I'm trying merge this code with something else that doesn't have to run continuously. Any advice?
Thanks!
Solved! Go to Solution.
06-11-2019 09:53 AM - edited 06-11-2019 09:54 AM
Take a look at State Machines. They are architectures, allowing for transition between different states, e.g. "Initialization", "Test running" or "Idle", "Shutdown" and so forth. The transition logic between this states can be based on user command, timing or on signal levels as well.
If something does not have to run continiously, but only once, then it can be inserted in the "initializatation" state/routine. Your logic can be configured, that it is the first state executed, and that if no errors occur then the next state should be "Test running" for example, where your thermocouple and conductivity action takes place.
Also keep in mind, that connecting blocks with the "error" wire, you can read/capture errors and perform a safe shutdown routine, instead of crashing Labview.
Br
06-11-2019 10:59 AM
How would you suggest performing a safe shutdown, I'm not sure what block to connect.
Thanks for the advice about State Machines!
06-11-2019 11:11 AM
Yes, you seem to have a lot of misconceptions about graphical programming and dataflow. Have a look at the shipping examples and design templates for some ideas.
06-11-2019 12:14 PM
As altenbach suggested you don't need to reconfigure the devices after every loop. Configure them once (in the initialization state), pass the task to the other states (use a shift register), and use a timer in a "waiting" state to trigger the capture on both devices simultaneously. Have a shutdown state that closes the DAQ tasks.
You really need to read up on data acquisition. You don't even need the inner loops - just take the number of samples that you want.
06-11-2019 12:48 PM
I attached the wrong one at first.
Also would the state machine make it possible to acquire data for a long period of time i.e longer than a week?
06-11-2019 01:10 PM
Yes, state machines are used in many data logging apps, some of which run for years. One thing that becomes critical for long time frames is that you store your data to disk at every collection cycle or at some slightly longer time interval so that you don't lose it if the PC crashes or you lose power.
06-11-2019 01:55 PM
Using the state machine I'm getting the error ERR (-50103) as when I used a while or for loop. I'm confused.
06-11-2019 02:02 PM - edited 06-12-2019 01:37 AM
@anotherabby wrote:
Using the state machine I'm getting the error ERR (-50103) as when I used a while or for loop. I'm confused.
This statement makes no sense.
06-11-2019 02:41 PM
There is not way to acquire data continuously because any buffer has limit. Take a look into "Voltage -Continuous Input.vi" example in Help -> Find Examples -> NI Example Finder dialog, then Hardware Input and Output -> DAQmx -> Analog Input. In this example, data are read by 100 samples (by default) into plot.
In your case data are saved into file. I would suggest to organize a file per minute, hour or day which depends of sample rate.
Usage of Flat sequence, Delays, etc. look strange. It would be better to explain what you want to reach.