LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a graph?

Hi i want to graph the data that i have on a char array that has the values of a wave form, i have tryed with the functions plotwaveform,plotx and ploty, but when i run the program it shows an error that says: " The control is not the type expected by the funcion" here it's my code for sure i am doing something wrong, but i do not know what is it.
 
 
static char FF6[513]; 
.
.
.
.
 
int CVICALLBACK GetGraph (int panel, int control, int event,  void *callbackData, int eventData1, int eventData2)
{
 ViUInt32 retcount;
 switch (event)
  {
  case EVENT_COMMIT:
    viRead (instrument, FF6, 512, &retcount);
  //PlotWaveform (panelHandle, PANEL_GRAPH, FF6, 512, VAL_CHAR, 1.0, 0.0,0.0, 1.0, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1,VAL_RED);
   PlotText (panelHandle, PANEL_GRAPH, 0.0, 0.0, FF6, VAL_APP_META_FONT, VAL_RED, VAL_TRANSPARENT);
break;
  case EVENT_RIGHT_CLICK:
   break;
  }
 return 0;
}
 
I would like to know if somebody has an example with the code source to make a graph or if somebody can identify my error on my program.
 
Thanks
0 Kudos
Message 1 of 4
(3,738 Views)

Hello,

The PlotText and PlotWaveform do two different things on the graph. PlotWaveform plots a waveform of data points onto a graph control, whereas the PlotText command plots a text string onto a graph control.  Thus they do two different things.  I wanted to clarify which is correct for your needs? Are you trying to plot the waveform values that are stored in the character array, or are you trying to plot the character array as a string onto the graph?

Also, I was able to plot my array using PlotWaveform and known data for the array (an array of 'a' characters).  Therefore I think that the problem we are having might be in the data we are receiving from the VISA Read command.  What type of data are we getting/expecting?

John B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,708 Views)
I have found the problem, it was that i have declared on the user interface stripchart and i was trying to setup a normal graph on the C code, now this issue is solve, thanks for your sugestions.
 
Now i have another problem may be you can help me. I am sending data from my USB RAW and i want to enable the USB interrupt with visa commands in order that when there is an interrupt my program in CVI gets the values from the USB.
 
i have tryed in diferent ways but always i got an error setup on the function, and the programm dos not run.I have read the only example that is on the user manual but i have still the problem, i have declarated my funciton, installed the handler, but when i want to eneble the VI_EVENT_USB_INT is when the problem appears, the error code says :
 
ViEnableEvent : Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state)
 
The code that i am using is the next:
 
//headers files
static unsigned char FF6[513];
static ViStatus status;
static ViSession defaultRM;
static ViSession instrument;
static ViObject instrument;   
static int panelHandle;
static int start=0; 
static ViBuf Userhandle;
static ViEvent eventContext;
static ViUInt32 retcount; 
static ViEventType etype; 
//USB int event handler
ViStatus _VI_FUNCH myCallback(ViSession instrument, ViEventType etype, ViEvent eventContext, ViAddr UserHandle)
{
//printf("hola");
//ViUInt32 retcount;
//ViJobId jobID;
//ViUInt16 stb;
//status = viReadSTB (instrument, &stb);
//status = viReadSTB(vi, &stb);
//status = viReadAsync(vi,(ViBuf)UserHandle,512,&jobID);
 
status = viRead (instrument, FF6, 512, &retcount);      //read the values of fifo6
  
return VI_SUCCESS;
}
 
int main (int argc, char *argv[])
{
// ViBuf Userhandle;
// ViEvent eventContext;
// ViEventType etype;

 if (InitCVIRTE (0, argv, 0) == 0)
  return -1; /* out of memory */
 if ((panelHandle = LoadPanel (0, "usb.uir", PANEL)) < 0)
  return -1;
 status = viOpenDefaultRM (&defaultRM);   //we open the Resource Manager
 if (status < VI_SUCCESS)      /*Check if we have an Error Initializing VISA...exiting*/
  return -1;
    status = viOpen (defaultRM, "USB0::0x04B4::0x1002::NI-VISA-0::RAW", VI_NULL, VI_NULL, &instrument); //we open the communication with our instrument
 if (status < VI_SUCCESS)      /*Check if we have an Error Initializing instrument...exiting*/
  return -1;
 viFlush (instrument, VI_WRITE_BUF_DISCARD);
 viFlush (instrument, VI_READ_BUF_DISCARD);
 
 Userhandle = (ViBuf)malloc(512);
 status = viInstallHandler (instrument, VI_EVENT_USB_INTR, myCallback, Userhandle);
 if (status < VI_SUCCESS)      /*Check if we have an Error to istall the handler for the USB INT */
  return -1;
 
 status = viEnableEvent (instrument, VI_EVENT_USB_INTR, VI_HNDLR, VI_NULL);
 if (status < VI_SUCCESS)      /*Check if we have an Error to istall the handler for the USB INT ************************** Here is the problem ***************************/
  return -1;

 DisplayPanel (panelHandle);
 RunUserInterface ();
 DiscardPanel (panelHandle);
 
 return 0;
}
 
 
I hope you can indentify where is my mistake, also i would like to know if you can send me and example using events, that will be very usefull for me, Thanks
0 Kudos
Message 3 of 4
(3,670 Views)

hi,i have the same error with you,could you tell me how to solve it.

0 Kudos
Message 4 of 4
(2,455 Views)