LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

flex_read_trajectory_data_rtn is very slow...any tips for more speed?

I am using CVI 9.and the lastest flex motion version.  I am downloading 160 data points(position & velocity) from one axis on a PCI-7344 flexmotion card.  It is taking about 1.3 seconds to get the data.  Is there any way I can speed this up?

 

Thanks - Dave.

0 Kudos
Message 1 of 6
(3,570 Views)

Hi Dave:

 

How do you have the flex_acquire_trajectory_data function configured?  Something in those settings may allow you to speed up the acquisition.

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,547 Views)

Hi Alex,

The acquisition speed is set to the max speed (3 ms IIRC) and is okay.  I have a for loop to make 160 reads of one axis and place in a data array. 

 

 for(I=0;I<DataSamples;++I)

{
     Status=flex_read_trajectory_data_rtn (NIMCCard, &DataBuffer[I][0]);
     if (Status<0)

    {
         ReportErr(GetArmDataFunctionErr);
    }
    SortedForceData[I] = AvgFrcData[I]= CheckInt2Float(DataBuffer[I][0]);
    ZeroedForceData[I] = SortedForceData[I] - StartCellReading;
    SortedDistData[I] = CheckPos2Float(DataBuffer[I][2]); 
}
 

CheckInt2Float() and CheckPos2Float() are integer to double conversion procedures.

This read procedure takes 1.3 seconds to execute.  No errors are reported. I have put timer reads into the loop and post results to a text box.  The for loop starts out executing fast at 1 or 2 ms per read but ends up at 14 ms per read.  I am pretty sure the buffer is full when I start the read process.

Thanks,

Dave

0 Kudos
Message 3 of 6
(3,538 Views)

Hi Alex,

In my previous post I stated that I was reading one axis.  I had a memory fail; I am reading two axis.  One of the axis is a stepper motor/slide with encoder and the other axis is a load cell. Sorry.

Dave

0 Kudos
Message 4 of 6
(3,536 Views)

Hi Dave:

 

That speed really isn't unexpected as that function runs in the background to all of the other motion processing that is being handled.  That said, it does seem curious that the loop iteration time seems to steadily increase.

 

What are you trying to with this data?  Is it crucial that you get the position that quickly?  One other thing you can try is to use high speed capture to get the position from the motion controller and calculate the velocity from these values.  This is meant to run a lot quicker and may help give you the results you're looking for.  Example code for it can be found at

C:\Documents and Settings\All Users\Documents\National Instruments\CVI\Samples\Motion\FlexMotion\Miscellaneous\High-Speed Capture

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 5 of 6
(3,512 Views)

Hi Alex,

 

Here is a description of what we are doing with the data and why we need it fast.  One axis has a stepper motor slide/encoder and another axis is a load cell that is mounted on the slide. The program uses the data to calculate the contact open point and arm force of a switch assembly.  The program calculates the slope of the data point and looks for the knee on the force/dimension curve that indicates the contact has opened.  Another stepper motor/axis on the system has a method to adjust the arm force.  We need a production rate of several thousand parts processed per hour.  The program has to wait for the data before it can proceed with the arm force adjustment.  Since this may happen 2 or 3 times per switch process cycle, the download time adds up. 

 

My initial look at the High speed capture is that the program wouldn't get enough data to analysis the arm force.

 

I am going to be looking at other methods that would reduce the amount of data required.

 

Thanks,

Dave

0 Kudos
Message 6 of 6
(3,496 Views)