LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I sequentially output 3 different voltage forms of finite duration and synchronize the second one with an input channel?

Solved!
Go to solution

Hi,

 

I am trying to make a 3-stage voltage ramp.  One that goes from 0V to -1V then from -1V to +1V and finally bring the voltage from +1V to 0V.  The key feature is that I'm trying to synchronize an input channel only for the middle ramp.  I'm getting the expected input but my output voltage on the oscilloscope is not correct.  The output and input goes to and comes from a NI USB-6229. On the oscilloscope, the following problems can be seen:

 

1. There is a time lag between the end of the 1st ramp and the start of the 2nd ramp

2. After the main ramp finishes once, the voltage immediately returns to -1V and begins another ramp again until it reaches 0V, then levels out for another short time period

3. The cycle then repeats from the beginning, completely missing the 3rd ramp

 

If anyone who thinks they could help in any way, I would very much appreciate any input.  If anyone tries out the program attached:  I used these parameters:  Input rate=1000; #data points=200; dt=0.0005

 

-Kyle Shiells

0 Kudos
Message 1 of 15
(3,023 Views)
Solution
Accepted by topic author kshiellsnucphys007

If you want to output your 3-stage ramp without any pause between the stages, you should build up the whole waveform (all 3 stages concatenated together) and write it to your output task at once (similar format as this example, but no need for triggering and you would replace the waveform with your own generated array).

 

I would just trigger the analog input off of the start of the analog output task.  You can use the Start.Delay DAQmx Trigger property if you want to wait until the 2nd phase to begin acquiring, or you could simply acquire all 3 stages and parse out what you need.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 15
(3,016 Views)

Hi John,

 

I did what you suggested, concantenated my 3 ramps together to a single waveform array, then I read all the aquired data points in my input and parsed out the beginning and end ramps.  I works.  I still have a time lag between cycles but I think that is due to a hardware limit of my USB DAQ/ADC device.  

 

thanks,

Kyle

0 Kudos
Message 3 of 15
(2,975 Views)

There shouldn't be any time lag between cycles if you just write everything at once and output the entire waveform as one finite output task.  If you post your new code I could take a look if you want.

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 15
(2,969 Views)

Hi John,

 

Sure.  Here it is.  The last 9 data points produced from the main ramp for loop mysteriously are all zero, which is this time lag I'm seeing on the oscilloscope.

 

Kyle

0 Kudos
Message 5 of 15
(2,959 Views)

The Y values array has 94 columns (rows after the Transpose) while the X values array has 100 elements. When you build the 2D array before you write to the file, the shorter array gets padded with zeros to the same length as the longer array because 2D arrays are always rectangular.

 

Note that my numbers are slightly different from yours. I disabled all the DAQ stuff and created a random array of 100 elements in the 1-iteration for loop.  Your DAQmx Read may get a different number.

 

Learn to use dataflow. You do not need the sequence structure and that 1-iteration for loop appears to be there to synchronize parts of the code.

 

It is usually better to do the configuration of the DAQ tasks outside the loop, followed by the Reads and Writes inside the loop, and clearing the tasks after the loop.

 

Lynn

0 Kudos
Message 6 of 15
(2,952 Views)

Hello Lynn,

 

Here is a new version of my code.  I tried to incorporate some of your ideas.  Thanks for your input.  There is still an approximate 60ms period (of 0V) between cycles on my oscilloscope that I cannot remove.

 

Kyle

0 Kudos
Message 7 of 15
(2,930 Views)

Kyle,

 

I suspect the issue with the gaps is due to reconfiguring the DAQ tasks on every iteration. I do not have DAQmx so this may not be completely accurate. You should move the creation and configuration of the tasks outside the loop. Inside the loo do the read and write. After the loop Clear the task.

 

Lynn

0 Kudos
Message 9 of 15
(2,919 Views)

Here is what I meant by outputting the entire waveform as one finite output task:

 

Final2Photon.3.png

 

 

Having the write inside the while loop with an auto-start is going to restart the task on every iteration, you don't want that if you want the output to be continuous cycle-to-cycle.  Try to get the output working by itself before adding the analog input back in (assuming you have some way to monitor the output waveform without incorporating the analog input in your code just yet).

 

 

Best Regards,

John Passiak
0 Kudos
Message 10 of 15
(2,913 Views)