LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ trigger for labview

Hi,

I do not know how to exactly use the TTL trigger and DAQ to program my data acquisition. Mainly I am reading voltage using DAQ.

     Please see the attachment detailing my problem. The first is about what I want to do and the second is how can I generate TTL signal for my motor (I know how to do this part).

regards,
 

Message Edited by Dushyant on 08-06-2007 08:04 PM

Download All
0 Kudos
Message 1 of 12
(5,261 Views)
Hi Dushyant,

I went ahead and drew a diagram based upon your description.  If there is anything incorrect please let me know.  During the time that the motor is operating between positions A and B, you are generating TTL pulses.  Do you have the ability to control that no pulses occur before A, and that they do not occur after position B has been reached?  If this is the case, I believe that you will want to use your TTL signal as the sample clock and not as a trigger.  By defining your acquisition to use an external sample clock of approximately 1kHz (1/1ms), the acquisition of points will not occur until the first pulse is received and will stop acquiring when no additional pulses are received.  What DAQ device will you be using in your application?



Regards,
Andrew W
National Instruments

Message Edited by TheWoost on 08-07-2007 01:08 PM

0 Kudos
Message 2 of 12
(5,243 Views)
Hi Andrew,

Thanks for responding.

The card I am using is : PCI-MIO-16E-4 for data acquisition and PCI-GPIB for controlling my motor.

Yes, the diagram that you drew is exactly what I want to do. But, scales are different a bit.

The precision (resolution) of my motor is 0.1 um.

If my motor is running with 1 mm/ sec, then it would take 0.1 m sec to cover that much distance. So, the regular pulses in your figure should be 0.1 m sec apart; other than that your diagram is exactly what I want.

As I already mentioned, I can program my motor to generat TTL pulse when it crosses certain point (A in your picture) and then I want my motor to send TTL pulses every delta t = 0.1 msec or 0.2 msec.

You suggested me to "use your TTL signal as the sample clock" and this is exactly what I want. Can you please elaborate on that?

If you have some exaple code, then that would be great too.

I really appreciate your help.
regards,
DK
0 Kudos
Message 3 of 12
(5,233 Views)
By using your TTL signal as the sample clock, you are configuring the PCI-MIO-16E-4 to acquire a single voltage sample on each rising edge of the TTL signal.  There are a number of shipping examples included with the NI-DAQmx driver that demonstrate analog acquisition using an external sample clock.  I have attached a modified version of the shipping example "Cont Acq&Graph Voltage-Ext Clk.vi".  In my example, you can specify a wait time that the VI will wait for a sample clock to be present (the default value is 5000ms).  What will happen is when you start the VI, it will wait no longer than this specified wait time for a sample clock to appear.  In addition, the VI will end execution 5000ms after your sample clock has ended.  There's a number of different ways you could go about implementing this, but this is what I came up with.  Let me know if you have any other questions.

Regards,
Andrew
0 Kudos
Message 4 of 12
(5,223 Views)
Thanks Andrew,

However, yesterday I figured out that TTL signal generating was not supported on my motor controller from Newport.com:  ESP -300 and it was supported on ESP -6000. It was only mentioned at the end of Newport's manual n so, I missed it first time. Now, I have to adopt to slow data acquisition and  I have to do it using software and of course, there may be some latency in program execution; but, I want to minimize that. i.e. I want to avoid using for loop or while loop.

I am using DAQ card PCI-MIO-16E-4.

The main code is "Fly_scan_St_Line_different_version.vi" and the other important subcode is "Motion_Update_Final"

The main code seems working almost fine. I am including all the subvis and I want someone to help me on the frame no 1 (of 0,1,2) of stacked sequence.

The subvi "motion and update.vi" asks my stepper motor to move and keeps updating position. Since I want my main code to start taking reading exactly when the motor is at "Intial Pos(micron)" and I am asking each millisecond whether it has reached at "Intial Pos(micron)". If it has then, I ask my "DAQ Assistant" to return me N-data paoint at regular interval of delta t time. I tried using "N-samples" and sepcifying the sample rate in "DAQ Assistant". But, it was not effective. The photo-diode reading was getting completed much before it should be. I also tried time loop, but again photo-diode was finsihing up early.

So,  Questions:

(i) can I avoid using for or while loop with something more efficient that decreases chance of latency during my code execution?

(ii) Pos_Step (micron)/velocity (mm/sec) = (delta t ) directly gives me the  time to wait between successive photo-diode reading. The velocity can be anything between 0 to 2 mm/sec. How small can we make delta t ?

Regards,
DK



Message Edited by Dushyant on 08-10-2007 01:57 PM

Message Edited by Dushyant on 08-10-2007 01:59 PM

Message Edited by Dushyant on 08-10-2007 04:23 PM

0 Kudos
Message 5 of 12
(5,205 Views)
Hi Dushyant,

You are essentially wanting to merge software and hardware timing together, and given the requirements of your application I don't think you can achieve the precision you want with a finite (N sample) acquisition.  Ideally, your motor controller would produce a digital pulse when the motor reaches position A, and then you could trigger your analog acquisition with this digital pulse.  However, it appears as though you are obtaining a device status via GPIB, and then with this status you are determining whether or not to start the acquisition.

If possible I think your best bet would be to obtain a timestamp when your motor crosses points A and B, while during the whole program execution performing a continuous acquisition with your DAQ card (such as that I reference in my earlier post), and then go back at a later time and throw away the data before the timestamp for position A and after the timestamp for position B.  From a programming standpoint, the part of your code pictured below actually becomes an infinite loop if the original value passed into it is "False", so you will want to modify this portion of the code.  In addition, please be very careful with using local variables in your code as you may run into situations where you read from the variable when it has not yet been updated.  Given the level of control you need from this application, using too many local variables can make debugging a nightmare.



As far as modification of your motor controller code, perhaps contacting Newport or posting the GPIB forums would be more suitable.  My overall recommendation would be to have parallel while loops running, one of which is handling the motor controller code and the other that is performing the data acquisition.

Regards,
Andrew


Message Edited by TheWoost on 08-10-2007 04:18 PM

0 Kudos
Message 6 of 12
(5,186 Views)
Hi,

I just updated my previous post. Please see that. I do not need any modification in subvi and it's working fine.

Only, I want to replace for loop with something efficient and I want to minimize the time between successive readings of photo diode which would minimize my "Pos_Step (micron)". I believe  that if I can get rid of "for loop" and can use "N-samples" with DAQ assistant, then I can go with delta t much lesser than 1 msec. However, if I try to remove for loop with "N-samples" with DAQ assistant with "samples to read" paramter equal to "N of for loop" and frequence = 1/ (delta t), the  DAQ finishes much earler than it should have.

I need help rgarding this.
0 Kudos
Message 7 of 12
(5,180 Views)
Hi Andrew,

You are talking about obtaining a timestamp when your motor crosses points A and B. Would this be done with hard-ware and TTL signal? If so, my motor controller can not do that. If you mean that I can do that using GPIB card or DAQ card, I would be interested to know how.

If I uses for loop, I can not go faster than delta t (= time between successive reading ) 1 msec. I believe if I can use "N-sample" feature of DAQ, then I can use clock on my DAQ card and it can go upto 500 KHz  and time = 1/500 msec. That's why I want to use this feature. But, even with proper value of sample to read and  sample rate in DAQ, the DAQ finish faster than when it should have.

regards,
Dushyant
0 Kudos
Message 8 of 12
(5,176 Views)
I think it would help to discuss the difference in performing a finite (N sample, hardware timed) acquisition and a continuous (hardware-timed) acquisition.  In a finite acquisition you are defining a specific number of samples that you would like to acquire at a given sample rate.  The PCI-MIO-16E-4 is capable of sampling up to 500kHz (dt = 2us) when sampling from only one channel.  In a finite acquisition you do not use a while loop because the call to the DAQmx Read.vi is only made once and will return all of the samples once they have been acquired.

In a continuous acquisition you are specifiying the sample rate that you would like to acquire at, and this is again up to 500kHz when using only one channel.  The reason why a for loop is necessary is because on each iteration of the for loop the call to the DAQmx Read.vi will retrieve a portion of samples from the buffer of the DAQ device while the buffer is being filled.

Regards,
Andrew
0 Kudos
Message 9 of 12
(5,175 Views)
Hi,

Yes, I want to acquire using "N sample, hardware timed" and I believe that the hardware would be DAQ card, right?

you wrote:
dt = 2us

while I have been using
dt =  1/ (Rate)

What do you mean by "2us"?
regards,
DK
0 Kudos
Message 10 of 12
(5,166 Views)