LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

AO Waveform Generation and AI in the same program

I am trying to get AO Waveform Generation and AI to work in the same program.

A simplified version of my program is attached (I will post the missing AI file separately).

The AO Waveform Generation sends signals to relays, which activate solenoids, which apply pressure pulses to my test specimen. The long array is so I can control the timing of the signals (the transverse channel is inactive as shown). I would like to collect data while the waveform is running, and have the data collection start when the waveform generation starts (I don't care if data collection continues after the generated waveform has run its course).

However, what happens is that while the generated waveform is running, the analog input (and the data collection) stops working - the chart doesn't show any motion, and no data are collected during that time.

Any ideas on how to make these two processes play nice together?

Thank you.
0 Kudos
Message 1 of 12
(4,342 Views)
Here is the AI subroutine.
0 Kudos
Message 2 of 12
(4,339 Views)
Anneliese,

Run the AI and AO in parallel. The way your program is currently written, you get 1 AI scan and 1 set of the AO array each time the while loop iterates. From your description I think you want the AI to loop repeatedly while the AO is sending its sequence of data. Start the AI in a loop of its own. Then start the AO in a parallel process. After the AO completes, stop the AI.

Also look into the event structure and a state machine architecture. Both techniques are very useful in this type of program.

Lynn
0 Kudos
Message 3 of 12
(4,334 Views)
Lynn -

Actually, the AI works just fine if the AO Waveform Generation isn't active, and I've set up the AO Waveform Generation so it just triggers once. But I'll try out your suggestions.

Thanks,

Anneliese
0 Kudos
Message 4 of 12
(4,324 Views)
Lynn -

Closer, but no cigar. Thank you for the hint on the event structure. I can now continue to display data while the AO Waveform Generation does its thing, but there's something wrong with the data collection - only two points are saved. I suspect it has to do with the nested WHILE loops, from looking at Highlighted Execution, but I can't figure out what to do.

Does anybody have any suggestions?

Program attached, with AI replaced with a random # generator (since the AI doesn't seem to be a problem).

Thanks

Anneliese
0 Kudos
Message 5 of 12
(4,314 Views)
Anneliese,

Look at the attached file. I set two independent loops. One has the Event structure and the AO (simulation). The other has the AI simulation and graph. I added notes to most of the things I changed. I eliminated the local variables and used queues to pass commands between the loops. In the actual program I would probably have three or more independent loops. The User Interface, the AI and the AO.

Lynn
Message 6 of 12
(4,299 Views)

Lynn -

Thank you, thank you, thank you!

Your code worked beautifully, and I was able to integrate it into my actual program with little difficulty.  I'd never even heard of the queuing functions you used, and I doubt I'd have come up with that code on my own.

Thanks again,

Anneliese

0 Kudos
Message 7 of 12
(4,289 Views)
Anneliese,

I am glad I was able to help. LabVIEW is simultaneously a simple to use and an extraordinarily complex and rich development environment. I have been using LV since version 1.2 and probably have more to learn than what I already know about it. This forum is a place where those who have questions can usually get answers and those who have knowledge and experience can in return give something back, because we all had to learn sometime.

Lynn
0 Kudos
Message 8 of 12
(4,277 Views)
Dear sir
I need the same application, but I dont have labVIEW 7.1 ,I have labVIEW 7 Express .When I downloaded the vi and tried to run it , an error message like " the vi version is newer than the labVIEW version".So how to solve this problem?or Can U send me the same application which is programmed on labVIEW 7 EXPRESS.
Thanks
Haider
 
[edited by moderator to remove confidential information - 05/21/2015]
0 Kudos
Message 9 of 12
(4,175 Views)

Hello Haider,

I saved the code down to a 7.0 version.  Hope this code helps you too...nice job Lynn!

Thanks,

Justin M.
National Instruments
0 Kudos
Message 10 of 12
(4,158 Views)