08-19-2014 08:58 PM
hey, thank you its working 
08-19-2014 11:08 PM
hey, Wolfgang I want to save continuous data as it is display by torque and rpm indicator after pressing start data will directly save to text file ( I am using S.EREN BALCI PROGRAM).So In which place should I use your code ??
I am using it in Time Callback function like this, but it is showing Type error (pointer expected ):-
int CVICALLBACK TimerCallback (int panel, int control, int event,
    void *callbackData, int eventData1, int eventData2)
{
  int count;
  int sensor;
  double val;
  char buf[64];
  int index;
 
  
  switch (event)
  {
    case EVENT_TIMER_TICK:
      if (GetInQLen (port) == 0) break;
      
      count = ComRdTerm (port, buf, 64, '\r');
      if (count > 0)
      {
        buf[count] = '\0'; //append null
        
        if (buf[0] == 'S' && strlen(buf) > 10)
        {
          Scan (buf, "%c[d]%i%c[d]%s[t44d]%c[d]%f", &sensor, &val);
          PlotStripChart(pnl,PANEL_TORQUE,&val,1,0,0,VAL_DOUBLE);
          PlotStripChart(pnl,PANEL_RPM,&val,1,0,0,VAL_DOUBLE); 
          if (sensor == 1)
            SetCtrlVal (pnl, PANEL_NUM_SENSOR_1, val);
             
          else if (sensor == 2)
           SetCtrlVal (pnl, PANEL_NUM_SENSOR_2, val);
		} 
      }
      break;
	  {
		  OpenFile("c:\\Users\\주홍찬\\Desktop\\vishal.txt",VAL_WRITE_ONLY,VAL_APPEND,VAL_ASCII);
			  for(index=0;index<64;index++);
		  {
			  FmtFile(pnl,"%f[e3p16]5s%f[e3p16]%s",PANEL_TORQUE[index],",",PANEL_RPM[index],"\n");
		  }
		  
		  CloseFile(pnl);
       }
  }
  return 0;
}
 Wolfgang
		
			Wolfgang
		
		
		
		
		
		
		
		
	
			08-19-2014 11:26 PM
Hey,
my example requires you to use the documentation/help and understand the function parameters...
The idea is to help you doing your work, not doing your work...
You're using the functions OpenFile and FmtFile in a wrong way!
So in CVI, put the mouse cursor on the function OpenFile and press F1 or Ctrl+P. You will realize that you missed the most important parameter, the file handle...
so it should look something like *file_handle = OpenFile (...);
This file handle then is used as the first parameter in FmtFile...
Also, your code fragment is in the wrong place, when should it execute? Right now it executes for every event, not just timer events...
In addition, my example used data arrays, I don't see where you save the data to these arrays; maybe in your case it's better to open the file when you open the serial port, close the file when you close the serial port / program, and write the data when you plot the data on the graph...
 ebalci
		
			ebalci
		
		
		
		
		
		
		
		
	
			08-21-2014 06:14 AM
Hi vishalnit,
The reason I sent you an example code is to help you to start with a working code.
Otherwise it could take forever to get you started.
But, as Wolfgang stated it, we cannot write the whole project for you.
Before you start expanding my project, make sure you understand (even at a abasic level) how things work in CVI.
You do not seem like you have understood the basics of a CVI program.
For example, you have put the OpenFile function OUT OF the case structure (below the break line).
It will NEVER get executed !!
It is easier for you to use the PlotStripChartPoint function rather than PlotStripChart.
You can call it like this (I tried it and it worked with my simulation):
Scan (buf, "%c[d]%i%c[d]%s[t44d]%c[d]%f", &sensor, &val);
if (sensor == 1)
{
  SetCtrlVal (pnl, PANEL_NUM_SENSOR_1, val);
  PlotStripChartPoint (pnl, PANEL_TORQUE, val);
}
else if (sensor == 2)
{
  SetCtrlVal (pnl, PANEL_NUM_SENSOR_2, val);
  PlotStripChartPoint (pnl,PANEL_RPM, val); 
}
 ebalci
		
			ebalci
		
		
		
		
		
		
		
		
	
			08-21-2014 11:08 AM
To keep things simpler I suggest you to use ArrayToFile function.
No need to open/close file or keep file handles.
Just collect every sample you collect in the timer callback (the val variable) in a double array and call the function to write and save all elements of the array into the file.
 patil1983
		
			patil1983
		
		
		
		
		
		
		
		
	
			09-29-2015 06:52 AM
HI
I am trying to comport auto detect,
i am uisng status = viFindRsrc (defaultRM, "ASRL[0-9]*::?*INSTR", &find_list, &retCnt, instrDesc); funtion to detect port , but its working upto port 9 after 9 it not detecting correct one . please give an idea how tp slove this issue. ( comport may be 1 to 255).
thanks
 nyc_(is_out_of_
		
			nyc_(is_out_of_09-29-2015 07:57 AM
@patil1983 wrote:
HI
I am trying to comport auto detect,
i am uisng status = viFindRsrc (defaultRM, "ASRL[0-9]*::?*INSTR", &find_list, &retCnt, instrDesc); funtion to detect port , but its working upto port 9 after 9 it not detecting correct one . please give an idea how tp slove this issue. ( comport may be 1 to 255).
thanks
Don't spam this message board. Duplicate post at http://forums.ni.com/t5/LabWindows-CVI/virtual-comport-auto-detect/td-p/3197519