LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with intermittent sampling and writing to file(s)

I am describing the functionality that I am trying to achieve via the attached VI.

  • The VI opens with a sequence structure. In the first sequence step analog output voltages for 2 AO channels are set
  • The next sequence step consists of analog data acquisition
    • Custom linear scales for 3 input channels are specified, to convert input ‘volts’ to respective physical quantity being measured
      • The input voltage signal is with +/- 10V but the physical quantity (forces) are greater than 10N
  • The headers for the data files are created as strings
  • The acquisition is set for finite sample acquisition
  • The VI is set for periodic acquisition, wherein the data is acquired for specific time period given by ‘Sampling on’ and then ignored for time period specified by ‘Interval off’.
  • The VI is set to write instantaneous data to multiple files. Each time the While loop is executed the instantaneous data, number of samples read (sampling rate x Sampling on time),  is written to a ‘.dat’ file.
  • Statistical operations on data collected for each While loop execution is performed. These values (average & st. dev) are then written to another file ‘*.sum’ with respective headers
  • The headers for the ‘*.sum’ file are written only for the first execution of the While loop
  • The VI is designed to run for a specific duration after which the execution of  While loop is stopped
  • Certain safety features are incorporated to terminate the execution of the While loop if the ratio of measured quantities exceeds a preset limit.
  • In the last sequence the analog outputs are set to zero

 

 

I am having following problems with the execution of the VI:

  • The VI does not write instantaneous data to data files (*.dat)
  • The VI writes the averaged data for *.sum file for only the first execution of the While loop.
  • It also truncates the values to around 10.5 written in *.sum file. While implies that the custom scale is not working as intended.

 

I would really appreciate if you would tell me how to fix these bugs with the VI. I would really appreciate your help.

Have a happy holiday season.

Thanks,

Dinesh

 

 

                                                                                                                                               

0 Kudos
Message 1 of 3
(2,301 Views)

Dinesh,

 

I gave up on trying to figure out your VI.  The diagram takes mutiple screens.  Wires run all over the place including behind nodes where you cannot tell whether they are connected.  You have duplicated code, code which does nothing (outputs not connected), code constructs which are probably eligible for the Rube Goldberg page, and others.

 

Your sequence structure could be eliminated by simply wiring error cluster wires in a few places.  A state machine architecture would be better.

 

You repeatedly open and close the .dat file.  This might contribute to your problem.

 

You do not check the errors from the .dat file VIs.  They might help you figure out what is going on.

 

You did not save any data with the VI, so we cannot see what is happening with your averaging.

 

Lynn

0 Kudos
Message 2 of 3
(2,293 Views)

Lynn, he may actually not be to blame for the diagram size. It does not change if you "clean" it, which leads me to believe that this is what he did. But a very entertaining diagram it is. A true case study 🙂

Now, the strange thing is that stuff like this remains in it:

 

ScreenHunter_001.jpg

 

As Lynn said, the reason why the file is updated only once is that there must be an error after the first acquisition completes. The only way to figure out which one it is (in order to avoid or correct it) is to debug your code in situ (using a probe on the error wires). It might be because you try to restart your acquisition within the loop (you probably should stop it first if you really want to restart it anyhow). I would put the start out of the while loop and try this way. The error might occur elsewhere though or for another reason...

 

Since you recreate your dat file at each iteration, the second giving you nothing because of an (unknown) error, will essentially erase your first successful iteration.

 

I don't understand the truncation statement.

 

 

 

0 Kudos
Message 3 of 3
(2,284 Views)