Hi Nick F.,
Sorry I did not explain my problem clear.
I setup a "current" scale in MAX, then I have a "current" task in my VI, which actually is a voltage task.
For the digital edge trigger, I wire the output of a relay as triggering signal to PFI0. When I set falling edge as triggering edge, the close action of the relay will start the DAQ. It seems in this way I can get my VI working now.
My problem is that some of my welding equipments dose NOT have a relay output can do digital edge trigger, so that I have to trigger the DAQ by "current", it is actually a voltage trigger. When I use reference analog window trigger, the counter task starts too early (or too late) so that the data acquired is almost zero.
After my last post, I spent more time in my lab, I found that if I use start analog window trigger, the VI acquired displacement data at the right moment as expected.
Back to my question: Is there anyway to use reference analog window trigger in my application?
I think I have a couple suggestions that will help you adjust your timing so that you can get the data you want.
1. When you run the DAQmx Start Task VI for the counter it will begin incrementing from its default value. However, until your analog input task is running, none of the values from the encoder will be read since you're using the analog input sample clock as the counter sample clock as well. This brings me to my second point:
2. The behavior of your analog input task is fundamentally different when you configure a start trigger and an analog window trigger. Since I'm not sure which you actually want, I'll describe the behavior of both.
a. Start trigger: When you use a start trigger, calling a DAQmx Start Task VI puts the task into the state of waiting for the start trigger--at this point the sample clock is not running because the task hasn't been started.
b. Analog Window Trigger: This is a reference trigger and determines which values to save. When using this type of trigger the DAQmx Start Task start the sample clock and the task is continually acquiring samples. With this type of trigger the task uses a circular buffer with a size equal to the number of samples to acquire. Then, when it receives this trigger is saves the pre-trigger samples and acquires enough post-trigger samples to fill the buffer. The difference here is that the counter is continually buffering samples until the task is stopped.
Depending on what you're trying to do there may be a better way to implement triggering. In particular it would be helpful to know the following if the above descriptions aren't clear:
1. Do you want synchronized samples (same rate and start) from the analog input and counter input?
2. Do you want the same number of samples from both?
3. Relative to your external trigger when do you want these samples? All post-trigger? Some pre-trigger?
4. Also, you mentioned that you do not have a digital start trigger--what type of signal is your trigger? Square wave, sine wave, other? What is the amplitude of the pulse/signal?
With this information it will be easier to provide advice. I hope this helps, and have a great day!
Thank you for your input. My answers to your questions:
3. If you mean external trigger is digital start trigger, these samples I want are all post-trigger, since I can set my equipment to send out the trigger signal before analog signal comes. For analog trigger, I want some pre-trigger samples, doing so I will not miss any portion of analog signal.
4. For digital start trigger, it is the close contact of a relay sent to the PFI0. For the analog trigger, it is a voltage signal, the shape of the waveform is showed in the attachment of the first post, I am attaching it again in this post, I named it as "Current" in the screenshot. The amplitude of the voltage signal ranges from 0.5 to 2.0 Volts.
Again, I really very appreciate your help.
It sounds like you want to acquire pre-start-trigger samples. From what you've said it sounds like you have an analog input signal and encoder that you only want to sample when the analog input it is reading the voltages you see on the screen shots you've provided. Essentially you want to implement a reference trigger on both measurements. Is this correct?
If this is the case, I would recommend just doing a continuous acquisition and cropping your data in software. In order to crop your data you can use the Trigger and Gate VI to implement a software reference trigger after you read all the data in. To do this just start both tasks together and read continuously.
If you weren't also acquiring samples from your encoder I would recommend using an analog reference trigger to acquire the correct points utilizing the pre-trigger samples feature. The issue with using this method in your case is that the sample clock is running during the entire acquisition so you would end up with continuous samples from the encoder and only the pre and post-trigger samples specified on the analog input and no way to know when they occurred relative to each other.