LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Putting a flat sequence on repeat without using a loop

Solved!
Go to solution

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!

0 Kudos
Message 1 of 11
(2,514 Views)

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



0 Kudos
Message 2 of 11
(2,508 Views)

How would you suggest performing a safe shutdown, I'm not sure what block to connect. 

 

Thanks for the advice about State Machines!

0 Kudos
Message 3 of 11
(2,478 Views)

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.

 

  • Do you really need to reconfigure both devices from scratch with every iteration of the timed loop?
  • If both should occur at the same time, why aren't they in the same frame? (and even same inner FOR loop)
  • You don't need the precision and overhead of a time loop to do something once every hour.
  • Your use of "stop timed structure" is incorrect. Check the help.
  • Yes, all you need is a simple state machine.
0 Kudos
Message 4 of 11
(2,471 Views)

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.

0 Kudos
Message 5 of 11
(2,456 Views)

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?

0 Kudos
Message 6 of 11
(2,447 Views)

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. 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 7 of 11
(2,435 Views)

Using the state machine I'm getting the error ERR (-50103) as when I used a while or for loop. I'm confused.

0 Kudos
Message 8 of 11
(2,426 Views)

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

  • What is generating the error?
  • What's the comment about loops?
  • Where did you get "the state machine"? (that's not an " out of the box thing", but a design pattern!)
  • Can you show us some code?
0 Kudos
Message 9 of 11
(2,420 Views)

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.

0 Kudos
Message 10 of 11
(2,407 Views)