03-21-2008 04:50 AM
03-21-2008 07:45 AM
03-21-2008 02:20 PM - edited 03-21-2008 02:21 PM
Here are the code extracts:
The initialisation for the Measurement
int mess_init()
{
DAQmxCreateTask("",&handle_mess_1);
DAQmxCreateAIVoltageChan (handle_mess_1,
"Dev1/ai0:1", "", DAQmx_Val_Cfg_Default, 0, 10,
DAQmx_Val_Volts, NULL);
DAQmxCfgSampClkTiming (handle_mess_1, "", 10000,
DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1);
CmtNewThreadPool (1, &POOL);
CmtSetThreadPoolAttribute (POOL, ATTR_TP_THREAD_PRIORITY,
THREAD_PRIORITY_NORMAL);
return 0;
}
Start of aquireing
int messen_start()
{
int32 numRead;
float64 *data_konv=NULL;
int i;
int pos_set=0;
char buff[200];
if (file_selected == 0)
{
DAQmxStartTask(handle_mess_1);
gRunning = 1;
MESS_FILE = fopen ("C:\\aaa\\bbb\\ccc\\ddd\\eee.log",
"w");
if(
(data=malloc(2*10000000*sizeof(float64)))==NULL )
{
MessagePopup("Error","Not enough memory");
}
while(gRunning)
{
DAQmxReadAnalogF64 (handle_mess_1, -1, 10.0, DAQmx_Val_GroupByScanNumber, data,
2*10000000, &numRead, NULL);
if( numRead>0 )
{
for
(i=0; i<numRead*2;i++)
{
if (auswertung==1)
{
reltime=reltime + (0.0001);
fprintf(MESS_FILE,
"%f;%f;%f\n", reltime, data[i], data[i+1]);
if (WERT_2 > weg_maximum[0])
{
weg_maximum[0] = WERT_2;
weg_maximum[1] = WERT_1;
SetCtrlVal(handle_panel, PANEL_WM, weg_maximum[0]);
}
skip=0;
}
i++;
}
PlotStripChart (handle_panel_graph, PANEL_PLOT_STRIPCHART,
data, numRead*2, 0, 0, VAL_DOUBLE);
}
ProcessSystemEvents();
}
}
return 0;
}
Calculation with aquired data
(The Polygon-Things are for calculation and Displaying an Integral of an
channel over the time)
03-21-2008 02:22 PM
03-21-2008 02:23 PM
03-21-2008 02:23 PM
if
(m!=0)
{
E =
E + (((m/2) * pow(weg_2,2) + b * weg_2) - ((m/2) * pow(weg_1,2) + b * weg_1));
}
else
{
E =
E + ((weg_2 - weg_1) * kraft_1);
}
SetCtrlVal(handle_panel, PANEL_E, E);
x_ar[0]=weg_1;
x_ar[1]=weg_2;
x_ar[2]=weg_2;
x_ar[3]=weg_1;
x_ar[4]=weg_1;
y_ar[0]=0;
y_ar[1]=0;
y_ar[2]=kraft_2;
y_ar[3]=kraft_1;
y_ar[4]=0;
graph_x[0]=weg_1;
graph_x[1]=weg_2;
graph_y[0]=kraft_1;
graph_y[1]=kraft_2;
PlotPolygon
(handle_panel_graph, PANEL_PLOT_GRAPH, x_ar, y_ar, 10, VAL_FLOAT, VAL_FLOAT,
VAL_BLUE, VAL_BLUE);
printf("%d\n", u);
u++;
weg_1 = WERT_2;
kraft_1 = WERT_3;
paare=1;
}
count_2++;
}
}
if (reltime != 0)
{
SetAxisRange
(handle_panel_graph, PANEL_PLOT_GRAPH_2, VAL_MANUAL, 0.0, reltime,
VAL_NO_CHANGE, 0.0, 1.0);
SetCtrlAttribute
(handle_panel_graph, PANEL_PLOT_GRAPH_2, ATTR_ACTIVE_YAXIS, VAL_RIGHT_YAXIS);
PlotXY
(handle_panel_graph, PANEL_PLOT_GRAPH_2, graph_x, graph_y_f, count_2,
VAL_DOUBLE, VAL_DOUBLE, VAL_THIN_LINE,
VAL_SOLID_SQUARE,
VAL_SOLID, 1, VAL_GREEN);
SetCtrlAttribute
(handle_panel_graph, PANEL_PLOT_GRAPH_2, ATTR_ACTIVE_YAXIS, VAL_LEFT_YAXIS);
PlotXY (handle_panel_graph,
PANEL_PLOT_GRAPH_2, graph_x, graph_y_s, count_2, VAL_DOUBLE, VAL_DOUBLE,
VAL_FAT_LINE,
VAL_ASTERISK, VAL_SOLID, 1, VAL_RED);
}
}
fclose(MESS_FILE);
return 0;
}
The source code is not very ordinary - the program is in
"beta-status" 😉
Maybe I describe one more time what the program should do:
Aquireing data with a very high rate (10,000 Hz) an displaying some Values on
User Interface (of course not every value, maybe one per second)
A function sets a marker (saving=1)
Now, data are stored in a semicolon-splitted text file
Another marker sets the saving-marker to 0
The saving stops
The analysis of stored data starts (with reading from file)
Greets,
chemph
03-26-2008 12:26 PM