How can run sample routine more quickly?
Dear Sir or Madam:
I'm using LabWindows/CVI to build a project. I need to get some sample data and then show these data on the computer screen. The sample circuit is made by myself, and the sample IC was AD1674(A/D conversion circuit, 12 bits). One cycle takes 0.5s, and it must finish sampling 1024 points. That means one sample point should not spent more than (0.5/1024)s. Within this time, the sample routine and the drawing must be finished, meanwhile the user interrupt event must be monitor. I used ASM code in sample program, I make this sample program as DLL in VC++, and link it to the main program written by CVI.
The problem is that the drawing on the computer screen is not continuously, it stops one or more times within one cycle. The part of the program showing as following:
Extern short int YdCmpS(short int iCmpValue, short int iResValue);
// YdCmpS is the DLL which is linked to CVI.
int main (int argc, char *argv[])
{
double TestAngle;
int ButtonVal;
if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */
return -1; /* out of memory */
if ((ydypanel = LoadPanel (0, "ydydemo1.uir", YDYPANEL)) < 0)
return -1;
DisplayPanel (ydypanel);
SetIniMember();
RunUserInterface ();
}
int CVICALLBACK TimerCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int ButtonVal;
double show_r; //showing radius
Point Endpoint;
if (event==EVENT_TIMER_TICK)
{
GetCtrlVal (ydypanel, YDYPANEL_YDYBUTTON, &ButtonVal);
if(ButtonVal) {
GetCtrlAttribute (ydypanel, YDYPANEL_YDYRING, ATTR_CTRL_INDEX,
&AmpIndex);
GetCtrlVal (ydypanel, YDYPANEL_YDYRING, &AmpFactor );
Ydnoise[0]=YdCmpS(0,AmpFactor);
Show_r= Ydnoise[i] * ChkValue +ChkRadius;
if(show_r>=MaxShowRadius) show_r=MaxShowRadius;
if(show_r<=MinShowRadius) show_r=MinShowRadius;
show_x=show_r*CosAngle[0];
show_y=show_r*SinAngle[0];
DrawPoint[0]=MakePoint(show_x, show_y);
CanvasStartBatchDraw (ydypanel, YDYPANEL_YDYCANVAS);
CanvasSetPenPosition(ydypanel, YDYPANEL_YDYCANVAS,DrawPoint[0]);
for(i=1;i SetCtrlAttribute (ydypanel, YDYPANEL_YDYCANVAS, ATTR_PEN_COLOR,
PenColor);
CanvasDrawPoint(ydypanel, YDYPANEL_YDYCANVAS,DrawPoint[i-1]);
SetCtrlAttribute (ydypanel, YDYPANEL_YDYCANVAS, ATTR_PEN_COLOR,
VAL_RED);
Ydnoise[i]=YdCmpS(i,AmpFactor);
Show_r= Ydnoise[i] * ChkValue +ChkRadius;
if(show_r>=MaxShowRadius) show_r=MaxShowRadius;
if(show_r<=MinShowRadius) show_r=MinShowRadius;
show_x=show_r*CosAngle[i];
show_y=show_r*SinAngle[i];
Endpoint=MakePoint(show_x, show_y);
CanvasDrawPoint(ydypanel, YDYPANEL_YDYCANVAS, Endpoint);
DrawPoint[i-1]=Endpoint;
}
CanvasEndBatchDraw (ydypanel, YDYPANEL_YDYCANVAS);
}
}
return 0;
}
Thank you very much!