Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Task/Create Channel Theory

I have a general question about DAQmx theory that I'm hoping someone can help me with.  I am using LabVIEW 2011 with a USB-6211 card.

 

Basically what I'm doing is generating a sinusoidal signal with the 6211 to feed a force generator and then reading a load cell with the 6211 as well.  I have to perform this sinusoidal force test 1000 times, then I return to position 0, place a 0 load on the system and wait.  I then repeat the whole process 5 more times.

 

Now my specific question is about creating/closing tasks in DAQmx.  When I initialize the program, I create a task called "Input" and then I create an Analog Input Voltage Channel (linked to input AI0) and a DAQmx Sample Clock where I set my rate to 1000.  I next create a task called "Output" and then I create an analog output voltage channel (linked to AO0).  The theory is that I can use these tasks at any place in my program because it performs different read and write functions at different times during operation.

 

So, during the first part of the test I wire the output task to a DAQmx Write (1Chan NSamp) and write 10 samples (of a continuously generated sine wave) at a time.  In a parallel loop I wire the input task to a DAQmx Read (1Chan NSamp) and read 10 samples at a time.  This seems to work without a problem.

 

The problem seems to happen when I move to the next phase of the test.  I repeat what I did in the last paragraph, I wire the output task to a new Write and the input task to a new Read.  I read what the measured force is at this point and I write a 1000 sample wave which ramps the force from whatever it is measured at to a force of 0.  Then I wait a specified amount of time before repeating the test.

 

The problem seems to be that before the ramp down to 0 load occurs, there is a sharp spike in force that I don't want.  I'm wondering if there is a problem with the way I'm reusing my task to start a new write and read?  I can't really figure out why else I would be getting this spike.  I'm not asking for a solution my specific problem, I'm asking if I'm doing the write/read correctly or if there is a better way to do it.

 

Thanks for your help.

0 Kudos
Message 1 of 2
(2,964 Views)

Two main possiblities occur to me:

1.  The first sample you generate as part of the ramp down represents a step function from the last voltage you wrote out to the output task, possibly because it hasn't yet been physically generated.  The load cell response you last measured will be past-tense by the time the output task gets to your ramp down waveform.

2.  Could also be a problem with scaling between your measured load cell response and the scaling you apply to create the ramp.

 

The solution to issue 1 is to focus on generating a ramp-down from the last value you wrote to your output task rather than your most-recently-read input value. 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 2
(2,919 Views)