LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finite data storage, retrieval and display within a while loop

Hi Jack, 

 

From the VIs you provided, it looks like you are using software timing for your analog output task. Everyime your output loop iterates, it will write to your device. The rate at which you write at can be affected by your operating system. To improve accuracy, you might want to try using a hardware clock. Which device are you using? 

 

More information about DAQmx timing and sample rates can be found here. Let me know if you have any further questions. 

Julianne K
Systems Engineer, Embedded Systems
Certified LabVIEW Architect, Certified LabVIEW Embedded Systems Developer
National Instruments
0 Kudos
Message 11 of 44
(796 Views)

In your stimulus subVI, the DAQmx Generate VI needs to be set to single waveform.  You have it set to single array of doubles.  The difference is that waveforms include the timing information.

 

Also, you may want to put a 10ms delay in your stimulus loop until you get it converted to a queue driven state machine.  Otherwise it will hog all the CPU time when not actually generating.  You may also want to use shift registers to save the DAQ reference in that loop so you don't have to recreate them every time you run it.  This will be part of converting to a state machine.

 

Let us know if this helps.  Sorry for the delay.  Your post got lost in my e-mail over the weekend.

0 Kudos
Message 12 of 44
(809 Views)

Hi Julianne,

 

Thanks for the reply... I an using a USB 6218 BNC device.

 

I have no experience with hardward timing... I assume this means using counters??

 

Regards,

Jack

0 Kudos
Message 13 of 44
(777 Views)

Hi all,

 

I am trying to implement your feedback in my vi... But having some difficulties with setting hardware timing for AO (Stim2(SubVI).vi) and displaying the queued data (TMS5.vi)... Attached my are files with a couple of specific difficulties identified...

 

Again, any feedback or suggestions would be greatly appreciated..

 

Thanks heaps for past feedback... I am learning a lot... This is an important project to me as the data sampled MUST be accurately synched and displayed in real time, with minimal data loss..

 

Download All
0 Kudos
Message 14 of 44
(774 Views)

Multiple issues, but nothing really unexpected:

 

  1. There is a mismatch between the type of data you set your queue up with in the initialization (scalar DBL) and the type of data you are feeding it (DBL waveform - WDT).  This problem is probably due to the use of the dynamic data type (DDT), which can convert itself to either scalars, waveforms, or arrays of waveforms.  I would strongly recommend you convert the DDT to a single WDT using the from DDT express VI right after the call to DAQ assistant.  And change the data type of the queue to a WDT. You can find a WDT constant in the Waveform»Analog Waveform palette.
  2. Right after the call to the DAQ Assistant, you split the data into two DDTs.  However, you only really have one set of data - a WDT.  This is probably the root or your issue with the filter.
  3. I am unsure what you are trying to do with checking to see if the DDT is >1.
  4. Display issue is probably due to the WDT/DDT confusion.
  5. As mentioned in my previous post, your configuration of the DAQ acquisition VI is stripping the timing information.  Change the input format to Waveform (your currently have it set to 1D DBL).
    WaveformSelection.png
  6. On a more practical note, not all of us have huge monitors.  Could you reduce the size of your front panel so it fits on a smaller display?  If I didn't know the keyboard shortcuts to navigate LabVIEW, it would cause me serious problems.

Keep at it.  You are making good progress and seem to be learning fast.

0 Kudos
Message 15 of 44
(770 Views)

Hi DFGray,

 

Thanks for the suggestions... Some worked while others did not... But your suggestions did point me in the right direction and after searching the forum for other postings I think I have managed to work most of the problems.. Thanks for the pointers as to where to look.

 

All in all, this project is moving forward nicely... I am trying to remove all polling and use event structures for all input... However, I am having trouble using an event structure to control the action of the stop button across the multiple loops? basically, the vi freezes and I need to be use the abort button... Action is set to "Switch until released" ( which was need for the stop local variables).

 

Attached are my revised vis... The AO timing was still incorrect after making the your suggested change... However, it worked using the DAQ assistant, so I just used that... The only problem is that because I cannot use a AO channel control in the DAQ assistant I made two subvis (one for each AO channel)... A minor issue given that the AO channels will not change , but it irritates me and I would like to know how to do this... 

 

Regards,

Jack

Download All
0 Kudos
Message 16 of 44
(756 Views)

Either you register the Stop button even in several vi's or use a User Event to send a Stop command of your preferrence.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 17 of 44
(743 Views)

Further observations on your current code:

 

  1. You should be able to remove the delays in all the loops.  The data acquisition will gate the top loop, the next two will be gated by the queues from the data acquisition, and the final loop is gated by the event structure.
  2. I told you the wrong thing about the timing.  You need to use the DAQmx Timing.vi to set the timing of your outputs.  Here is a screenshot.
    DAQmxTiming.png 
  3. You need to make sure your Stop value is set to false before anything starts running or your top three loops will exit immediately and your bottom loop will not.
  4. Your hang is probably due to not destroying your queues when you exit the top loop.  Do a Release Queue and set force destroy to TRUE on both your queues after the top loop (use the error outputs).  Note that this will enable you to remove the stop local variable from the middle two loops, since it will create an error (queue destroyed) on the outputs of the queues that are waiting.

Keep at it.  You are close.

0 Kudos
Message 18 of 44
(735 Views)

Thank you!!

 

AO timing and freq and pulse controls are now working correctly... I also implemented your suggestions for the stop control... Also now working well.

 

Next hurdle....

 

Along with the continuous data display, I also need to display data from a finite number of samples (i.e. 3000) which is triggered when AI2 is =>1 (loop 3)... AI2 is the trigger out signal of the stim device that is driven using my AOs (so the voltage signal is not a round number; hence the use of >1 to "round" coerce the data is "0" or no trig or "1" for trig.

 

The triggered data needs to include the data 200 (50ms) before the trigger and 2800 (700ms) samples after AI2=>1... Also, the trigger out signal from the stim provides a 1ms pulse, so because the data sample rate is 4kHz, there is a train of four "1" values for each AO pulse that is generated from the AO.... I need to the triggered data to be relative to the first "1" value only.

 

I have tried numerpous boolean comparison operators, relays and alsorts of other thing, but the trigger and gate will not open and get the data.

 

Any suggestions?

 

Regards,

Jack

0 Kudos
Message 19 of 44
(716 Views)

To recap, you need 3000 points, 200 pretrigger, 2800 posttrigger, trigger is edge trigger and only on first pulse.

 

You can put this code in either your acquisition loop or another loop fed by a queue from the acquisition loop.  The extra loop may work better, since this problem is easy to handle using a state machine / task handler combination.

 

The states of the state machine would be

  • Waiting for trigger
  • Collecting data
  • Finished

The tasks would be

  • Reset (go to Waiting for trigger)
  • Add data
  • Exit

Implement this by creating a nested case structure.  One case structure is the states, one the tasks (putting the tasks as the outside loop allows you fewer cases, since Exit always simply exits).  I would drive the tasks with a queue whose data is the command clustered with the data.  In the Reset case, the data would be empty.  When you start AO, send a Reset.  At each data acquisition, send an Add data.

 

The data to be displayed would be a ring buffer of 3000 points, probably implemented as a shift register.  On reset, the ring buffer pointer (also in a shift register, could be the same one if data is clustered) is moved to zero.  When data is recieved, it is written into the buffer, wrapping as needed as it overflows the end.  Check for trigger with the Basic Level Trigger Detection.vi.  When a trigger is detected, the current buffer pointer location is noted and the state machine transitions to collecting data.  As data is recieved, it is written into the buffer until 2800 more points are collected.  At that point, the buffer is rotated (using Rotate 1D Array) so the first point is first, the data displayed, and the state machine transitions to Finished.  Input data is now ignored until the Reset command starts the process again.  The Exit command exists so you can exit the loop when the Stop button is hit (need to send the Exit command at that point).

 

Good luck!

0 Kudos
Message 20 of 44
(709 Views)