Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI 6602 2 ms counting and synchronized voltage output

Hi guys,

 

I am running a microscope setup that contains a piezo stage that features voltage driven X-Y 2D movement. The stage is controlled by a PCI6731 (Dev1) Board through ao0 (X) and ao1 (Y).

 

Furthermore there are up to to photodetectors that basically generates an edge for every photon that hits it. I want to count them by using Ctr0 and Ctr1 on a PCI6602 Board (Dev2).

 

I will scan a certain area under my objective using the piezo and for each pixel in my image, photons should be counted for exactly  1, 2, 3 or whatever ms (will always be in the ms range). The scanning is being done by to loops and in the inner loop the photon counting is done. Images are typically 256 * 256 or 512 * 512. So the counting event is done quite a number of times.

 

The basic outline of operations is as follows (pseudo programming language and for 1 detector)

 

For Y = 0 to 256 (or 512 or whatever)

  Move Y (Via some ao tasks in a different method)

     For X=0 to 256 (images are always square)

        MoveX

        Setup a counting task on Ctr0 to count edges

        Setup a second counting task on Ctr3 to generate a pulse of 2 ms.

        // I use the 80MHz timebase on this counter for that purpose and I let it output  an edge for 80000 * 2 ticks to create the pulse

        // I route the internal out of Ctr3 to Ctr0

        Define a pause trigger for counter one that  will pause counting on Ctr0 whilst Ctr3 outputs LOW and counts when Ctr3 outputs HIGH

        Start the Ctr0 task

        // I assume Ctr0 will now be paused because of the pause trigger being set.

        Start the Ctr3 task

        // The Ctr3 task will run and let Ctr0 count for 2 ms after which Ctr0 will be paused again

        Read the counts on Ctr0

        Dispose of both Ctr tasks

        Store the Read counter value in a 1D array so that it can be used to rebuild the image later.

 

        // Optioally I run some direct drawing to screen here

   end of X loop

end of Y loop

 

I got the whole thing running in C# on simulated hardware without errors but the implementation is _DEAD_ slow.

 

I ran all my code through Ants profiler and what I noticed was that all my routines such as recalculating a 2D image from the 1D array and drawing it to screen are very fast (I use some unsafe code for that, very fast) but the actual aqcuisition loop with the movement and counting routines is horribly slow.

 

The culprits, according to ants, seem to be the Daqmx.Task.Start() and Stop() calls (task creation also takes some time). But I figured I really need them, since I need to repeat the 2 ms counting 256 * 256 times at least... I could of course try to movetask creation out of the loops and save significant time but I don't see how I could move start and stop outside of the loop...

 

Another issue is that right now, I really couldn't tell how I would achieve coordination between counting and moving the piezo stage. I am doing this by software now through a separate method for my ao tasks. However, in an ideal situation I should be able to do the following;

 

2 ms pixel photon collection

When this is finished trigger a move

Move

When the move is finished, trigger the next photon collection

Repeat

 

I will also attach a file containing the code for the acquisitions and movements. It's a bit messy due to a lot of tinkering and trying things. If necessary I can also provide the full code for my software.

 

I currently can onl test against simulated hardware. Boards are being used by another guy right now but I really need to finish this stuff soon...

 

All help would be welcome, especially some sample code. I'm afraid I'm not skilled enough with Daq to do it completely on my own... I'm getting quite frustrated by the whole thing actually :s

 

 

Download All
0 Kudos
Message 1 of 3
(4,230 Views)

I was just wondering.

 

Could it be that start() stop() methods are much slower when run against simulated HW vs. real HW?

 

 

0 Kudos
Message 2 of 3
(4,212 Views)

Hi guys,

 

Is there really nobody that has an idea about how to solve my problem?

 

I'm totally lost :S and I need a solution quite rapidly.

 

Cheers,

 

Kris

0 Kudos
Message 3 of 3
(4,179 Views)