LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

issue with Analog Signal Generation Synchronization and Digital Acquisition

Hello,

I am currently facing an issue with synchronizing the generation of an analog signal and digital data acquisition. I am using an NI PCI 6251 acquisition card. My goal is to generate an analog signal from pin AO1 while simultaneously acquiring 4 signals from the digital pins on the card.

I am aware that I can synchronize these tasks using a trigger. However, as a beginner, I am unsure about how to achieve this through software rather than hardware. Most of the tutorials I have come across demonstrate the use of a hardware trigger, whereas I specifically need a software-based solution.

Would anyone be able to assist me in resolving this problem? I am seeking guidance on how to implement a software-triggered approach and would greatly appreciate it if someone could provide me with code that accomplishes this task. Time is of the essence, so your prompt help would be invaluable.

Thank you.

0 Kudos
Message 1 of 5
(408 Views)

A couple different ways you could do it:

 

1. If both tasks are going to run at the same sample rate, you can sync with a shared sample clock without needing a trigger.  Since your device requires an external sample clock for your DI task anyway, this approach is probably the best one.

    Configure the DI task to use "/Dev1/ao/SampleClock" as its own sample clock and be sure to start the DI task before starting the AO task.

 

2. Let the tasks remain hardware-triggered, but let your software generate the trigger signal at a time of your choosing.  For example, use a simple DO task to generate the pulse and configure the AO and DI tasks to use that signal as a trigger.  You need to use a DO line that also has a "PFI" designation, which allows it to be routed as a trigger signal.   On your device, that'll be DO lines on ports 1 and 2.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 5
(383 Views)

Hello, first of all, I want to thank you for your help. However, I've tried to apply what you told me about using a trigger with a Digital Output (DO). You will find attached the code that I have created. Being a beginner, I'm not sure if what I have done is correct. In fact, in my VI, I attempted to generate a signal through AO0 and simultaneously acquire the same signal through AI0. I followed your suggestion by adding a small task that generates a pulse using PFI7 on the board. For both AO and AI tasks, I configured them to use the signal from PFI7 as a trigger. Therefore, I set up these two tasks to receive this signal on PFI8, which should initiate the start of the AO and AI tasks. Unfortunately, this approach is not effective, and I'm uncertain about the source of the error. Specifically:

  • When I launch the program, the AI and AO tasks start even before I generate the trigger signal from PFI7. Consequently, upon starting the program, an error message is displayed that I'm unable to identify.

Could you please let me know where I might have made a mistake in using the triggers?

Download All
0 Kudos
Message 3 of 5
(361 Views)

Hello,

I am currently facing an issue with synchronizing the generation of an analog signal and digital data acquisition. I am using an NI PCI 6251 acquisition card. My goal is to generate an analog signal from pin AO1 while simultaneously acquiring 4 signals from the digital pins on the card.

I am aware that I can synchronize these tasks using a trigger. However, as a beginner, I am unsure about how to achieve this through software rather than hardware. Most of the tutorials I have come across demonstrate the use of a hardware trigger, whereas I specifically need a software-based solution.

Would anyone be able to assist me in resolving this problem? I am seeking guidance on how to implement a software-triggered approach and would greatly appreciate it if someone could provide me with code that accomplishes this task. Time is of the essence, so your prompt help would be invaluable.

Thank you.

Download All
0 Kudos
Message 4 of 5
(367 Views)

Attached is a mod I did to illustrate the method I recommended earlier, based on a shared sample clock.  Consider it a pretty good start but not a perfect example in every way.  Anyway, below in italics are most of the comments that I put on the block diagram:

----------------

 

The general idea is that one task will "borrow" the other task's sample clock to use as its own. Since the same signal drives sampling, their sampling will stay in sync.

 

Another thing of note is how "software triggering" is implemented. Here, the task that will generate the sample clock that both tasks depend on is not started until you click the "SW Trigger" button on the front panel.

 

Event Structure notes:
- starts with infinite timeout (-1 value). Nothing executes until you click a button
- when you click the trigger button, the AI task is started and its sample clock starts existing to be used by the AO task, which is already waiting for it. Then the timeout is set to a very low value (5 msec).
- subsequently, the timeout case is going to keep happening whenever there are no further button clicks. In that case AI data keeps being read from the task. Depending on how many samples you ask for, you'll usually have to wait for them to accumulate before the read will finish.

 

AO generation:

- I chose to make use of the default behavior of regeneration. Fill the buffer up once with a repeating waveform and let the driver and hardware keep repeating it.
- I modified the sine signal generation Express VI to check the 'Integer # Cycles' box, resulting in a potentially smoother transition from the end of the waveform back to the beginning

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 5
(343 Views)