LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues logging data - does not save the correct data

I am having 2 issues:

 

1. I am having issues with my logging occuring at the right time.

 

I have a few things occuring based on the state of 'Injection'. In the case of logging, the following needs to happen:

When injection is 'True' nothing should occur. When injection goes 'False', data logging should occur. If my injections are 'continuous' the boolean goes:

True, False, True, False. I would have 2 logging sessions during both 'False' occurrences. What appears to be happening is that the logging occurs during the 'True' state. I am not sure why. 

 

2. The logging needs to save a certain amount of samples to the text file. If my 'False' state lasts for 1 second, I need to have 1000 samples. If 2seconds, 2000 seconds, if 1.5seconds, 1500 samples..you get the idea. At current I am only getting 100 samples at a time, at dt of .1

 

Code below:

 

full-code.PNG

0 Kudos
Message 1 of 20
(3,997 Views)

It seems that my shift register and logic does the correct item.

 

It is initialized as FALSE. Injection goes TRUE, the output of the logic of the shift registers on the left is still FALSE. When the Injection goes FALSE, the output of the shift registers is TRUE (not false & True = True) and so the logging should occur, however it seems to have recorded at the wrong time, perhaps of how the data acquired is buffered? This is where I am lost..thanks!

0 Kudos
Message 2 of 20
(3,987 Views)

I am guessing it is because the DAQmx Read occured during the time when it was *not* logging, so it simply records whatever is available at the time the case goes TRUE? How do I go about getting it to acquire during the time it goes TRUE?

 

I had it working prior, but the issue became that I need to do all of the following (some of which is not in my code yet):

 

-Read Voltage on AI0/Record Voltage on AI0 (the logging I am trying to achieve as described)

-Read voltage on AI1 (and simply display it, continuously, for observation)

-Read current on AI2 (still need to implement; and simply display it, continuously, for observation)

 

The other things my program does is:

-Set voltage on AO0

-Set current on AO1. (still need to implement)

0 Kudos
Message 3 of 20
(3,984 Views)

I can't speak about your timing issues- it is difficult to tell from a picture (insert a snippet!) where we can't see the data that is setting up the timing for the channel.

 

As to logging..... why is this missing from your block diagram?Smiley Surprised

Capture1.PNG

Use your boolean to enable/disable logging or just log all data encluding the boolean and post process it by timestamp to ignore the "injection" times


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 20
(3,979 Views)

Customer requests .txt file logging, not TDMS.

The output needs to be a simple 2 column file with time in the first column and data in the second.

 

Setup for both channels. Example 'Delay(s)' is: 1. In this case, I should be logging 1000 data points.

Capture.PNG

0 Kudos
Message 5 of 20
(3,976 Views)
You have specified continuous acquisition and not specified number of samples for your read. You specified to read number of samples available. You are logging exactly how many samples the read returns.

Your code is very confusing and I would hesitate to deliver that to a paying customer.
Message 6 of 20
(3,966 Views)

Thanks Dennis.

 

i seem to have issues w my UI updating when I specifiy samples to read. It appears to lag, which is OK, as long as the timing is still correct..

 

Can I acquire continuously, without specifing how many samples, but specify how many samples to read?

0 Kudos
Message 7 of 20
(3,954 Views)

@belopsky wrote:

Thanks Dennis.

 

i seem to have issues w my UI updating when I specifiy samples to read. It appears to lag, which is OK, as long as the timing is still correct..

 

Can I acquire continuously, without specifing how many samples, but specify how many samples to read?


DAQmx Read will return the number of samples requested immediatly if they are available otherwise it will wait for the number of samples requested to be avilable and return the number of samples requested.  This of course, means that the loop will only iterate no faster than "number of samples * Sample rate". (probably what you mistook for "Lag")  IF the number of samples requested is not available before the timeout period DAQmx Read will return with the number of samples available and a timeout in the error cluster so your calling code can handle the exception intelegently.  If the number of samples requested is -1 DAQmx Read returns the number of samples available now without waiting at all.

 

Clear?


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 20
(3,949 Views)

Thanks, yes, that seems to make sense, I suppose my question is:

 

What must I do to ensure that the samples I need to log are available when logging occurs? It is pretty time sensitive that this be right..

I need to record as soon as the injection goes FALSE and stop as soon as it goes TRUE..

0 Kudos
Message 9 of 20
(3,936 Views)

I suppose the issue is that I cannot have my while loop lag, as it then slows down my relay control and some voltage events (i have voltage that drops and ramps depending on the relay).

 

I am working off some old Labview code that used TraditionalDAQ. The setup is in a stacked sequence structure where the 'AI Start' and 'AI Config' are in the first frame, and the 'AI Read' is in the main acquisition loop.

 

See below for old code:

 

Capture.PNG

0 Kudos
Message 10 of 20
(3,926 Views)