⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkds30xx_example.c

📁 泰克3000示波器波形采集程序CVI,环境LABWINDOWS CVI
💻 C
字号:
/***************************************************************************** 
 *  Copyright 1999 National Instruments Corporation.  All Rights Reserved.   * 
 *****************************************************************************/

/*****************************************************************************
 *  tkds30xx Instrument Driver Sample Program                              
 *  Developed with LabWindows/CVI 5.1                                     
 *  Original Release: 05/24/1999                                  
 *
 *  Purpose:  This sample program initializes the scope, configures it for an
 *            edge triggered acquisition, acquires a waveform, and displays the 
 *            waveform in a message pop-up dialog.
 *
 *            To run this sample program, do the following:
 *            1) Create a new project in LabWindows/CVI.
 *            2) Add this file to the project.  To add files to the project,
 *               select the Add Files To Project from the Edit menu of the 
 *               Project window.
 *            3) Add the .fp file for the tkds30xx instrument driver to the 
 *               project.
 *            4) Check that the resource name used in tkds30xx_InitWithOptions()
 *               is correct. If simulating, change flag to simulate.
 *            5) Run the project.
 *****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <userint.h>
#include "tkds30xx.h"

main ()

{
    #define     CH1     "CH1"
    #define     CH2     "CH2"

    ViSession   vi;
    ViStatus    error = VI_SUCCESS;
    ViReal64    initialX, incrementX;
    ViInt32     actualRecordLength, actualPts;
    ViReal64    meas, *waveform = VI_NULL;
    ViChar      str[256];

        /* 
            If you want to run this sample program and the instrument is not
            present, set the Simulate flag to 1.  (Example:  "Simulate = 1")
        */
        ViReal64 i;
   
    checkErr( tkds30xx_InitWithOptions ("ASRL1::INSTR", VI_TRUE, VI_TRUE,
										"Simulate=0,RangeCheck=1,QueryInstrStatus=1,Cache=1", &vi));
                                        
    checkErr( tkds30xx_ConfigureAcquisitionType (vi, TKDS30XX_VAL_NORMAL));
    
    checkErr( tkds30xx_ConfigureChannel (vi, CH1, 30.0, 0.0, TKDS30XX_VAL_AC, 10.0, VI_TRUE));
    checkErr( tkds30xx_ConfigureChanCharacteristics (vi, CH1, 1.0e6,
                                                     200.0e+6));
  checkErr( tkds30xx_ConfigureChannel (vi, CH2, 30.0, 0.0, TKDS30XX_VAL_AC, 10.0, VI_TRUE));
    checkErr( tkds30xx_ConfigureChanCharacteristics (vi, CH2, 1.0e6,
                                                     200.0e+6));
                                                     
    checkErr( tkds30xx_ConfigureAcquisitionRecord (vi, 0.004, 1000, 0.0));
    
    checkErr( tkds30xx_ConfigureTrigger (vi, TKDS30XX_VAL_EDGE_TRIGGER, 0.0));
    
    checkErr( tkds30xx_ConfigureTriggerCoupling (vi, TKDS30XX_VAL_DC));
    checkErr( tkds30xx_ConfigureEdgeTriggerSource (vi, CH1, 0.00000001, TKDS30XX_VAL_POSITIVE));
    
    checkErr( tkds30xx_ActualRecordLength (vi, &actualRecordLength));
    
    waveform = calloc (actualRecordLength, sizeof(ViReal64));
    waveform1 = calloc (actualRecordLength, sizeof(ViReal64)); 
    
    
	
	
    
  
   
   

 checkErr( tkds30xx_ReadWaveform (vi, TKDS30XX_VAL_CH_1,actualRecordLength , 10000,waveform ,&actualPts,&initialX, &incrementX) );
 

checkErr( tkds30xx_ReadWaveform (vi, TKDS30XX_VAL_CH_2, actualRecordLength, 10000, waveform1,
								 &actualPts, &initialX, &incrementX) );
 
    YGraphPopup ("1", waveform, actualPts, VAL_DOUBLE);
        YGraphPopup ("1", waveform1, actualPts, VAL_DOUBLE);  
    
    
Error:
    if (error != VI_SUCCESS)
        {
            ViChar   errStr[2048];

            tkds30xx_GetError(vi, &error, 2048, errStr);
            MessagePopup ("Error!", errStr);
        }
    if (waveform)
        free (waveform);
    
    if (vi)
        tkds30xx_close (vi);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -