Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx function generator - multiple channel output

Solved!
Go to solution

I am using cDAQ 9172 for data acquisition. I am not  familiar with LabVIEW.

I need to write 2 continuous sine signals to 2 ports on the 9263 output module.    The signals need to be able to vary their amplitude, phase , offset and frequency  dynamically ( on the fly).

I am trying to modify the code present here: http://zone.ni.com/devzone/cda/epd/p/id/8699 (also attached here)
This code writes to one port, and I need to write to 2 ports.

There 7 parameters I need to input to this code 

Signal 1 to port ao1:
Amplitude 1
Frequency 1
Phase 1
Offset

Signal 2 to port ao2:
Amplitude 2
Frequency 2
Phase 2
Offset

Note that the offset value is the same for both ports.

Each of these parameters are calculated separately and need to be input to the above code as local variables. 

My program works fine when I use the above code with inputs as Frequency 1, phase 1 , amplitude 1, offset 
and write the resulting sine signal to one port (a01)

Question:   How do I modify the code so that it writes to 2 ports simultaneously ?  I think replicating the same code twice (as two separate loops is) not a good idea.

Any suggestions?






0 Kudos
Message 1 of 17
(6,337 Views)

Hi, 

 

Please see attached two screeshots that show how we can write to multiple channels within 1 task (The only way to do this because there is only one timing engine on our DAQ cards --> only one analog output task is possible at any given time).  You will notice that I use the merge signals Express VI to merge the two sine ways signals and wire that to the DAQmx write.  Currently as is this VI allows me to switch the parameters of the sine waveson the fly as they are inside of the while loop.

 

klet me know if you have any questions regarding this!

Charley Dahan

Global Account Manager
Download All
0 Kudos
Message 2 of 17
(6,313 Views)

CharlesD,

                    thanks for the reply.   I am able to vary the frequency and amplitude dynamically but not the phase.  I need to restart the program to see a change in phase. Why is this happening?

  

0 Kudos
Message 3 of 17
(6,291 Views)
Solution
Accepted by topic author Sanjeevs
never mind...I got it running  by wiring a boolean true constant to reset signal of the Simulate Signal vi.   Thanks for your help
0 Kudos
Message 4 of 17
(6,288 Views)

When I run the vi, I get the following error message

 

Error -200462 occurred at DAQmx Start Task.vi:1
 
Possible reason(s):
Measurements: Generation cannot be started, because the output buffer is empty. 

Before starting a buffered generation, write data. Unreserving a task empties the buffer. Changing the size of the buffer or setting the Regeneration Mode property will result in the buffer being unreserved and emptied.

 

I moved DAQmx start task from before the loop to after the loop.  It does not help.   What can be done? 

Thanks 

0 Kudos
Message 5 of 17
(6,272 Views)

Ensure that you are starting the task BEFORE the While loop like in the screen shot.  I made the same mistake earlier when I forgot to put a start task block before the while loop and I got the same error.  Also make sure that all of the drop down menus below the DAQmx functions are the set to same exact values as I have put in my block diagram.  Lets try this and then we will go from there,  My program seemed to work fin on my machine so it could very well be that you did not copy something appropriately. 

 

 

 

 

Charley Dahan

Global Account Manager
0 Kudos
Message 6 of 17
(6,255 Views)

I spent quite some time to ensure that I copied your code right, and I did not find  any discrepancies.   Can you upload your vi here? That ll help me resolve this issue much quicker. Thnks 

0 Kudos
Message 7 of 17
(6,250 Views)

Please see attached LabVIEW code:

 

 

Charley Dahan

Global Account Manager
0 Kudos
Message 8 of 17
(6,220 Views)

Even this vi (the one you sent) shows the same error. Nothing related to the setup has changed.  Is there some alternate approach to solve this issue?

 

0 Kudos
Message 9 of 17
(6,210 Views)

Alright let's try one more thing.  It sounds like this error is saying that it wants you to write some data to the buffer BEFORE we start the task.  with my device I got the same error as you after re-running it with real-hardware instead of a simulated device.  I was then able to rectify the error code by writing an empty data (0) to the buffer before starting the task.  PLease see the attached VI.  If this does not work let me know and we will try something different.

 

Thank you 

Charley Dahan

Global Account Manager
0 Kudos
Message 10 of 17
(6,185 Views)