LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

there are a qusition when run the project !!!!!!!!!!!prease help help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!! thank your!!!!!!!!!!!!!!!!

why is the return value of the plotxy function negative?thanks for your to give a solution for this qusition!
0 Kudos
Message 1 of 5
(3,832 Views)
hi
negative value means ther is a error in your plotting.
0 Kudos
Message 2 of 5
(3,827 Views)

thanks for help

then,is it synor error?

0 Kudos
Message 3 of 5
(3,820 Views)
hi
   what is the error?please inspect the code for me,thank you very much!
the code is:
int CVICALLBACK GenerWave (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 
// double p;
 switch (event)
  {
 double *wave;
 double samples;
 double f;
 double phase;
 double cycnum;
 double sampcyc;
 double amp;
  case EVENT_COMMIT:
    GetCtrlVal (panelHandle, PANEL_AMP, &amp);
  GetCtrlVal (panelHandle, PANEL_SAMPCYC, &sampcyc);    
  f=1.0/sampcyc;
  GetCtrlVal (panelHandle, PANEL_CYCNUM, &cycnum);
  
    GetCtrlVal (panelHandle, PANEL_PHASE, &phase);
    samples=sampcyc*cycnum; 
  wave=malloc(samples*sizeof(double));
    SineWave (samples, amp, f, &phase, wave);
   
       // DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_IMMEDIATE_DRAW);
             // PlotY(panelHandle, PANEL_GRAPH, wave, samples, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE,VAL_SOLID, 1, VAL_RED);
           
       PlotY (panelHandle,PANEL_GRAPH,wave,samples,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,
           VAL_SOLID,1,VAL_RED);
 
  free(wave);
           
        
   break;
  }
 return 0;
}
0 Kudos
Message 4 of 5
(3,814 Views)
What error number do you get ?
Is it - 10 The control is not the type expected by the function ?

The check if you use the right panelHandle (is it the same panel that calls
the CallBack ?) and control id. What kind of Graph do you use (Graph,
Stripchart?), maybe its the wrong graph for this function an you have to use
change the control from graph to stripchart or u have to use another
function, PlotXY f.e.

Greetings from Germany

Norbert Rieper




"lxlll" <x@no.email> schrieb im Newsbeitrag
news:1214386810048-731334@exchange.ni.com...
> hi
> &nbsp;&nbsp; what is the error?please inspect the code for me,thank you
> very much!
> the code is:
> int CVICALLBACK GenerWave (int panel, int control, int
> event,&nbsp;&nbsp;void *callbackData, int eventData1, int eventData2){
> &nbsp;//&nbsp;double p;&nbsp;switch (event)&nbsp;&nbsp;{&nbsp;double
> *wave;&nbsp;double samples;&nbsp;double f;&nbsp;double phase;&nbsp;double
> cycnum;&nbsp;double sampcyc;&nbsp;double amp;&nbsp;&nbsp;case
> EVENT_COMMIT:&nbsp;&nbsp;&nbsp; GetCtrlVal (panelHandle, PANEL_AMP,
> &amp;amp);&nbsp;&nbsp;GetCtrlVal (panelHandle, PANEL_SAMPCYC,
> &amp;sampcyc);&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;f=1.0/sampcyc;&nbsp;&nbsp;GetCtrlVal (panelHandle,
> PANEL_CYCNUM, &amp;cycnum);&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; GetCtrlVal
> (panelHandle, PANEL_PHASE, &amp;phase);&nbsp;&nbsp;&nbsp;
> samples=sampcyc*cycnum;&nbsp;&nbsp;
> wave=malloc(samples*sizeof(double));&nbsp;&nbsp;&nbsp; SineWave (samples,
> amp, f, &amp;phase, wave);&nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;DeleteGraphPlot
> (panelHandle, PANEL_GRAPH, -1,
> VAL_IMMEDIATE_DRAW);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> //&nbsp;PlotY(panelHandle, PANEL_GRAPH, wave, samples, VAL_DOUBLE,
> VAL_THIN_LINE, VAL_EMPTY_SQUARE,VAL_SOLID, 1,
> VAL_RED);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PlotY
> (panelHandle,PANEL_GRAPH,wave,samples,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> VAL_SOLID,1,VAL_RED);&nbsp;&nbsp;&nbsp;free(wave);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;&nbsp;&nbsp;}&nbsp;return
> 0;}


0 Kudos
Message 5 of 5
(3,791 Views)