Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pause acquisition, wait for software event, and then resume

I am working on an application that is using the NI PCIe-6361 and C# to move a sensor (via analog outputs) and make readings at several points (via an analog input) with the final result being a rastered image. I have this part working great at this point. However, now I'm working on adding the ability to pause acquisition at some user-defined interval (i.e. every 10000 points), signal the software so that some adjustments can be made, and then resume the acquisition when the software signals everything is ready to continue.

 

My idea is to use a pause trigger on the AI and AO tasks to drive the pause trigger with a digital line that would be configured to go high at the required interval. Then, I want to use the DigitalChangeDetection callback to notify the software that the hardware is paused and that it's safe to make the needed adjustments. Finally, when the software is ready I want to drive the pause line low, causing the AI and AO tasks to resume.

 

Some questions:

1. Is this a reasonable/good way to handle this? Is there a better way? Am I using the correct mechanisms for this?

 

2. I did some initial tests with this and am having some issues. I setup a digital output task to go high at some interval. I then hardwired that digital out (P0.6) to another digital in (PFI1). With that connection I can now do one or the other of the following, but not both at the same time:

 

     a. Get a DigitalChangeDetection event in the software when PFI1 goes high

     b. pause the digital out task when PFI1 goes high

 

Is it not possible to do both of these things at the same time?

 

3. Assuming I can get #2 resolved, is it possible to configure a digital output task to go high at a specific interval (using DigitalSingleChannelWriter.WriteMultiSamplePort in C#), but to also manually push it back low when I want the hardware to resume (using something like DigitalSingleChannelWriter.WriteSingleSampleSingleLine)?

0 Kudos
Message 1 of 4
(5,440 Views)

Hello Eric

 

About your first question: The workaround you explained sounds reasonable for me. It could be done in different ways, so if it is failing, it could be important to know what exactly is failing.

 

I also have another idea. I do not know what kind of adjustments you need to do while the task is not running but... Have you thought in stopping the task instead of pausing the task? Once you finish doing your adjustments you can start the task again... Is there any special reason why you cannot do that? Do you need to respect some kind of special synchronization? It could be easier to implement. 

 

Regards

Frank R.

0 Kudos
Message 2 of 4
(5,398 Views)

Thanks for the suggestion Frank. I'll have to think about the option of stopping the task and restarting. I hadn't considered that. My main concern would be performance. Right now I send a fairly large output buffer to the DACs, which is run continuously (looped) until the user explicitly stops the procedure when they’re done. If I wanted to stop the procedure I think it would require splitting that buffer into multiple separate buffers and pushing them over to the NI card each time I resumed acquisition, which seems like it could really kill performance. I’m pretty new to using NI, so I could be thinking about this wrong. Is there a way to do this without drastically reducing the overall throughput?

0 Kudos
Message 3 of 4
(5,386 Views)

Hello Eric

 

Stopping and starting the task was just an idea I wanted to share with you since it is easier to implement, however I can understand if you think it will kill performance, however I do not see where we need to split a buffer into multiple separate buffer, but anyways. I would like to know what solution you are trying right now, what results are you getting? If you get an error, its code could be helpful. If the problem is the performance, do you have number telling is what is the required performance? I just want to understand the specifications you are trying to accomplish and the results you are getting right now.

 

Regards

Frank R,

0 Kudos
Message 4 of 4
(5,372 Views)