02-12-2023 09:02 AM
Hello everyone,
I'm a beginner in LabView.
Recently, I want to output an analog sine wave signal (amplitude : 4V, Frequency : 350Hz )
and create three pulse output signals to control my camera and double pulse laser,
so I wrote two function by DAQ Assistant VI.
one for signal generation, another one for Laser/Camera control.
but if I connect the usb-6341 to the oscilloscope, I can't make the signals lock at same phase.
I have no idea how to solve this problem. please help me!
this is my VI.
For example, I want to make the sine wave signal always lock at baseline which I draw.
02-12-2023 09:28 AM
This isn't the kind of thing you can expect to do with the DAQ Assistant. You're going to need to spend a little time learning the core DAQmx driver API.
Most likely you'll end up needing to sync via hardware signals where one of your pulse generation tasks drives the timing for the other pulse task and the analog output task. You might possibly need a 3rd counter task that drives timing for all the other signals. More detail about the kind of timing relationships you need to establish will help make that more clear.
-Kevin P
02-19-2023 08:29 AM
Hello Kevin,
Is this mean that I need an additional NI C Series device to output sample clock and start trigger to my usb-6341 and drive my both programs?
Or is there any device that can achieve my goal directly and easily?
Thank you so much for your reply!
02-19-2023 09:36 AM
It depends on what kind of pulses you are trying to generate. Are the three pulses the same? Or do they have the same frequency but different offsets? Or they must be individually configurable? What is the frequency of the pulse? What are the update rate of the pulse and analog output?
If they must be individually configurable, you might need 3 counters.
If they have some similarity (eg frequency), you can use the digital tasks using only one counter.
02-19-2023 04:31 PM
It's pretty likely the USB-6341 already has all the capability you need. it isn't yet clear *exactly* what kind of timing relationships you need, but the device has 4 individually programmable counters as well as AI, AO, DI, DO. That gives you an awful lot of options.
-Kevin P
02-22-2023 03:23 AM
In my experiment, I need to record the air flow field of the speaker outlet, so the setup is equipped with double pulse laser, camera and a loudspeaker module.
I will need to control interval time (delay time) between two lasers to cooperate with the exposure time of the camera to obtain the image. This part may require 3 Counter outputs.
It also requires 1 Analog output to generate 5V, 350Hz sine wave to drive the loudspeaker module.
The important thing is that I need to be able to synchronize the signals of the 3 Counter outputs and 1 Analog output so that the images we take can be phase-locked. Every frame need to be maintained at the same phase of the sine wave.
I already calibrated my LabView Code, but I'm not sure that I already arrived my goal or not. Please help me.
If I miss anything, please let me know! thank you so much.
02-22-2023 05:22 AM
Going by the screenshot -- I'm on LV2020 and can't open the code itself.
Overall things look pretty good, but I have a few comments and suggested changes.
1. Your 0 initial delay isn't actually possible. DAQmx will silently coerce that to be the smallest allowable pulse interval time of 2 timebase cycles (20 nanosec on your device). So you may need to bump the other ones by this amount to keep their relative timing.
2. You may also find that down at the nanosecond level, there are also signal propagation effects that will give you some uncertainty and error in this relative timing when you look carefully on a scope. Just so you know.
3. Most of my NI counter knowledge was learned "in the trenches" many years ago. Go back far enough and one could not create a single counter task with multiple channels of output. Go back a little less and you could configure them that way on *some* devices, but they would not start truly simultaneously. I simply don't know if that's changed in the meantime.
Fortunately, you've set up triggering which *can* start them in sync. But there's another change you'll need to assure that.
4. Start your multi-counter task *before* starting your AO task. That ensures that they're all armed and ready when the AO start trigger is asserted.
5. Since your AO task allows regeneration, there's no need to keep writing to the task inside the loop. Just write an integer # of full sine wave cycles to the task before you start it. Given your sample rate of 10 kHz and your desired sine wave frequency of 350 Hz, I'm fairly doubtful your Express VI is doing that.
I'd recommend an integer much greater than 1. The driver will be repeatedly delivering chunks of the data you wrote down to the board, and continually wrapping around and repeating the process. Making the buffer bigger allows the driver to deliver bigger chunks at a time, helping shield you against PC and OS timing uncertainties that may starve the driver of CPU temporarily. Offhand, I'd probably go big and write a full second worth of data to the task. That's likely overkill, but in the big scheme of things it's not much memory to sacrifice for the sake of much greater robustness.
There can also be an option to regenerate using *only* the device's onboard buffer. If you were to go this route, 1 full sine wave would be enough to write and the hardware would take over from there.
6. Once you eliminate the need to keep writing to the AO task inside the loop, all you're doing is waiting for a user-requested stop or a task error. You don't need 2 loops with 2 separate stop buttons, put 2 "task done" queries into 1 common loop with just 1 stop button.
7. There's no need to spin the query loop so fast with a 0 msec wait. I would typically go with 100-200 msec. (And in fact, I found sometime in the past that "task done" queries themselves can be surprisingly slow to execute, to the tune of 15+ msec. Dunno how universal that finding is.)
8. Don't stay blind to errors. At the end of your task chains, send the final error outs to a front panel indicator or an error dialog (or both).
-Kevin P