10-31-2011 04:04 PM
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.
11-01-2011 08:46 AM
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.
11-01-2011 05:04 PM
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
11-02-2011 11:27 PM
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..
11-03-2011 08:15 AM
Multiple issues, but nothing really unexpected:
Keep at it. You are making good progress and seem to be learning fast.
11-06-2011 09:08 PM
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
11-07-2011 03:15 AM
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
11-07-2011 09:51 AM
Further observations on your current code:
Keep at it. You are close.
11-09-2011 12:06 AM
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
11-09-2011 08:35 AM
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
The tasks would be
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!