|
我本来认为是很EASY的事,怎么变的这么麻烦
事情是这样的,我打算把我生成的3路正弦信号,分别送到PXI-6289的ao0,ao1,ao2三个通道上去。波形已经能通过如下的代码生成,没想到输出到引脚成了大问题,看了些关于DAQ方面的资料,感觉是越看越糊涂。什么DAQ助手,也不过就是帮我生成初始化的框架。感觉DAQ助手的用处有限,不知道是我不会用,还是大家都认为它没用。
我把代码发在下面,大家帮我看看,我是个新手,希望大家能帮我完善下代码,怎么才能把信号送出去。
#include <ansi_c.h>
#include <analysis.h>
#include <cvirte.h>
#include <userint.h>
#include "sin.h"
#define PI 3.1415926535
static int panelHandle;
double amp;
double amp0;
double amp1;
double amp2;
int sampcyc;
double f;
double phase;
double cycnum;
int samples;
double *wave0;
double *wave1;
double *wave2;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "sin.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK GenerateWave (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal(panelHandle,PANEL_AMP,&);
GetCtrlVal(panelHandle,PANEL_NUMPCYC,&sampcyc);
f=1.0/sampcyc;
GetCtrlVal(panelHandle,PANEL_CYCNUM,&cycnum);
GetCtrlVal(panelHandle,PANEL_PHASE,&phase);
samples=cycnum*sampcyc;
wave0=malloc(samples*sizeof(double));
wave1=malloc(samples*sizeof(double));
wave2=malloc(samples*sizeof(double));
amp0=amp*sin(phase/180.00*PI);
amp1=amp*sin((phase+120.00)/180.00*PI);
amp2=amp*sin((phase+240.00)/180.00*PI);
SineWave(samples,amp0,f,&phase,wave0);
SineWave(samples,amp1,f,&phase,wave1);
SineWave(samples,amp2,f,&phase,wave2);
DeleteGraphPlot(panelHandle,PANEL_GRAPH0,-1,VAL_IMMEDIATE_DRAW);
DeleteGraphPlot(panelHandle,PANEL_GRAPH1,-1,VAL_IMMEDIATE_DRAW);
DeleteGraphPlot(panelHandle,PANEL_GRAPH2,-1,VAL_IMMEDIATE_DRAW);
PlotY(panelHandle,PANEL_GRAPH0,wave0,samples,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,
VAL_RED);
PlotY(panelHandle,PANEL_GRAPH1,wave1,samples,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,
VAL_RED);
PlotY(panelHandle,PANEL_GRAPH2,wave2,samples,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,
VAL_RED);
free(wave0);
free(wave1);
free(wave2);
break;
}
return 0;
}
int CVICALLBACK TRANS_CLOSE (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
} |
|