DAQdataIO.rar

  • orangexk
    了解作者
  • Others
    开发工具
  • 111KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 11
    下载次数
  • 2006-07-08 12:29
    上传日期
此源码事基于CVI的,应用DAQ函数实现数字输入输出实例
DAQdataIO.rar
  • 应用DAQ函数实现数字输入输出
  • sample11_ao.prj
    3.4KB
  • sample11_ai.exe
    113KB
  • sample11.c
    3.7KB
  • sample11.h
    1.8KB
  • sample11_ai.c
    1.8KB
  • sample11_ao.obj
    2.7KB
  • sample11.uir
    3.2KB
  • sample11_ai.obj
    2.1KB
  • sample11.obj
    2.6KB
  • sample11.exe
    151.5KB
  • sample11.prj
    3.1KB
  • sample11_ao.c
    2.7KB
  • sample11_ao.exe
    113.5KB
  • sample11_ai.prj
    3.5KB
  • www.pudn.com.txt
    218B
内容介绍
#include <utility.h> #include <easyio.h> #include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */ #include <userint.h> #include "sample11.h" #define MAX_CH_NUM 4 #define SCAN_NUM 100 static int panelHandle; unsigned long numChannels; unsigned long taskID; short device; char channelString[100]; double waveform[MAX_CH_NUM*SCAN_NUM]; int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; if ((panelHandle = LoadPanel (0, "sample11.uir", PANEL)) < 0) return -1; DisableBreakOnLibraryErrors(); DisplayPanel (panelHandle); RunUserInterface (); EnableBreakOnLibraryErrors(); return 0; } int CVICALLBACK TimerCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int i; unsigned long scanBacklog; switch (event) { case EVENT_TIMER_TICK: //获取已采集的数据长度 AICheckAcquisition (taskID, &scanBacklog); //检查采集是否完毕 if (scanBacklog >= SCAN_NUM) { //读取数据 AIReadAcquisition (taskID, SCAN_NUM, LATEST_MODE, &scanBacklog, GROUP_BY_CHANNEL, waveform); //删除控件GRAPH上的所有曲线 DeleteGraphPlot (panel, PANEL_GRAPH, -1, VAL_DELAYED_DRAW); //作曲线图 for (i=0; i<numChannels; i++) PlotY (panel, PANEL_GRAPH, &waveform[i*SCAN_NUM], SCAN_NUM, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_GREEN); //设置控件SAMPLE、DEVICE、CHANNEL有效 SetCtrlAttribute (panelHandle, PANEL_SAMPLE, ATTR_DIMMED, 0); SetCtrlAttribute (panelHandle, PANEL_DEVICE, ATTR_DIMMED, 0); SetCtrlAttribute (panelHandle, PANEL_CHANNEL, ATTR_DIMMED, 0); //设置TIMER控件无效 SetCtrlAttribute (panel, control, ATTR_ENABLED, 0); } break; } return 0; } int CVICALLBACK SampleCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: //获取控件DEVICE和CHANNEL的值 GetCtrlVal (panel, PANEL_DEVICE, &device); GetCtrlVal (panel, PANEL_CHANNEL, channelString); //获取采样通道数 GetNumChannels (device, channelString, ANALOG_INPUT, &numChannels); //开始采样 AIStartAcquisition (device, channelString, SCAN_NUM*numChannels, 2000, 5.0, -5.0, 0, &taskID); //设置控件SAMPLE、DEVICE、CHANNEL无效 SetCtrlAttribute (panelHandle, PANEL_SAMPLE, ATTR_DIMMED, 1); SetCtrlAttribute (panelHandle, PANEL_DEVICE, ATTR_DIMMED, 1); SetCtrlAttribute (panelHandle, PANEL_CHANNEL, ATTR_DIMMED, 1); //设置TIMER控件有效 SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1); break; } return 0; } int CVICALLBACK PanelCallback (int panel, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_CLOSE: QuitUserInterface (0); break; } return 0; } int CVICALLBACK QuitCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: QuitUserInterface (0); break; } return 0; }
评论
    相关推荐